← Back to BlogAgentic Coding

What Claude Code Rewind Cannot Undo

Claude Code rewind tracks edits made by its file tools. What it misses, when files stay lost, and the git habits that undo the rest.

According to the Claude Code docs, rewind restores the file edits Claude made with its own file editing tools, plus changes later made by shell commands to files it had already edited. The docs also say it does not restore a file that only a Bash command touched, that it usually misses subagent edits, and that it normally does not capture changes you made outside the session. For those cases the fix is git: commit before you start, work on a branch or worktree, and keep git reflog in mind.

Sources: Claude Code docs: Checkpointing

The risk is not that rewind is broken. It is that /rewind looks like a universal undo button, and the page that documents it lists several things it does not cover. This post walks through each limit, shows which git command covers the gap, and ends with a short pre-session routine.

Insight

Disclosure: we build TLM Forge, a process layer for Claude Code, so weigh the product section near the end accordingly. It does not provide rollback. Git does.

What /rewind actually does

Checkpointing captures the state of your code before each prompt you send that starts a turn. The docs say Claude Code keeps file snapshots for the 100 most recent checkpoints in a session, and that it saves checkpoints with the conversation, so /rewind still works after you resume a session. Menu wording and limits are as the docs describe them today and may change. You open the menu with /rewind, or by pressing Esc twice when the prompt input is empty.

Sources: Claude Code docs: Checkpointing

The menu lists your prompts. After you pick one, you choose an action. The docs list these:

  • **Restore code and conversation**: revert both to that point.
  • **Restore conversation**: rewind the chat but keep the current code.
  • **Restore code**: revert file changes but keep the conversation.
  • **Summarize from here** and **Summarize up to here**: compress part of the conversation to free context. These do not change files on disk.
  • **Never mind**: go back without changing anything.

One detail matters before you rely on it. The two code restore options appear only when the selected checkpoint has tracked file changes to revert. If no file edits were captured after that point, the menu offers only conversation restore, the summarize options and Never mind. A missing code option means the selected checkpoint has no tracked file changes to revert.

Sources: Claude Code docs: Checkpointing

What rewind does not cover

The checkpointing page documents several gaps, most of them under Limitations. Each one maps to a way people lose work while believing they had an undo.

Sources: Claude Code docs: Checkpointing, Limitations

1. Files only a Bash command changed

Once Claude has edited a file with its file editing tools in your conversation, /rewind undoes changes that Bash commands make to that file afterward. A file that only Bash commands changed is not tracked and stays as it is. So rm, mv or a sed -i on a file Claude never touched with its edit tools is outside the safety net. The docs say to use version control, such as Git, to revert it.

Sources: Claude Code docs: Checkpointing, Bash command changes not tracked

The rule has a boundary that is easy to misread. It does not say "Bash is never tracked." It says a file becomes tracked once Claude edits it with the file tools, and from then on shell changes to that file can be rewound too. What decides the outcome is whether Claude has edited that file with its file tools in your conversation, not which tool made the later change. The docs describe Bash changes to such a file as undone, but a deletion is the case to verify: the first issue below reports one that was not restored.

2. Subagent edits

A subagent edits with Claude file tools, but Claude Code usually does not capture those edits in your session checkpoints. The docs make one exception: a foreground forked skill edits your working tree during your own turn, so rewinding restores its edits. For any other subagent, rewinding restores only the files Claude had already edited in your conversation. The subagent edits to other files stay. This includes a forked skill that runs in the background, which is the default.

Sources: Claude Code docs: Checkpointing, Subagent edits not restored

3. Changes you or another session made

The docs say checkpointing only tracks files that have been edited within the current session. Manual changes you make outside Claude Code, and edits from other concurrent sessions, are normally not captured, unless they happen to modify the same files as the current session. If you keep an editor open while Claude works, or run two sessions in one checkout, treat a code restore as unreliable for those changes.

Sources: Claude Code docs: Checkpointing, External changes not tracked

4. Symlinked and hard-linked files

Checkpointing does not rewind symlinked or hard-linked files. When you restore code, Claude Code skips any tracked path that is a symlink or hard link and shows a Restored the code, but skipped N files warning. The skipped files keep their current contents. The error reference lists other skip reasons too, such as a directory that changed since the checkpoint. The docs give two examples of linked files: config files a dotfile manager symlinks into your project, and files pnpm hard-links into place. Read that warning rather than dismissing it.

Sources: Claude Code docs: Checkpointing, Symlinked and hard-linked paths, Claude Code docs: Error reference, rewind warnings and errors

5. Messages typed mid-turn

A message you type while Claude is still working can be marked **No code restore** in the menu, because it has no checkpoint of its own. To undo the edits Claude made after that message, select the prompt that started the turn and choose a code restore. That reverts the edits from the whole turn, including the ones made before your message arrived, so you may lose more than you meant to.

