The short answer
Claude Code saves a checkpoint of your code before each prompt you send, and /rewind (or pressing Esc twice on an empty prompt) can restore your files, your conversation, or both, to that point.1 It undoes changes made by Claude’s own file editing tools. It does not undo a file that only Bash commands changed, most edits made by subagents, files outside the session, or symlinked and hard-linked files.1 It never touches a database, a remote API or a pushed branch. Anthropic’s docs say it plainly: checkpoints are for quick, session-level recovery and are not a replacement for version control.1
So treat /rewind as a fast undo for edits, and keep Git and your database’s own recovery tools for everything else.
Deedglass
A tool call meets your rules before it runs
Asks to run
DELETE FROM visits;
Deletes every row in visits
Deedglass checks your rules
- Reading dataAllowed
- Deleting a whole table (DROP, TRUNCATE)Never
- Changing or deleting rows without saying which (WHERE)This one
- Other changesWait for a person
How checkpoints are made
The rules, from Claude Code’s checkpointing docs:1
| Rule | What it means for you |
|---|---|
| Every prompt that starts a turn creates a checkpoint | The undo points are your prompts, not individual edits |
| Snapshots are kept for the 100 most recent checkpoints in a session | Very long sessions lose their oldest undo points |
| Checkpoints are saved with the conversation | /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 | Old sessions may fail to restore, with No files were restored |
cleanupPeriodDays changes the retention |
Raise it if you rely on old sessions |
The unit matters. If one prompt led Claude to edit twelve files, the checkpoint before that prompt is the only way back for those twelve files through /rewind. You can’t pick out one edit in the middle of a turn. A message you type while Claude is still working can show as No code restore, because it has no checkpoint of its own; to undo edits after it, pick the prompt that started the turn, which reverts the whole turn.1
The rewind menu
Open it with /rewind, or with Esc twice when the prompt box is empty. If the box has text, double Esc clears the text instead.1 Pick a prompt, then an action:
| Action | Files | Conversation |
|---|---|---|
| Restore code and conversation | Back to that point | Back to that point |
| Restore conversation | Unchanged | Back to that point |
| Restore code | Back to that point | Unchanged |
| Summarize from here | Unchanged | Compressed from that point on |
| Summarize up to here | Unchanged | Compressed before that point |
The two code options appear only when the selected checkpoint has tracked file changes to revert.1 That detail is the most useful signal in the menu: if Restore code is missing, Claude Code has nothing to put back for that turn, even if something on disk changed.
Restore code is often the right choice when the plan was fine and the edits were wrong: you keep the conversation, so Claude still knows what it tried, and you can ask for a different approach. Restore conversation without code is for the opposite case, when you like the files but want to take back a misleading exchange.
What rewind leaves behind
This is where the menu can mislead. The docs list five gaps.1
1. Files only Bash touched. If Claude creates, edits, moves or deletes a file with a shell command, and has never edited that file with its file tools in the conversation, the file isn’t tracked and stays as it is. There is one twist: once Claude has edited a file with its file tools, later Bash changes to that same file are undone by /rewind. So sed -i on a file Claude already edited comes back; rm -rf build/ on files it never edited does not.
2. Subagent edits. Subagents edit with Claude’s file tools, but their edits usually aren’t captured in your session’s checkpoints. The exception is a forked skill running in the foreground. Any other subagent, including a background forked skill, leaves its edits to other files in place after a rewind.
3. External changes. Your own edits outside Claude Code and edits from other concurrent sessions are normally not captured, unless they touch files the current session also edited.
4. Symlinks and hard links. Restore skips any tracked path that is a symlink or hard link and warns Restored the code, but skipped N files. Dotfiles a dotfile manager links into your project, and files pnpm hard-links into place, fall in this category.
5. Everything that isn’t a local file. The docs describe tracking files. A migration Claude ran, rows it deleted, a message it sent through an MCP tool, a git push or a cloud resource it created are outside the checkpoint entirely. Rewinding the conversation after a DROP TABLE only makes Claude forget it ran it.
Put together:
| What the agent did | Does /rewind undo it? |
|---|---|
Edited app.ts with its edit tool |
Yes |
Ran sed -i on app.ts after editing it |
Yes |
Ran rm -rf dist/ on files it never edited |
No1 |
A background subagent rewrote utils.ts |
No, unless the main session also edited it1 |
Edited a symlinked .env |
No, skipped with a warning1 |
| Ran a migration on Postgres | No |
| Pushed a branch or posted to Slack | No |
When rewind itself misbehaves
Public bug reports show the feature has had rough edges. Issue #14002, opened in December 2025 and still open when we checked, reports the Restore code option sometimes missing, only some modified files being restored, and debug logs showing zero files tracked at snapshot creation.2 Issue #34368, opened in March 2026 and since closed, reports the rewind option appearing on a turn where Claude deleted a file, and the rewind not bringing the file back.3
These are user reports against particular versions, not a statement about the current release. They are a reason to test the undo you rely on, the same way you’d test a backup, before the day you need it. The docs also give a debug path: turn on /debug before a restore and the debug log names each skipped path.1
A recovery plan that covers the gaps
Use each tool for what it covers.
- Commit before you hand over. A clean
git statusbefore a long agent task makesgit diffandgit restoreyour real undo for code, including files Bash or a subagent changed. - Use
/rewindfor fast edit undo. It’s quicker than Git for “that last turn went wrong”, and it keeps or resets the conversation as you choose. - Keep the agent away from things checkpoints can’t restore. Deny rules and hooks are the way to stop
rm -rf,git push --forceor database commands from running unasked. Our posts on deny, ask and allow rules and on a hook that blocks database commands cover both, including where they fall short. - Have a real undo for data. For Postgres, the change stream already holds the before and after of every row an agent changed, which is a far smaller restore than a backup. See undo for agent sessions.
- Mind retention. If you return to sessions after weeks, raise
cleanupPeriodDays.1 - Check for symlinks. If your repo links config files in from elsewhere, those edits won’t be restored.1
Cursor’s checkpoints have similar limits, covered in our Cursor checkpoints post.
Questions people ask
Does /rewind undo files Claude deleted with rm?
Only if Claude had already edited those files with its file editing tools in the conversation. A file that only Bash commands changed isn’t tracked.1 Use Git for those.
Can I rewind after closing Claude Code?
Yes. Checkpoints are saved with the conversation, so /rewind works after you resume, until the retention sweep removes the snapshots, by default about 30 days later.1
Is Esc Esc the same as /rewind?
Yes, when the prompt box is empty. With text in the box, double Esc clears it and saves it to your input history.1
Does rewind undo database changes?
No. Checkpoints track local files. A database needs its own recovery: point-in-time restore, branching, or replaying the before-images of the changed rows.
To see what an agent’s tools can reach on your own machine, including Claude Code’s settings and MCP servers, run npx deedglass scan (the grade, explained). To try approvals and undo on a real database in your browser, open the playground.
Written with AI assistance and checked against our claims register.