Claude Code saves a checkpoint every time you send a prompt, so you can undo its file edits, rewind the conversation or both. If Claude just broke something, you do not need Git gymnastics: press Esc twice or type /rewind, pick the prompt before things went wrong and restore.
The same menu can also summarize part of a long conversation to free up context without losing your earlier instructions.
This guide covers how checkpoints work, how to undo changes step by step, what each rewind option does, summarizing, rewinding after /clear, the limits you must know (Bash commands, subagents, symlinks), how checkpoints compare with Git and fixes for common errors. It follows Anthropic’s official Claude Code documentation as of December 2026.
- Open the menu:
/rewind(alias/undo), or pressEsctwice with an empty prompt. - Options: restore code and conversation, conversation only, code only, or summarize.
- Automatic: every prompt creates a checkpoint; the last 100 per session keep file snapshots.
- Survives resume: checkpoints are saved with the session, kept about 30 days by default.
- Not tracked: files only changed by Bash commands, most subagent edits and symlinked files.
- Still use Git: checkpoints are a quick undo, not version control.
How Checkpoints Work
A checkpoint is a restore point for the files Claude edits with its file editing tools.
- Every prompt you send that starts a turn creates a new checkpoint.
- Claude Code keeps file snapshots for the 100 most recent checkpoints in a session. When an older checkpoint is discarded, snapshot files no other checkpoint needs are deleted, except each file’s first snapshot.
- Checkpoints are saved with the conversation, so
/rewindstill works after you resume a session. - Snapshots are removed by the retention sweep, by default about 30 days after the session last saved one. To keep them longer, raise
cleanupPeriodDaysin your settings; our Claude Code settings guide shows where.
| Item | Value |
|---|---|
| When a checkpoint is made | Each prompt that starts a turn |
| Snapshots kept | Last 100 checkpoints per session |
| Default retention | About 30 days (cleanupPeriodDays) |
| Commands | /rewind, /undo, Esc Esc |
Undo Claude’s Changes Step by Step
- Make sure the prompt input is empty. If it has text, the first double
Escclears it (pressUplater to recall it). - Press
Esctwice, or type/rewindor/undoand press Enter. In vim mode, pressEsctwice from NORMAL mode. - The rewind menu lists the prompts you sent this session. Use the arrow keys to select the prompt just before the bad change.
- Choose Restore code to undo file edits but keep the chat, or Restore code and conversation to go back completely.
- If you restored the conversation, your original prompt is placed back in the input. Edit it with clearer instructions and send it again.
- Check the files with
git diffbefore you continue.
The two code restore options only appear when the selected checkpoint has tracked file changes to revert. All shortcuts are in our Claude Code commands cheat sheet.
Every Rewind Menu Option
| Option | Files | Conversation | Best for |
|---|---|---|---|
| Restore code and conversation | Reverted | Rewound | Starting again from an earlier point |
| Restore conversation | Kept as they are | Rewound | Re-asking with better wording while keeping good code |
| Restore code | Reverted | Kept | Undoing a bad edit but keeping the discussion |
| Summarize from here | Unchanged | Later messages compressed | Freeing context after a long debugging detour |
| Summarize up to here | Unchanged | Earlier messages compressed | Keeping recent detail, compressing old history |
| Never mind | Unchanged | Unchanged | Backing out of the menu |
Rewound messages can come back if you exit straight away. Claude Code saves the rewound conversation together with your next prompt. Send Claude a prompt before you exit. If the messages return, run /rewind, select the same prompt and choose Restore conversation again. Restored files stay as the rewind left them.
Summarize to Free Context
Summarizing works like a targeted /compact. It does not change files on disk, and the original messages stay in the session transcript, so Claude can still reference details.
- Open the rewind menu and select a prompt.
- Highlight Summarize from here or Summarize up to here with the arrow keys.
- Optionally type focus instructions where the row reads add context (optional), for example “keep the final API design and drop failed attempts”.
- Press Enter. Pressing the option’s number key summarizes immediately without instructions.
A Summarized conversation marker appears where the compressed messages were. Summarize from here puts your original prompt back in the input; Summarize up to here leaves the input empty at the end of the chat. Saving context also saves money, see our guide to reducing Claude Code token usage.
Rewind Past /clear and Resume
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). Select it to go back to the conversation that was active before /clear. It is available until you exit Claude Code or resume another session.
Because checkpoints are stored with the session, you can also resume yesterday’s session with claude --continue or claude --resume and still rewind, as long as the snapshots have not been cleaned up.
What Checkpoints Do Not Cover
Bash command changes
Once Claude has edited a file with its file tools, /rewind also undoes later Bash changes to that file. A file that only Bash commands changed (for example rm, mv, a code generator or npm install touching package-lock.json) is not tracked and stays as it is. Revert those with Git.
Subagent edits
Subagent edits are usually not captured. A foreground forked skill edits during your own turn, so its edits are restored.
Any other subagent, including background forked skills (the default) and a background /code-review --fix run, only has files restored that Claude had already edited in your conversation. More on subagents in our Claude Code subagents guide.
Your own and other sessions’ changes
Restoring code can discard edits you or another session made to a tracked file after the selected checkpoint. Commit or copy the file before restoring. Files Claude never touched are left alone.
Messages sent mid-turn
A message you typed while Claude was working may show No code restore. Select the prompt that started that turn and restore from there instead; it reverts the whole turn’s edits.
Symlinks and hard links
Symlinked and hard-linked files are skipped, with a Restored the code, but skipped N files warning. Dotfile manager links and pnpm hard links are common examples. Run /debug before restoring to log skipped paths to ~/.claude/debug/<session-id>.txt.
Checkpoints vs Git vs /branch
| Tool | Scope | Use it for |
|---|---|---|
| Checkpoints | One session, Claude’s file edits | Fast undo of a bad turn |
| Git | Whole repository, permanent | History, branches, collaboration, Bash changes |
/branch or --fork-session |
A copy of the conversation | Trying another approach while keeping the original session intact |
Anthropic is clear that checkpoints are not a replacement for version control. Use both. If you run Claude in CI or scripts, see our claude -p headless guide.
A Safe Experiment Workflow
- Commit or stash your work so Git has a clean base.
- Ask Claude to try approach A. Review the diff.
- Not happy?
/rewind> select that prompt > Restore code and conversation, then ask for approach B. - Run tests after each attempt. If a script or install changed files, use
git checkoutorgit restorefor those. - When an approach works, commit it. Use Plan Mode first for big changes; see our Plan Mode guide.
Troubleshooting
“No files were restored”
The checkpoint’s snapshots were deleted by the retention sweep. Increase cleanupPeriodDays for the future and use Git to recover now.
Esc Esc does nothing
The prompt input had text, so the first double Esc cleared it. Press it again with an empty input, or type /rewind.
No Restore code option
The selected prompt had no tracked file changes. Pick an earlier prompt where Claude edited files.
A deleted or generated file did not come back
It was changed only by a Bash command. Restore it from Git.
“Restored the code, but skipped N files”
Those paths are symlinks or hard links. Edit them yourself or ask Claude to reverse the change.
Rewound messages reappeared
You exited before sending a new prompt. Rewind again and send a prompt before exiting.
My manual edits were overwritten
Restoring code reverts tracked files to the checkpoint, including your later edits. Commit before restoring next time.
FAQ
How do I undo in Claude Code?
Type /undo or /rewind, or press Esc twice with an empty prompt, then pick a prompt and choose Restore code.
Does Claude Code have a redo?
There is no separate redo command. Use Git to keep versions you might want back, or /branch to explore alternatives.
Do checkpoints work in VS Code and the desktop app?
Checkpoints are part of Claude Code sessions, and the rewind menu is documented for the terminal. The extensions have their own controls; check them before relying on terminal shortcuts.
How many checkpoints are kept?
File snapshots for the 100 most recent checkpoints in each session.
Are checkpoints shared with my team?
No. They are local session data. Share work through Git.
Does rewinding cost tokens?
Restoring does not call the model. Summarizing does, because Claude writes the summary.
Can I rewind after closing the terminal?
Yes. Resume the session and run /rewind, as long as the snapshots are still within the retention period.