Sources: Claude Code docs: Checkpointing, Messages sent mid-turn

6. Old checkpoints expire

Per the docs, snapshots are bounded two ways. Only the 100 most recent checkpoints in a session keep file snapshots, and Claude Code deletes the file snapshots of a session in its retention sweep, by default about 30 days after the session last saved one. Those figures are the docs' current defaults and may change. Rewinding to a checkpoint whose snapshots are gone can fail with No files were restored. The setting cleanupPeriodDays keeps snapshots longer. The docs describe checkpoints as designed for quick, session-level recovery.

Sources: Claude Code docs: Checkpointing, Automatic tracking, Claude Code docs: Error reference, rewind warnings and errors

Insight

The docs close the section with a plain statement: checkpoints are designed for quick, session-level recovery, and for permanent version history you keep using version control, such as Git.

Reports from the issue tracker

The public issue tracker for Claude Code shows people running into the edges of this model. These are single-user reports on specific versions and platforms, not confirmed findings, and behavior may differ in other versions, so treat them as examples of what to watch for rather than proof of how rewind behaves for everyone. Issue 34368, opened in March 2026 by a user on Windows in a VS Code terminal running version 2.1.38, and closed as not planned by a bot for inactivity, reports that the code rewind option appeared on a turn where Claude deleted a file and that rewinding did not bring the file back. Issue 91733, opened in September 2026 by a user on macOS running version 2.1.236, reports that rewinding to a prompt showed no restore menu for a file Claude had created and then edited, and that the file kept its edited content.

Sources: GitHub issue 34368: Rewind offers to undo file deletions it cannot actually restore, GitHub issue 91733: Rewind does not restore file content for untracked files edited in session

The reporter of the second issue wonders whether the file never having been added to git played a role, and says that is unclear. Whatever the cause turns out to be, the practical lesson is the same: do not make a rewind the only copy of anything you care about.

Rewind or git: what to use when

What happenedDoes rewind restore it?What to use instead
Claude edited a file with its edit tools and the result is worseYes, with Restore codeRewind is the right tool. A commit beforehand gives you a second copy.
A Bash command changed a file Claude had already edited this sessionPer the docs, yes. Verify deletions: issue 34368 reports one that was not restoredRewind, then check the result with git diff.
A Bash command (rm, mv, sed -i) changed or deleted a file Claude never edited with its edit toolsNo, the file is not trackedgit restore --source=HEAD <path>, if the file was committed.
A subagent edited files Claude had not edited itselfUsually nogit diff to see the damage, then git restore or revert the branch.
You or another session changed a file in the same checkoutNormally not capturedCommit your own work first. Run one session per worktree.
The file is a symlink or a hard linkSkipped, with a warningAsk Claude to reverse the edit, edit it yourself, or restore from git if the path is committed.
The session is old, or the checkpoint is beyond the 100 most recentNot guaranteed. The docs say snapshots cover the 100 most recent checkpoints and are swept by default about 30 days after the session last saved oneA commit or branch. Git history lives outside Claude Code snapshot storage.
Uncommitted work was lost and there is no commit to return toOnly if Claude edited it with file toolsNothing reliable. Commit before sessions so this row never applies.

A git safety net in four habits

None of this is exotic. It is the ordinary git workflow, applied before the agent starts instead of after something breaks.

Habit 1: commit or stash before a risky session

A commit is a restore point for everything it contains, whether shell commands, subagents or you changed those files afterward. Before a session that touches many files, commit what you have. Note that git add -A stages every untracked file that is not ignored, so check git status first if secrets or large files sit in the folder. If you would rather not commit unfinished work, git stash push saves the working directory and index and reverts the tree to match HEAD. By default it leaves untracked files alone; the -u option stashes untracked files too, and -a also takes ignored files, which matters for local config such as a .env file.

Sources: git-scm.com: git-stash

``` git add -A git commit -m "wip: before Claude session" # or, to set work aside instead: git stash push -u -m "before Claude session" ```

Habit 2: give the session its own branch

git switch -c <name> creates a new branch and switches to it. Do it before you prompt, and every change the session makes lands on a branch you can delete or reset without touching main.

Sources: git-scm.com: git-switch

A worktree goes one step further. A repository can support multiple working trees, which lets you check out more than one branch at a time. git worktree add -b <branch> <path> creates a new branch and checks it out into a separate directory, so the agent works there while your own checkout stays untouched. That keeps your edits and the agent edits out of the same directory, which avoids the external changes gap from the list above. When you are done, git worktree remove deletes it, and it only removes clean worktrees unless you pass --force.

Sources: git-scm.com: git-worktree

``` git worktree add -b claude/refactor-auth ../myapp-claude cd ../myapp-claude # run Claude Code here; delete the folder if the experiment fails ```

