Checkpointing
Claude Code automatically tracks file changes while you work. It is a safety net that lets you return to a previous state anytime the code changes in ways you didn't intend.
How It Worksโ
A checkpoint is created automatically every time Claude Code modifies files.
Prompt 1: "Build the login API"
โ Checkpoint A created โ code modified
Prompt 2: "Add error handling"
โ Checkpoint B created โ code modified
Prompt 3: "Write tests"
โ Checkpoint C created โ code modified
โ Esc+Esc can roll back to point B
Key characteristics:
- Auto-created: a checkpoint is made for each user prompt
- Persists across sessions: checkpoints remain accessible when a session is resumed with
/resume - Auto-cleanup: deleted along with the session after 30 days (configurable)
Rewindโ
How to Accessโ
Esc + Esc # Keyboard shortcut (fastest)
/rewind # Slash command
A scrollable menu appears where you can select any prompt point in the session.
Even if you cleared the conversation with /clear, /rewind can restore the conversation from before the /clear (v2.1.191+).
Restore Optionsโ
Selecting a point presents five options:
| Option | Reverts code | Reverts conversation | Purpose |
|---|---|---|---|
| Restore code + conversation | O | O | Fully return to that point |
| Restore conversation only | X | O | Keep the code, rewind only the conversation |
| Restore code only | O | X | Keep the conversation, rewind only the code |
| Summarize from here | X | Summarized | Compress the conversation after this point |
| Cancel | X | X | Return to the menu |
When you restore the conversation, the original prompt from that point is automatically restored into the input box. You can edit it and resend, or run it as-is.
"Summarize from here" vs. Restoreโ
Restore rolls back state โ the code, the conversation history, or both, to an earlier point.
Summarize from here behaves differently:
- Messages before the selected point are kept intact
- Messages after the selected point are replaced with an AI summary
- Files on disk are not changed
- The original messages are preserved in the session transcript
Think of it as a targeted version of /compact. Instead of compressing the whole conversation, it keeps your early context intact and selectively compresses only the space-hungry parts.
/compact โ compresses the whole conversation
Esc+Esc โ "Summarize from here" โ compresses only what comes after the selected point
Practical Scenariosโ
Experimenting with a Different Approachโ
> Implement OAuth login with passport.js
... not happy with the result ...
Esc + Esc โ roll back to the earlier point
> Implement OAuth login from scratch (without passport.js)
Recovering from a Mistakeโ
> Refactor this entire module
... the refactoring breaks the existing tests ...
Esc + Esc โ "Restore code + conversation" โ back to before the refactoring
> Refactor only within the bounds of not breaking the tests
Cleaning Up a Debugging Sessionโ
> Fix the payment failure bug
... 30 minutes of debugging, lots of trial and error ...
Esc + Esc โ "Summarize from here" at the point debugging started
โ the trial-and-error is compressed into a summary, freeing up context
Iterating on a Featureโ
> Build search feature v1 โ Checkpoint A
> Add filtering โ Checkpoint B
> Add autocomplete โ Checkpoint C (bug appears)
Esc + Esc โ "Restore code only" at point B
โ conversation history kept, but the code returns to state B
> Implement autocomplete a different way
Limitationsโ
Changes Made via Bash Commands Are Not Trackedโ
Checkpoints only track changes made through Claude's file editing tools. File operations performed by Bash commands cannot be rolled back:
# These changes cannot be reverted by checkpoints
rm file.txt
mv old.txt new.txt
cp source.txt dest.txt
External Changes Are Not Trackedโ
Only files edited by Claude within the current session are tracked. Edits made directly in another editor, or changes from another Claude Code session, are not included.
Not a Replacement for Gitโ
Checkpoints are for quick, session-level rollback. Use Git for permanent version control.
| Checkpoints | Git | |
|---|---|---|
| Purpose | Quick rollback within a session | Permanent version history |
| Scope | Current session | Full project history |
| Retention | 30 days | Permanent |
| Analogy | "Local undo" | "Permanent history" |
Independent of checkpoints, keep the habit of taking a snapshot with git commit before starting large tasks. It lets you safely recover even from Bash-command changes that checkpoints cannot cover.