Skip to content

Timemachine

Before the agent runs any tool that changes files, timemachine snapshots your working tree, so anything it deletes or overwrites can come back. In a --dangerously-skip-permissions session there is no prompt between the agent and your files, and plain git protects only what you committed: an uncommitted change or an untracked file the agent clobbers is gone for good. With a snapshot taken first, you get it back.

How it works

A harness plugin, one that dresses up the session itself and never touches your notes. It registers a hook that fires just before any file-changing tool runs (Edit, Write, Bash, and the rest - a PreToolUse hook, in Claude Code terms). The hook saves your tree as a commit under refs/timemachine/, a side shelf inside your repo’s own .git storage that sits on no branch, then lets the tool run. It never blocks anything. A safety net, not a gate.

captured

Exactly what git add -A would stage.

  • tracked files you changed
  • new files git does not ignore
never captured

Anything .gitignore hides: your .env, keys, build output.

Names shaped like secrets are skipped even if you forgot to ignore them:

.env*.pem*.key*.p12*credentials*
snapshots live in your repo's .git local only, never pushed newest 200 kept, older pruned

Commands

Terminal window
node plugins/timemachine/timemachine.js list
node plugins/timemachine/timemachine.js restore <id> <path>
node plugins/timemachine/timemachine.js show <id>
node plugins/timemachine/timemachine.js status
node plugins/timemachine/timemachine.js wipe
  • list shows snapshots, newest first
  • restore <id> <path> brings a file back into the working tree
  • show <id> shows what a snapshot holds
  • status shows count, location, last snapshot time
  • wipe deletes every snapshot in this repo

If the agent clobbered something, run list, find a recent snapshot, and restore the path. Commit once the file is back.

Install

Terminal window
imprnt plugin add timemachine

This copies the plugin into plugins/timemachine/ and wires it as a native Claude Code plugin. imp passes the folder to every session it launches, so the hook is active without touching your Claude settings. (Gemini cannot host Claude hooks, so imp --gemini skips timemachine with a warning and runs without the safety net.)

To remove:

Terminal window
imprnt plugin rm timemachine

Adding --purge deletes the folder too. Snapshots stay in .git until you wipe them.

Limits

It protects files inside a git repo only, so it pairs with keeping your work in git. It is damage recovery, not security and not an off-machine backup. And a snapshot preserves the state before each tool rather than stopping the tool: the agent still does the thing, you just get to undo it.