Habit 3: small commits per phase

Commit when each logical piece works, not once at the end. Every commit becomes a restore point, and git restore --source=<commit> <path> takes a file back from any of them. Without --source, git restore restores from the index, so name the source when you mean a specific commit. The structure of those commits matters for review and bisecting too, which is covered in Clean Git History When an AI Agent Writes the Code. This post is only about the restore-point side.

Sources: git-scm.com: git-restore

Habit 4: know where git reflog fits

Reflogs record when the tips of branches and other references were updated in the local repository, and HEAD@{2} means where HEAD used to be two moves ago. If an agent runs a reset or rebase and a commit seems to vanish, git reflog often lists it so you can return to it. Entries expire: gc.reflogExpire defaults to 90 days, and gc.reflogExpireUnreachable to 30 days. The limit is the important part. The reflog only knows about commits and ref moves. Work you never committed was never recorded, which is why habit 1 comes first.

Sources: git-scm.com: git-reflog

Put an approval step in front of destructive commands

Recovery is the second line of defence. The first is not running the command unreviewed. The docs say that in Manual mode, Bash commands need your approval except a built-in set of read-only commands, and file modifications need approval too. Other permission modes change which actions prompt, and the docs say bypassPermissions skips prompts. Permission rules are evaluated in order: deny, then ask, then allow, and a matching ask rule prompts even when a more specific allow rule also matches. That makes an ask rule a reasonable fit for commands that destroy state, such as Bash(git clean *) or Bash(git push *), which appear as ask-rule examples in the docs.

Sources: Claude Code docs: Configure permissions

Keep the limits of that in view. The docs state that a Bash rule matches the command text Claude writes and is not a security boundary around the program, so a different form of the same command can slip past it. The full treatment, including what deny rules miss, is in Claude Code Permissions: What Deny Rules Miss. Treat an approval step as friction that catches the common case, and keep the git net for the rest.

Sources: Claude Code docs: Configure permissions

Pro Tip

Make the approval prompt useful by reading the command before pressing yes. A prompt you approve on reflex adds no safety. If you find yourself approving everything, narrow the allow list rather than the habit.

When the damage is a loop, not a deletion

Not every loss is a deleted file. Sometimes the session slowly wrecks a working codebase while retrying the same failing fix, and the right move is to return to the last good commit and start over with a clearer prompt. That pattern is covered in Why Claude Code Keeps Fixing the Same Bug. A recent commit makes that reset cheap. Without one, you are choosing between a rewind that may not cover everything and a manual cleanup.

A different failure is an agent that weakens a safeguard while doing routine work. Rewind and git can restore files, but only a review of the diff shows what changed and why. See OpenAI Agents Weakened Their Own Monitoring, and One Denied It.

Where TLM Forge fits

TLM Forge does not provide rollback, and nothing in it replaces the git habits above. What it offers is earlier visibility: on Medium and Deep tasks it shows a design for your OK before building, so you can read the plan before code changes. On Deep tasks it also runs a spec audit.

The design sign-off is a review of a plan, not a snapshot of your files. Commit first, then run the process.

A five-line routine before any big session

  • Commit or stash what you have, using -u if untracked files matter.
  • Create a branch, or a worktree if you also edit files yourself.
  • Check that files you care about, such as local config, are either committed or consciously accepted as unprotected.
  • Add ask rules for commands that destroy state, and read each prompt before approving.
  • Commit after each phase that works, so any later problem has a nearby restore point.

Frequently asked questions

01Does Claude Code rewind undo rm?

Not for a file that only a Bash command touched; the docs say that file is not tracked. If Claude had already edited it with its file tools, the docs say later Bash changes are undone, but verify with git. Restore from git if committed.

02How do I undo Claude Code changes?

Run /rewind, or press Esc twice on an empty prompt, pick the prompt you want to return to, and choose Restore code. For anything rewind does not track, such as shell deletions or subagent edits, use git restore from a commit.

03Does /rewind work after I close and resume a session?

Yes, checkpoints are saved with the conversation, so you can run it after resuming. The docs say a retention sweep deletes snapshots by default about 30 days after the session last saved one, and old rewinds can fail with No files were restored.

04Is rewind a replacement for git?

No. The documentation describes checkpoints as quick, session-level recovery and tells you to keep using version control for permanent history and collaboration. Commit before risky sessions so a restore point exists outside Claude Code.

05How do I revert Claude Code changes I did not commit?

If Claude edited the files with its edit tools, use rewind and Restore code. Otherwise uncommitted work has no reliable recovery, because git only records what was committed or stashed. That is why committing first is the habit that matters most.

Ship AI-written code you can trust

TLM Forge is the missing process layer for Claude Code: a spec audit, independent multi-agent review, enforced TDD, and an adversarial red-team gate.

Get TLM Forge