Claude Modsunofficial directory

Automation·terminal · desktop·no license file

Agent Time Machine

Every tool call on a branching timeline with snapshots: inspect, restore, branch, rerun.

Generic cover for Agent Time Machine: a placeholder terminal with the band above the prompt highlighted

Agent Time Machine records every tool call Claude Code makes as a numbered step on a timeline, and after each one that can change files it takes a git snapshot of your project in a separate repository. You can then see the files as they were at any step, find which edit broke a test, put the project back, branch off from an earlier step, compare two runs and run a step again. It is the time-machine plugin of YeonwooSung’s my-claude-code-mods marketplace, and it never writes to your own .git.

It does not replace Claude Code’s /rewind. It adds what /rewind misses, files changed by Bash commands, plus the timeline, test blame and comparisons, and it moves only files: the conversation is never rewound. Claude Time Machine also snapshots Bash with git, but it is an undo tool, with buttons to roll back a turn or a single command; Agent Time Machine is for working out what happened, step by step. Both plugins are named time-machine and both register /tm, so install only one.

What it does

Everything goes through /tm:

  • Timeline. /tm draws the last 30 steps as a tree: number, tool, target (a file, command or pattern) and marks for test results, denials, errors and snapshots. --all shows every step and --branch <name> another branch. /tm-pane keeps the same tree open in a live pane.
  • Inspect. /tm show <n> prints a step’s input, the head of its result, the files it changed, its test result and its snapshot. /tm diff <a> [b] shows the diff between the snapshots of two steps, or between a step and now, cut at 400 lines.
  • Test blame. /tm why takes the last failing test run and ranks up to five files changed since the last passing run of the same command, by whether the failure output points at them and how recently and often they changed. If a later run passed, it lists the steps that fixed it. The author calls the ranking a clue, not proof.
  • Restore and branch. /tm restore <n> lists the files that would change; with --yes it sets the files to step n, after a safety snapshot, so the restore can be undone. /tm branch <n> [name] --yes does the same and records the steps that follow on a new branch, leaving the old path intact. Claude gets a note that the files changed and that its earlier reads are stale.
  • Compare. /tm compare <a> <b> sets two branches, or a branch and an earlier session (session:<id>), side by side: where they forked, the steps only on each side, the file differences and each one’s last test result.
  • Rerun. /tm rerun <n> calls the step’s tool again with the same input, through the normal permission check, and reports whether the result is identical or which lines changed, including any change in passed and failed tests. Tools that change files or act on their own (Agent, Skill and similar) need --write. --isolated runs a Bash step in a temporary copy of the snapshot taken before it.
  • /tm sessions lists the recorded sessions of the project.

The status line shows the last step number, how many snapshots were taken and the average snapshot time.

Install

Needs Claude Code 2.1.287 or later and git.

claude plugin marketplace add YeonwooSung/my-claude-code-mods
claude plugin install time-machine@my-claude-code-mods

The marketplace holds six other mods by the same author (agent-profiler, context-inspector, loop-detective, pin-memo, model-effort-band and token-run); the second command installs only this one. Recording starts by itself. Run /tm once Claude has used a few tools.

How it works

Where snapshots go. Everything lives under ~/.claude/time-machine/, one folder per project, named after the project folder plus a short hash of its path. Inside are a bare git repository (shadow.git) with the snapshots, one git index per session, and each session’s timeline as JSON Lines files. The storeDir setting moves it; it must be an absolute path outside the project, or snapshots turn off.

Your repository. The mod runs git with its own git directory and index and pins git’s environment variables, so your .git, branches, staging area and history are never written to. The one thing it takes from your .git is .git/info/exclude, copied when a session first uses git, so your local ignore rules apply too. It also works in a folder that is not a git repository.

What a snapshot holds. Each snapshot stages the whole project into the shadow index: tracked files and any untracked file that .gitignore does not exclude. Ignored files such as node_modules, build output and .env are never copied. A commit is made only when something changed, and git stores each file version once. The author gives no disk-usage figures.

When. A baseline is taken just before the first tool that can change files, so startup is not slowed. After that a snapshot follows every Edit, MultiEdit, Write and NotebookEdit, every MCP or unknown tool, and every Bash command, because a redirect can write files from a “read-only” command (the skipSearchBash setting skips commands such as grep, ls or cat). Read-only tools never trigger one. If files changed between Claude’s tool calls, say because you edited in your editor, the difference becomes a separate external step so it is not blamed on Claude.

Cleanup. Once a day, in the background, the mod deletes session records older than 14 days (retentionDays; 0 keeps everything) along with their snapshot references, removes leftover temporary folders, and runs git gc --auto, which reclaims space when git judges it due. Deleting the project’s folder under ~/.claude/time-machine/ removes its whole history.

What the timeline records. For each step: the tool input, with secret-looking values masked and each text field cut at 4 KiB, the first 2 KiB of the result, and parsed test results. Model turns are kept only as lengths and hashes unless you turn on recordModelOutput, which also stores Claude’s replies and the first 200 characters of your prompts. Masking covers these records only: snapshots are plain copies of your files, so a secret in a file that is not ignored is in the shadow repository too.

Cost and network. It makes no model calls and no network requests. It runs only git and a few shell commands (sh, mkdir, rm, find, cp). After a restore or branch it adds a short note to the conversation so Claude re-reads the changed files.

Guards. /tm restore and /tm branch with --yes, and every /tm rerun except an --isolated dry run, run only when you type them; if Claude issues them they refuse, and none of this is exposed as a tool. A restore refuses if the files changed since its safety snapshot, or if the target step holds a path that is now ignored, since overwriting an ignored file could not be undone.

Limitations

  • A rerun repeats the tool, not the session: Claude’s replies, web fetches, MCP results, time and randomness are not replayed.
  • A nested git repository is stored only as a pointer, without its contents, and one with no commits makes snapshots fail until they turn off.
  • Snapshots turn off when git is missing, the session root is your home folder or /, or the baseline takes more than 5 seconds; the timeline keeps recording. In large repositories every tool that can change files waits for its snapshot.
  • A log file inside the project that keeps changing produces an external step before every tool that changes files. Changes from a background Bash land in the next snapshot, and attribution between parallel tool calls is approximate.
  • /tm rerun --isolated is a copy, not a sandbox: the command still reaches your environment, home folder and network, and it skips the permission prompt. Without --yes it only shows what would run, and it refuses commands that name the project’s absolute path. The copy lacks ignored files, dependencies included.
  • A step whose stored input was cut or masked can be rerun only in the same Claude Code process (the last 500 steps, 32 MiB at most), not after a reload or resume.
  • /tm why parses output from pytest, jest, vitest, go, cargo and node:test. With other runners it knows only pass or fail from the exit status.
  • The author documents the pane and status line in the terminal; the /tm-pane message says the pane also shows in the desktop app. In the VS Code chat panel the hooks record and /tm answers, but neither draws. With claude -p, recording and snapshots still work.
  • The author lists no supported systems. The code calls sh, mkdir, rm and find and turns snapshots off when the store path does not start with /, so it is written for macOS, Linux and WSL.
  • The repository has no license file.