Claude Code automatically snapshots your code before every edit. Each time you send a prompt, a checkpoint is created. If Claude takes a wrong turn — breaks a feature, goes down the wrong path, or over-engineers a solution — you can rewind to any previous state in seconds. Checkpoints persist across sessions and are cleaned up automatically after 30 days.
Result:
> Esc Esc (press Escape twice)
┌─ Rewind to ──────────────────────────┐
│ ● Message 5: "Add auth middleware" │
│ ○ Message 4: "Create user model" │
│ ○ Message 3: "Set up database" │
│ │
│ Restore: ◉ Both ○ Code ○ Convo │
└──────────────────────────────────────┘
Setup
No setup needed. Checkpointing is enabled by default.
1. Make some changes with Claude
Work normally — every prompt you send creates a checkpoint automatically.
2. Rewind when needed
Press Esc twice with the input empty, or type /rewind:
Esc + Esc → Opens the rewind menu (only when you haven't typed anything)
/rewind → Same thing, via command
If you had text half-written, double Esc clears it instead of opening the menu. You don't lose it: it goes to your input history, so Up brings it back once you're out of the menu.
3. Choose what to do with that point
| Option | What it does |
|---|---|
| Restore code and conversation | Reverts files and rewinds the chat to that point |
| Restore conversation | Rewinds the chat and leaves files as they are now |
| Restore code | Reverts file changes and keeps the conversation |
| Summarize from here | Compresses the conversation from that point forward, freeing context |
| Summarize up to here | Compresses everything before that point, leaving recent messages intact |
| Never mind | Back to the list without touching anything |
The two code options only show up when that checkpoint has tracked file changes to revert. If no edits were captured, the menu offers restoring the conversation, the summarize options, and leaving.
And if you ran /clear earlier in the same process, an extra entry sits at the top of the list to resume the conversation from before that /clear (since v2.1.191).
Reference
| Feature | Details |
|---|---|
| Trigger | Esc • Esc with an empty input, or /rewind |
| Checkpoint creation | Automatic on every user prompt |
| Snapshots kept | The 100 most recent checkpoints in the session |
| Persistence | Survives session restarts and /resume |
| Retention | 30 days, in plain text on your disk (configurable via cleanupPeriodDays) |
| Tracks | File edits made through Claude's editing tools |
| Does NOT track | Bash commands (rm, mv, cp), external edits |
Limitations
- Files modified by bash commands (e.g.,
rm file.txt) are not tracked - Manual edits you make outside Claude Code are not captured
- What a subagent edits usually isn't restored by a rewind. The exception is a skill with
context: forkrunning in the foreground, which edits during your own turn. Everything else, including any background subagent, is a job for git rather than rewind. Where a subagent runs changes more than you'd think: it also trims its tools - Symlinked and hard-linked paths are not rewound. Restoring code prints
Restored the code, but skipped N filesand those files keep their current contents - Checkpoints are session-level recovery, not a replacement for Git
Official docs: Checkpointing
EscEscrewinds, but a singleEscis a different move: stop and redirect Claude mid-task without losing what it's done.
The same Rewind menu can also compress context without undoing anything: free up context without losing recent work with Summarize up to here.