Claude Code has built-in checkpointing: it automatically captures the state of your code before Claude's edits, so you can rewind to a previous state if a task goes off track. You open this with the built-in /rewind command, or by pressing Esc twice while the prompt input is empty.
This is a built-in Claude Code feature, not a separate plugin. Checkpointing is automatic, and you interact with it entirely through the /rewind menu (or by pressing Esc twice).
How checkpoints work
- Automatic capture: every prompt you send creates a new checkpoint of your code before Claude's file edits.
- Persists across sessions: checkpoints are available again in resumed conversations, not just the current run.
- Automatic cleanup: checkpoints are cleaned up along with their sessions after 30 days by default. This retention is governed by the standard session
cleanupPeriodDays setting, not a separate checkpoint config file.
Checkpoints are created automatically as you work — checkpointing is tied to your prompts rather than to a manual create step or a configurable interval.
Opening the rewind menu
/rewind
Or, with an empty prompt input, press Esc twice.
If the prompt input contains text, pressing Esc twice clears the text instead of opening the menu. The cleared text is saved to your input history, so press Up to recall it after you finish in the rewind menu.
The menu lists each prompt you sent during the session. Select a point, then choose an action.
Rewind menu actions
For the selected message you can choose:
- Restore code and conversation — revert both code and conversation to that point.
- Restore conversation — rewind to that message while keeping current code.
- Restore code — revert file changes while keeping the conversation.
- Summarize from here — replace the selected message and everything after it with an AI-generated summary (keeps earlier context in full detail).
- Summarize up to here — replace the messages before the selected message with a summary, keeping the selected message and later ones intact.
- Never mind — return to the message list without changes.
After restoring the conversation or choosing Summarize from here, the original prompt from the selected message is restored into the input field so you can re-send or edit it.
Restore vs. summarize
The restore options change state on disk and in history: they undo code changes, conversation history, or both.
The summarize options do not change files on disk — they compress one side of the conversation into a summary to free up context window space. The original messages are preserved in the session transcript, so Claude can still reference them. You can type optional instructions to guide what the summary focuses on. This is like /compact, but targeted to one side of the selected message rather than the whole conversation.
If you instead want to branch off and try a different approach while keeping the original session intact, use session forking (claude --continue --fork-session) rather than rewind.
When to use it
- Exploring alternatives: try a different implementation approach without losing your starting point, then restore code if it doesn't pan out.
- Recovering from mistakes: a refactor introduced a bug across several files — open
/rewind, pick the prompt before the refactor, and choose Restore code.
- Iterating on a feature: experiment with variations knowing you can revert to a working state.
- Freeing context space: in a long debugging session, use Summarize from here to compress a verbose side-discussion while keeping your initial instructions in full detail.
Example: undo a bad refactor, keep the discussion
You: Refactor the payment service to use async/await
Claude: (edits several files)
You: The payment flow is broken now.
You: /rewind
-> select the prompt before the refactor
-> choose "Restore code"
Your files revert to the pre-refactor state while the conversation (including what went wrong) stays intact, so Claude can try a different approach with that context.
Limitations
Checkpointing is a session-level safety net, not full version control. Be aware of what it does not track:
- Bash command changes are not tracked. Files modified by shell commands Claude runs (for example
rm file.txt, mv old.txt new.txt, cp source.txt dest.txt) cannot be undone through rewind. Only direct edits made through Claude's file-editing tools are tracked.
- External changes are not tracked. Manual edits you make outside Claude Code, and edits from other concurrent sessions, are normally not captured — unless they happen to touch the same files as the current session.
- It is not a replacement for Git. Keep using version control for commits, branches, and long-term history. Think of checkpoints as "local undo" and Git as "permanent history."
See also