-
-
tm init on a real open-source repo (slugify) guesses the check and install step, turns the network off for checks, saves a first point.
-
An agent's edit breaks the code. Time Machine saves that state too; tm verify runs the tests in a separate copy: FAIL, exit code, log.
-
tm find-good checks save points newest first and stops at the newest one that passes. tm timeline shows each verdict.
-
tm recover puts the working version on a new branch plus a recovery copy, saves your current state first, and lists what it did not restore.
-
Nothing is switched, pushed or merged: the recovery branch is new, your folder keeps your latest edits, and every step is in the audit log.
-
tm demo builds a small app, breaks it the way an agent might, and rescues it with the real engine, naming the .env values to set again.
-
The MCP server gives any agent 7 tools: checkpoint, timeline, diff, verify, find_good, recover and log.
-
The local web app (tm ui): the project's status, the last version that works, and every save point on one ruler.
-
Going back: review the version that passed, what changed, and the three steps before anything moves.
-
What runs where: hooks, CLI, MCP server and web app share one engine and a store outside your project. The website is separate.
-
CI on every pull request: tests on macOS and Linux with Node 22 and 24, plus a clean install from source.
-
time-machine-site.vercel.app: save before the agent acts, check with your own tests, bring back the newest version that passes.
Inspiration
We build with coding agents every day. Claude Code is fast, and most of the time it is right. But when it is wrong, it can be wrong across twenty files and a shell command at once: a "lint fix" that quietly breaks checkout, a cleanup that deletes a working feature, a git reset --hard run at the wrong moment.
Undo works for typing, not for that. Git only helps if someone committed at the right moment, and an agent doesn't. And even when you find an old version, you still don't know whether it actually worked.
So we asked a narrower question than "how do we undo everything?": can we always get back the newest version that passed our own tests, and say honestly what we couldn't bring back? Time Machine is our answer.
What it does
Time Machine saves your project before Claude Code acts. It runs your own tests on each save point in a separate copy, then brings back the newest one that passes, on a new branch. Your folder and your current branch are never touched, and nothing is pushed, merged or deployed.
A real run, shortened (from tm demo, which builds a small app, breaks it the way an agent might and rescues it with the real engine):
$ tm find-good
cp-0006 FAIL The check failed with exit code 1.
cp-0005 FAIL The check failed with exit code 1.
cp-0004 FAIL The check failed with exit code 1.
cp-0003 PASS The check passed.
PASS cp-0003 is the newest version that works.
$ tm recover cp-0003
Recovery ready for cp-0003. Nothing was pushed, merged or deployed. Your folder and branch were not touched.
Branch tm/recover/cp-0003
Saved first cp-0007, your state before this recovery
Not restored
Secret values in .env: PORT, STRIPE_SECRET_KEY
Databases, deployed versions and external services are not captured
On your own project it is four commands:
tm init # guesses the check (npm test) and the install step (npm ci, or npm install without a lockfile)
tm checkpoint -m "works" # or let the Claude Code hooks save for you
tm find-good # checks save points newest first, each in a fresh copy
tm recover cp-0001 # new branch tm/recover/cp-0001 plus a recovery copy
The main pieces:
- Saves before the agent acts. Claude Code hooks save before each prompt and before risky shell commands such as
rm -rf,git reset --hard,git clean -fandDROP TABLE. When a save happens, Claude Code shows one line, for example "Time Machine saved cp-0007 before git reset --hard." - Checks with your own tests.
tm verifyandtm find-goodrebuild each save point in a separate Git worktree, with a clean environment and a time limit, and run your check there. - Five honest verdicts. PASS (exit 0), FAIL (1), INCOMPLETE (2, something saved is missing), BLOCKED (3, the check can't run yet) and ERROR (4, crashed, timed out or failed its integrity check). A save point that was never checked is shown as "not checked", never as working.
- Recovers without touching your work.
tm recoversaves your current state first, then createstm/recover/cp-XXXX.tm restoreputs single files back, and--dry-runwrites nothing. - Says what it did not restore. Every result names the
.envvalues you must set again by hand (only key names and a fingerprint are stored, never the values), plus databases, deployed versions and outside services. - Agents can use it too. An MCP server exposes 7 tools (checkpoint, timeline, diff, verify, find_good, recover, log), so any MCP agent can save and check its own work.
- A local web app.
tm uiopens a history view with live check output, the failing test names (Jest, Vitest, Mocha,node --test, TAP), comparisons, and "Put it back" for one file or all. Its server binds to127.0.0.1.
How we built it
- One engine, three front doors. A TypeScript pnpm monorepo on Node 22+:
packages/coreis the engine,packages/cliis thetmcommand (and serves the web app), andapps/webis the web app. The Claude Code plugin, the hooks and the MCP server all call the same engine, so human output and--jsonoutput come from the same result. - Save points that survive. Each save point is stored in
~/.timemachineas a git bundle with metadata: code including uncommitted changes, untracked files, lockfiles and version pins such as.nvmrc, environment file digests and config key names. Deleting the project folder doesn't delete its history. - Signed results. Save points and verdicts are signed with a local key. That catches accidental edits and edits by tools that don't read the key; we say plainly that it is not tamper-proof against someone who can read the key.
- Sandboxed checks. With
network: deny, test runs get no network (sandbox-execon macOS,bwraporunshareon Linux). If no sandbox is available, the verdict is BLOCKED instead of a silent run. - Validated everywhere. Config, hook input and MCP arguments go through zod schemas.
- Tested hard. 776 automated tests in 73 files (Vitest), 99 of them for the website's functions. CI runs on macOS and Linux with Node 22 and 24. Acceptance tests V01 to V14 run on a synthetic project, and every bug fix starts with a failing test.
- Website. A static site on Vercel with small serverless functions for the waitlist, sign-in and checkout (checkout isn't open yet), and a Supabase-backed waitlist.
Challenges we ran into
- Checking a save point without touching your folder. Running tests in place would overwrite your work. We rebuild each save point in its own Git worktree, with its own install step, and clean it up after.
- Defining "passing" honestly. Flaky tests, missing test commands and half-saved states are common. A plain pass/fail would lie, so we added INCOMPLETE, BLOCKED and ERROR, each with its own exit code.
- Secrets. Bringing back a
.envfile would copy secrets into a store. We keep only key names and a fingerprint and tell you which values to set again by hand. - Hooks that never get in the way. The hooks act only in projects where
tm initran, step aside if another hook set already saves, and stop with one clear message if the approved check changed (for example after agit pull). - Being honest about limits. It is tempting to promise "undo anything". Databases, deployments, emails and payments live outside the project, so every result names what was not restored.
Accomplishments that we're proud of
- A recovery that proves itself. The result is the newest save point that passed your own tests, on a new branch, not a guess.
- Measured on a real open-source repo. On 17 Oct 2026, on
sindresorhus/slugify, from a clean folder with a fresh home and an empty npm cache:tm initto a verified recovery branch in 54 to 82 seconds over two runs (script:scripts/time-first-run.sh). Almost all of that time isnpm installinside the fresh copies. - 776 passing tests across the engine, CLI, web app and site functions, green in CI on two operating systems.
- Exit codes that agents can act on. Every command except
tm uitakes--json, and the verdict exit codes let scripts and agents decide what to do next.
What we learned
- Git worktrees and bundles are a great base for safe, separate copies, once you handle missing objects and moved folders.
- Process sandboxing works very differently on macOS and Linux, so "network off" needs a fallback that says BLOCKED rather than pretending.
- An agent tool needs machine-readable results first and pretty output second.
- Threat-modelling an agent's destructive commands (what it can delete, reset or drop) shaped which commands trigger a save.
- Honest limits build more trust than big promises.
What's next for Time Machine
- npm release of the
timetmpackage, so install is one command instead of building from source. - More agents and editors through the MCP server and hooks.
- Action connector (planned, v2): record and, where honest, reverse what agents do in Gmail, Slack, Notion, Calendar and Stripe, with the same "what was not restored" list.
What's real, what's not yet
- Works today, from source: the
tmCLI, the local web app (tm ui), the Claude Code plugin and hooks, and the MCP server. Code: https://github.com/ShadowEsu/Time-Machine (MIT). - Not yet: the npm package isn't published, and the action connector is planned, not built.
- Limits: a passing check means your tests passed, not that the app is correct. Checks run in a separate worktree, which is weaker isolation than a container.
Built for Next Byte Hacks V5
Time Machine was built during Next Byte Hacks V5. The first commit to github.com/ShadowEsu/Time-Machine was on Oct 13, 2026, inside the Oct 6 to 31 window, and the project has not been submitted to any other hackathon. Time Machine is not affiliated with Apple Inc.
Built With
- claude-code-hooks
- git
- mcp
- node.js
- pnpm
- supabase
- typescript
- vercel
- vitest
- zod