← Blog

Claude Code Revert: Undo Changes With /rewind

September 13, 2026

AI Coding

To revert changes in Claude Code, run /rewind or press Esc twice with the prompt empty. /undo and /checkpoint are aliases for the same command. All of them open checkpointing, the built-in way to handle Claude Code revert and undo.

How it works, per Anthropic's docs as of September 2026:

  • Every prompt you send creates a checkpoint of your code as it was just before.
  • File snapshots are kept for the 100 most recent checkpoints in a session.
  • Checkpoints are saved with the conversation, so /rewind still works after you resume a session.
  • Snapshots are deleted in a retention sweep, by default about 30 days after the session last saved one.

The catch: checkpointing only tracks edits Claude makes with its file editing tools. Shell commands, most subagents, and your own edits sit outside it, which is why git still matters.

How to undo in Claude Code

You have three ways in:

  • /rewind, or its aliases /undo and /checkpoint.
  • Esc twice with an empty prompt. If there's text in the prompt, double Esc clears it instead and saves it to your input history, so pressing Up gets it back.
  • The VS Code extension has its own version. Hover over a message and click the rewind button, then pick Fork conversation from here, Rewind code to here, or Fork conversation and rewind code. The VS Code docs point to the same checkpointing system, limits included.

One shortcut sounds like it should work but doesn't. According to the interactive mode reference, Ctrl+_ undoes your last edit to the prompt text. It doesn't touch your files.

What each Claude Code revert option does

The rewind menu lists every prompt you sent this session. Pick one, then pick an action:

OptionCodeConversation
Restore code and conversationReverted to that pointReverted to that point
Restore conversationLeft as it is nowRewound to that message
Restore codeReverted to that pointKept
Summarize from hereUnchangedEverything after this point is compressed
Summarize up to hereUnchangedEverything before this point is compressed, later messages kept
Never mindUnchangedUnchanged

The code options appear only when that checkpoint has tracked file changes to revert. If nothing was captured after that point, you'll see only Restore conversation, the two summarize options, and Never mind. That doesn't mean something broke. It means no tracked edits happened after that point.

After Restore conversation or Summarize from here, the prompt you picked goes back into the input box. That makes for a good loop: rewind to just before a bad instruction, rewrite it, and send it again.

The summarize options exist to free up context, not to undo anything, and they leave the files on disk alone. For more on managing context, including the whole-session version, see how auto-compact works.

What rewind can't revert

Bash commands aren't tracked. If Claude runs rm file.txt, mv old.txt new.txt, or cp source.txt dest.txt, rewind can't undo it. The same goes for any file a shell command changes, whether that's a codemod script, sed -i, or a formatter.

Subagent edits usually aren't restored. Subagents edit with the same file tools, but Claude Code usually doesn't capture those edits in your session's checkpoints. The exception is a foreground forked skill: a skill with context: fork that runs in the foreground, for example with background: false. It edits your working tree during your own turn, so rewind restores it. Every other subagent needs git, and that includes a forked skill running in the background (the default) and a background /code-review --fix run. Our Claude Skills guide explains how skills are put together.

Changes made outside the session aren't tracked. Edits you make in your editor, and edits from other Claude Code sessions running at the same time, normally aren't captured unless they touch the same files as the current session.

Some files get skipped. A restore skips any tracked path that's a symlink or hard link, or whose directory changed since the checkpoint, or whose backup can't be read safely. You'll see Restored the code, but skipped N files, and those files keep their current contents. Config files linked in by a dotfile manager and files pnpm hard-links into place both land here. Turn on /debug before restoring and the debug log lists each skipped path.

Before and after you rewind

Look before you revert. /diff shows the changes in your working tree, including Claude's edits and anything else you haven't committed. It's the fastest way to tell whether the damage came from file edits, which rewind can undo, or from shell commands, which it can't.

If you get No files were restored, either the backups for that checkpoint are gone or Claude Code couldn't write the files, for example because of permissions. Backups disappear in the retention sweep, and /rewind still lists the old checkpoints after they're gone. The error reference suggests asking Claude to reverse its edits, or restoring from version control. To keep backups longer, raise cleanupPeriodDays in your settings. It defaults to 30, and setting 0 fails validation.

Getting back a cleared conversation. If you ran /clear earlier in the same Claude Code process, the rewind menu shows an extra entry at the top: /resume <session-id> (previous session). Picking it brings back the conversation you had before the clear. It needs v2.1.191 or later and lasts until you exit or resume a different session.

Branch instead of rewinding. If you want to try another approach and keep the current path, /branch creates a copy of the conversation and switches you into it, and /resume takes you back to the original. From the command line, claude --continue --fork-session does something similar. Rewind changes where you are. A branch gives you a second place to work.

Why git still does the heavy lifting

The checkpointing docs say it plainly: checkpoints are for quick recovery within a session, and they're not a substitute for version control. Git doesn't care whether a change came from a file edit, a shell command, or a background subagent. It sees whatever is on disk.

A split that works:

  • Use checkpoints for the fast inner loop. An edit went wrong, so go back two prompts, rephrase, and try again.
  • Use git for anything you'd hate to lose. Commit before you hand a large task to an agent. The things checkpoints miss (shell commands, background subagents, linked files) show up a lot in big tasks. When those need undoing, git restore throws away unstaged changes to a file.

Our guide to coding agents covers the write-test-fix loop where you'll reach for both.

Which undo fits which change

What changedHow to undo it
An edit Claude made with its file tools this session/rewind or /undo, then Restore code
The conversation went off course but the code is fineRestore conversation
Files changed by a shell commandgit
Edits from a background subagent or /code-review --fixgit
A symlinked or hard-linked file that was skippedAsk Claude to reverse the edit, or fix it by hand
Snapshots older than your retention periodgit, and a higher cleanupPeriodDays next time

Most people learn this table by losing an afternoon of work first. Taku works one step earlier. You don't assemble an AI setup yourself and find its failure modes the hard way. You mirror one somebody has already proven and run it in your own desktop workspace. Taku is in Beta, and the Mac app is available now.