Claude Code checkpoint guide
Use /rewind to edit your last message in Claude Code
To edit your last message in Claude Code, press Esc twice at an empty prompt or run /rewind (also /undo). Select the prompt that started the turn. Restore conversation returns it to the input box. Edit and resend it with your files as they are. To undo only the tracked file edits and keep the conversation, choose Restore code.
Last updated · Published
By CWYN · Published · Checked against docs, not run · Anthropic’s checkpointing guide, command reference and interactive keyboard shortcuts (as of )
1. Edit the last message or restore its file changes
Every prompt that starts a turn creates a checkpoint automatically. Select a prompt in the rewind menu to see its actions. The two actions that restore code appear only when that checkpoint has tracked file changes to undo.
| Menu action | What changes | When to pick it |
|---|---|---|
| Restore code and conversation | Tracked files and the conversation return to the checkpoint. | You want to retry a change with both the files and the discussion back where you started. |
| Restore conversation | The conversation rewinds. Current files stay on disk. | The edit worked, but you want to ask a different follow-up. |
| Restore code | Tracked file edits are undone. The conversation stays. | You want the old code and still need Claude’s explanation of what went wrong. |
| Summarize from here | Context only. The selected point and what follows become a summary. | Keep the original requirements in full and shorten the debugging discussion that followed. |
| Summarize up to here | Context only. Earlier messages become a summary and later messages stay in full. | Shorten the initial investigation and keep the recent test failure in context word for word. |
Choose Never mind to close the menu. After Restore conversation or Summarize from here, the selected prompt returns to the input so you can edit and resend it. If you want another model to try the same task, switch models before opening the rewind menu.
2. Undo the last change or several turns
Undo the last change
- Open the menu with
/rewind. Both/undoand/checkpointopen the same menu. - Select the prompt that asked Claude to make the change. Its checkpoint holds the code state from before Claude acted.
- Choose Restore code. Review the restored file. The messages about the edit are still there if you want to ask Claude to try again.
If pressing Esc twice clears a draft, press Up to recall it from input history. The shortcut opens rewind when the input is empty. In vim mode, press Esc twice from NORMAL mode.
Undo several turns at once
- Open the menu and select the first prompt whose changes you want to undo. For example, if “Rename the parser” was followed by “Update its callers,” select “Rename the parser” to undo both. Select “Update its callers” to keep the rename.
- Choose Restore code to keep the discussion, or Restore code and conversation to retry from the earlier files and messages.
- If you rewound the conversation, send your next prompt before exiting. Claude Code saves the rewound conversation with that prompt.
3. Get a conversation back after /clear
- In the same Claude Code process where you ran
/clear, open/rewind. - Select
/resume (previous session)at the top of the menu to return to the conversation from before the clear.
That shortcut lasts until you exit or resume another session. After that, use the local session picker to resume the conversation.
4. Free context with a partial summary
- Open
/rewindand pick the prompt that divides the discussion you need in full from the part you can shorten. - Choose Summarize from here to shorten the discussion from that point forward, or Summarize up to here to shorten what came before it.
Both summaries leave files on disk as they are. For a summary of the whole conversation, see when to use /compact or /clear.
5. Rewind didn’t restore my file
| Symptom | Likely cause | What to do |
|---|---|---|
No files were restored | The prompt can still be in the conversation after its file snapshots expire. | Choose a more recent checkpoint with snapshots, or recover the version saved in Git. Increase cleanupPeriodDays to keep future snapshots longer. |
No code restore | A message typed mid-turn did not start a checkpoint. | Select the prompt that started the turn. Look for Restore code there if Claude made tracked edits. |
| A shell edit remains | Claude changed that file only through Bash commands. | Recover a saved version from Git. If Claude used its edit tools on the file first, rewinding that tracked edit also undoes later Bash changes to the same file. |
| A subagent’s edit remains | Rewind usually skips subagent edits. A foreground forked skill with context: fork is the exception. | Check which agent made the edit. Use a saved Git version for changes the parent session did not track. |
| An editor change or another session’s edit remains | Manual edits outside Claude Code and changes from concurrent sessions are normally outside this session’s checkpoints. | For a Claude edit, check the session that made it. For an outside edit, recover a version you saved in Git. |
Restored the code, but skipped N files | Claude Code skips symlinked and hard-linked files during restore. | Run /debug before restoring to log the skipped paths. Use the paths to identify which files still need recovery. |
| Rewound messages came back after exit | You exited before sending another prompt, so the rewound conversation had not been saved. | Rewind again, then send your next prompt before you exit. |
Checkpoint retention and restore limitations (as of ).
6. When to use rewind, Git or /branch
- Rewind when you can identify the prompt that led to an unwanted edit. You can restore the tracked files and keep the conversation for another attempt.
- Git when you need a file version you can return to after session snapshots expire. Commit the versions you want to keep, including changes made by Bash, subagents or your editor.
- Branch when you want to try a different conversation and keep the original session intact. Run
/branchin the session, or start a fork from the terminal withclaude --continue --fork-session.
If you are undoing a project setup change, use the rollback checklist in the Claude Code Complete Setup Pack to review the setup files after restoring them.
7. Claude Code checkpoint FAQ
Does rewind undo Bash commands?
Rewind restores tracked file contents. A file changed only by Bash stays as it is. If Claude first edited the file with its edit tools, restoring that earlier snapshot also removes later Bash edits to that file.
How far back can I rewind?
Claude Code keeps file snapshots for the 100 most recent checkpoints in a session. By default, the retention sweep deletes the session’s snapshots about 30 days after the session last saved one. To keep snapshots longer, choose the settings file for your project or user account and set cleanupPeriodDays there.
Does rewind work after --resume?
Yes. Checkpoints are saved with the conversation. After you resume the session, open /rewind as usual. Restoring code still requires the file snapshots for the checkpoint you select.
Can I undo a rewind?
/undo opens the checkpoint picker again. It has no separate redo action. Look for an available checkpoint with the file version you want, or recover a copy you saved in Git. To keep the original conversation, use /branch before rewinding.