Last updated: November 24, 2026
TL;DR
Claude Code saves a checkpoint of your code before every prompt that starts a turn. To go back, run /rewind (or its alias /undo), or press Esc twice with the prompt empty, pick the prompt you want to return to, and choose to restore the code, the conversation or both. Checkpoints cover edits made by Claude's file editing tools. They don't cover a file only a shell command changed, edits you make outside Claude Code, or most subagent edits, so keep committing with Git. Everything below comes from Anthropic's checkpointing docs.
Open the rewind menu
Two ways in:
- Run
/rewind, or/undo, which does the same. - Press
Esctwice when the prompt input is empty. If the prompt has text in it, the first doubleEscclears it instead; the text goes to your input history, soUpbrings it back. In vim mode, pressEsctwice from NORMAL mode.
The menu lists the prompts you sent in the session. Select the one you want to act on.
Choose what to restore
| Option | What happens |
|---|---|
| Restore code and conversation | Both go back to that point |
| Restore conversation | The conversation goes back; your current code stays |
| Restore code | File changes are reverted; the conversation stays |
| Summarize from here | Everything after that point is compressed into a summary |
| Summarize up to here | Everything before that point is compressed; later messages stay |
| Never mind | Back to the list, nothing changed |
The two code options appear only when that checkpoint has tracked file changes to revert. After you restore the conversation, or summarize from here, the prompt you picked comes back into the input so you can edit it and send it again.
Rewind the conversation without the code when Claude went the wrong way but the files are fine. Rewind the code without the conversation when you want to keep what you both learned and try the change again.
Summarize instead of compacting everything
The two summarize options work like a targeted /compact: they free context without touching files on disk, and the original messages stay in the session transcript. To steer the summary, highlight a summarize option with the arrow keys and type instructions where the row reads add context (optional), then press Enter. Our /compact guide covers when to compact the whole session instead.
To try a different approach while keeping the original session as it is, branch it with /branch rather than rewinding.
What rewind can't undo
- ๐ Files only a shell command changed. Once Claude has edited a file with its file tools, rewind also undoes later shell changes to that file. A file that only shell commands touched isn't tracked.
- โ๏ธ Changes made outside the session. Your own edits in an editor and edits from other sessions running at the same time aren't captured, unless they touch files this session edited.
- ๐ค Most subagent edits. Rewind restores only files Claude had already edited in your conversation. A subagent's edits to other files stay, background forked skills included. A forked skill running in the foreground is the exception. Our subagents guide covers how they run.
- ๐ Symlinked and hard-linked files. A restore skips them and warns that it skipped files; they keep their current contents.
- โณ Old checkpoints. A session keeps file snapshots for its 100 most recent checkpoints, and snapshots are cleaned up by default about 30 days after the session last saved one. Rewinding to a checkpoint whose snapshots are gone can fail with "No files were restored". The
cleanupPeriodDayssetting keeps them longer.
Rewind is not version control
Checkpoints are for quick recovery inside a session; Anthropic's docs say to keep using Git for commits, branches and long-term history. Commit before a large change so you can always get back, whatever made the edits. Our beginner's guide to GitHub source control covers the basics.
Two details save confusion later. Checkpoints are saved with the conversation, so /rewind still works after you resume a session. And if you rewind and then exit before sending another prompt, the rewound messages can come back: send a prompt before you exit so the rewound conversation is saved.
Frequently asked questions
How do I undo changes in Claude Code?
Run /rewind, or its alias /undo, or press Esc twice with an empty prompt. Pick the prompt you want to return to and choose Restore code, Restore conversation, or both.
Does Claude Code rewind undo shell commands?
Only for files Claude had already edited with its file editing tools. A file that only shell commands changed isn't tracked, so revert it with Git.
Can I rewind after resuming a Claude Code session?
Yes. Checkpoints are saved with the conversation, so /rewind works after you resume. Snapshots are cleaned up by default about 30 days after the session last saved one.
Does rewinding restore subagent edits?
Usually not. Rewind restores files Claude had already edited in your conversation; a subagent's edits to other files stay. A forked skill that runs in the foreground is the exception.
Are checkpoints a replacement for Git?
No. Checkpoints are for quick recovery within a session. Keep using Git for commits, branches and history.
Next: the commands around it
Rewind is one of a handful of commands that cover a working day. Our Claude Code CLI guide lists the rest, from starting and resuming a session to switching permission modes.
Stop guessing. Score your first workflow.
Score one workflow in about five minutes. Nine questions, a grade, and the specific gap holding it back - no call required.
Related Posts

Claude Code slash commands: the built-ins worth knowing, and how to make your own
Which Claude Code slash commands to learn first, grouped by the moment you need them, the aliases and removed commands that trip up old habits, and how to make your own command with a skill in .claude/skills.

Claude Code statusline: show the model, context and cost at a glance
The Claude Code statusline runs a script you choose and shows what it prints. Set it up with /statusline or by hand, choose which session fields to show, keep it fast, and fix it when it goes blank.

Claude Code Code Mode: what it changes and when to turn it on
Code Mode is an experimental Claude Code feature in which Claude writes JavaScript that makes several tool calls in one step. What it changes, the tasks it helps with, the limits to accept first, and how permissions apply to the code.
