Claude Code /rewind and checkpoints: what they undo
How Claude Code's /rewind and Esc Esc work: the restore and summarize choices, what checkpoints miss (Bash, subagents), 30-day retention, and -p rewinds.
Type /rewind (also /undo or /checkpoint), or press Esc twice on an empty prompt. Pick one of your earlier prompts, then choose Restore code and conversation, Restore conversation, Restore code, Summarize from here or Summarize up to here. Claude Code takes a checkpoint before every prompt you send, but it only tracks edits made by its own file tools: a file that only a shell command changed, edits you made in your editor, and most subagent edits are not restored. Snapshots go after about 30 days by default. It is an undo for the session, not a replacement for git.
Open the rewind menu
/rewind # or /undo, or /checkpoint
Esc Esc # with the prompt input emptyCopiedIf the prompt has text in it, the first double Esc clears it instead, and the cleared text goes to your input history, so Up brings it back after you are done in the menu. In vim mode, press Esc twice from NORMAL mode. The menu lists the prompts you sent in the session; each prompt that started a turn is a checkpoint, because Claude Code captures your files “before each prompt you send that starts a turn”, per Anthropic’s checkpointing page (as of November 2026). It has existed since Claude Code 2.0.0.
In the VS Code extension, hover over any message and a rewind button appears, with three choices: Fork conversation from here, Rewind code to here, and Fork conversation and rewind code. For cloud sessions at claude.ai/code, Anthropic’s docs mention a Rewind to here action only in a troubleshooting entry: on a self-hosted runner with Claude Code before v2.1.246 it fails on any message except the newest.
What each choice does
| Choice | Your files | The conversation |
|---|---|---|
Restore code and conversation | Back to that point | Back to that point |
Restore conversation | Left as they are now | Back to that point |
Restore code | Back to that point | Kept in full |
Summarize from here | Untouched | That message onward becomes a summary |
Summarize up to here | Untouched | Everything before it becomes a summary; later messages stay |
Never mind | Untouched | Untouched |
The two code options only appear when Claude’s tracked edits after that point have something to revert. If you only see Restore conversation and the summarize options, the checkpoint has no captured file changes.
After Restore conversation or Summarize from here, the prompt you picked is put back in the input box, so you can edit it and send it again. To steer a summary, highlight a Summarize option with the arrow keys and type into the row that reads “add context (optional)”; pressing the option’s number key summarizes straight away. A summary does not touch your files and the original messages stay in the transcript. Claude Code’s /compact covers when a summary is the better tool than a whole-conversation compact.
Two details catch people out. If you rewind the conversation and then exit before sending another prompt, the rewound messages can come back next time; send Claude a prompt before you exit, because the rewind is saved together with it (restored files stay restored either way). And if you ran /clear earlier in the same Claude Code process, the top of the menu has a /resume <session-id> (previous session) entry that takes you back to the conversation before the clear.
What a rewind does not undo
Checkpoints follow Claude’s file editing tools (Write, Edit and NotebookEdit). Everything else depends on whether one of those tools had already touched the file:
- Shell commands. Once Claude has edited a file with its file tools, a rewind also undoes later changes a Bash command made to that file. A file that only Bash commands changed is not tracked and stays as it is. A
sed -ion a fresh file, a code generator,npm installrewriting a lockfile: none of these come back unless Claude edited the same file first. - Your own edits and other sessions. Changes you make outside Claude Code, and edits from another Claude Code session running at the same time, are normally not captured, unless they land on files this session has edited.
- Subagents. A forked skill running in the foreground edits during your own turn, so its edits rewind as usual. Any other subagent, including a forked skill in the background (the default) and a background
/code-review --fix, has its edits restored only in files Claude had already edited in your conversation; the rest stay. Claude Code subagents covers how they run. - Messages typed while Claude was working. They can show as No code restore in the menu and have no checkpoint of their own. Pick the prompt that started that turn and restore code from there; that reverts the whole turn’s edits.
- Symlinks and hard links. A tracked path that is a symlink or hard link is skipped (dotfile-manager configs and files pnpm hard-links are the usual cases), and so is a file whose directory changed since the checkpoint.
- Directories. The SDK’s version of the same mechanism lists “Creating, moving, or deleting directories is not undone by rewinding” and says remote or network files are not tracked.
- Anything outside the machine. A rewind restores files on disk. A commit, a push or a database migration runs as a shell command, so it falls under the Bash rule above, and whatever it changed on another system stays changed.
When a restore skips files, Claude Code says so:
Restored the code, but skipped 2 files: the tracked path is (or became) a link or other non-regular file, its directory changed since the checkpoint, or its backup could not be safely read. Skipped files were left untouched — run with --debug for the paths.CopiedThe message only gives a count. Run /debug before the restore and the log at ~/.claude/debug/<session-id>.txt names each skipped path; on macOS or Linux find . -type l lists symlinks and find . -type f -links +1 hard-linked files. For a skipped file, ask Claude to reverse its edit or fix it yourself.
How long checkpoints last, and where
Snapshots are stored per session in ~/.claude/file-history/<session>/ as pre-edit copies of the files Claude changed, and checkpoints are saved with the conversation, so /rewind still works after you resume the session. Two limits apply:
- The last 100 checkpoints. Claude Code keeps file snapshots for the 100 most recent checkpoints in a session. Older snapshots no remaining checkpoint needs are deleted, except each file’s first one.
- About 30 days. The retention sweep deletes a session’s snapshots once they pass
cleanupPeriodDays(default 30, minimum 1), counted from the last snapshot the session saved. The checkpoints still show in the menu after that, but restoring one can fail.
The failure looks like this:
Failed to restore the code:
No files were restored: 1 file failed (backup missing, or the file could not be updated)CopiedOnce the backups are gone, trying again fails the same way; restore from git or ask Claude to reverse the edits. The same message appears if Claude Code could not write a file (fix the permissions and run /rewind again), or in a fork made with /branch or --fork-session when copying a backup into the fork failed, for example on a full disk. Before v2.1.260, missing backups were skipped silently and the rewind looked like it had worked, so update if you are on something older. To keep snapshots longer, raise the retention in ~/.claude/settings.json; it also keeps transcripts longer, which matters if they hold secrets:
{
"cleanupPeriodDays": 90
}CopiedClearing these out is optional, and permanent. Deleting ~/.claude/file-history/ yourself loses checkpoint restore for past sessions. claude purge on a project deletes its sessions’ file-history/ entries along with its transcripts and auto memory, after a confirmation that reads “This cannot be undone”; deleting Claude Code sessions and history covers both.
Turn checkpointing off
The setting is fileCheckpointingEnabled, on by default. In /config it is Rewind code (checkpoints), and toggling it there writes the key to your user settings. It can sit in any settings file; the settings.json guide covers which file wins.
{
"fileCheckpointingEnabled": false
}CopiedFor one session, start with CLAUDE_CODE_DISABLE_FILE_CHECKPOINTING=1 claude. Whichever of the two turns it off, the other cannot turn it back on. With checkpointing off, no file snapshots are taken, so /rewind cannot restore code changes.
Rewind in claude -p and the Agent SDK
A claude -p run has no menu, and file checkpointing is off there unless you ask for it: fileCheckpointingEnabled is ignored in -p and SDK sessions (unless managed settings set it to false, which keeps it off from Claude Code v2.1.331). In the Agent SDK, set enableFileCheckpointing: true (TypeScript) or enable_file_checkpointing=True (Python) and call rewindFiles() or rewind_files() with the UUID of the user message to go back to; the SDK checkpointing page shows the full pattern, including the replay-user-messages option you need for those UUIDs. This restores files only; the conversation is not rewound.
If you captured the session ID and the checkpoint’s message UUID, you can also rewind from a shell. The SDK turns checkpointing on for you, but a direct claude -p needs CLAUDE_CODE_ENABLE_SDK_FILE_CHECKPOINTING set on the command, and the original session must have had checkpointing enabled:
CLAUDE_CODE_ENABLE_SDK_FILE_CHECKPOINTING=true claude -p --resume <session-id> --rewind-files <checkpoint-uuid>Copied--rewind-files does not appear in claude --help, but the CLI accepts it. On success it prints Files rewound to state at message <checkpoint-uuid> and exits without sending a prompt. A bare claude -p with --rewind-files and no variable fails with “File rewinding is not enabled”. On a server where Claude Code runs unattended, that makes checkpoints something you plan for at launch, not something you can reach for afterwards.
Checkpoints and git
Anthropic puts it plainly: checkpoints “are designed for quick, session-level recovery”, and permanent history belongs in version control. Rewind is the fast way back from a turn that went wrong; by default its snapshots go after about 30 days, and it misses files only shell commands changed. For commits, branches and undoing what Claude did in git, see Claude Code and git.