Checkpoints and Session Recovery
Claude automatically checkpoints your code. Restore any previous state without manual git commits. Your safety net when experiments go wrong.
You just asked Claude Code to refactor your entire authentication system. Halfway through, you realize the new approach is worse than what you had. Your stomach drops.
But then you remember: every single change Claude Code made is checkpointed. Roll everything back in seconds. No panicked git stash. No digging through terminal history.
What Checkpoints Actually Track
Every time you send a prompt to Claude Code, it automatically creates a checkpoint. An invisible snapshot of your project at that exact moment. You don't have to ask for it or remember to save. It just happens.
What gets captured: every file edit that Claude Code makes through its own editing tools. Creates, modifies, deletes. All checkpointed.
What does NOT get captured:
- Bash command side effects. If Claude Code runs
rm important-file.tsormv old.ts new.tsthrough a bash command, those changes aren't tracked. The checkpoint system only watches Claude Code's own file editing tools, not arbitrary shell commands. - Your manual edits. Open a file in your editor and change something yourself? Checkpoints won't know.
- External changes. Another terminal session, a teammate pushing code, a build tool generating files. None of that.
This distinction will bite you if you're not aware of it. Checkpoints aren't a full filesystem snapshot. They're a record of what Claude Code's editing tools touched. Nothing more.
How to Restore a Checkpoint
Two ways to trigger a rewind.
Press Esc twice. Becomes muscle memory fast.
Type /rewind. Same result.
Either way, you get a menu with five options:
- Restore code and conversation rolls back both files and conversation history. Claude forgets everything after that point.
- Restore conversation only rewinds the conversation but leaves files alone. For when Claude went down a wrong reasoning path but the code changes are actually fine.
- Restore code only puts your files back but keeps the full conversation. For when you want Claude to remember what failed so it can try something different.
- Summarize from here condenses everything after that point into a summary. Frees context window space.
- Never mind cancels.
In VS Code, hover over any message in the Claude Code panel and you'll see a rewind button. Click it for three options: fork the conversation, rewind the code, or fork and rewind.
Try it now. Open a project with Claude Code. Ask it to rename a variable across multiple files. After it finishes, press Esc twice. Select "Restore code and conversation." Watch all the renames disappear. That's your safety net in action.
Checkpoints and Git: Different Jobs
Checkpoints aren't a replacement for git. Different jobs entirely.
Checkpoints are your "local undo." Fast, automatic, temporary. Use them when experimenting. Tell Claude Code to try a risky refactor. If it works, great. If not, rewind. No commit noise. No branch cleanup. Dead simple.
Git is your "permanent history." Once you're happy with changes, commit them. Checkpoints don't push to a remote. They don't create shared history.
A solid workflow that combines both:
# 1. Start from a clean git state
git status # make sure working tree is clean
# 2. Ask Claude Code to try something experimental
# (checkpoints are created automatically with each prompt)
# 3. If the experiment fails, press Esc+Esc to rewind
# 4. If the experiment works, commit it
git add -A
git commit -m "refactor: simplify auth middleware"Checkpoint persistence is real. They survive across sessions. Close the terminal, shut down your computer, come back tomorrow. As long as you resume the same conversation, your checkpoints are still there. They auto-clean after 30 days by default.
A few more things worth knowing:
- Use checkpoints for bold experiments. Tell Claude to try the weird approach. You're two key presses away from undoing it all. That freedom changes how you work.
- Commit before long experimental chains. About to ask Claude to make a series of risky changes? Git commit first. Checkpoint safety net AND git safety net.
- Don't rely on checkpoints for bash-heavy workflows. If Claude is mostly running shell commands (installing packages, running migrations, moving files around), checkpoints won't capture those side effects. Git is your protection there.
- Rewind isn't just for mistakes. Try approach A, evaluate it, rewind, try approach B. Compare by going back and forth.
Key Takeaways
- Every prompt creates an automatic checkpoint. No manual action needed.
- Checkpoints only track edits made by Claude Code's own tools. Bash side effects, manual edits, and external changes are invisible.
- Press
Esctwice or type/rewind. Five options in the menu. - They persist across sessions and auto-clean after 30 days.
- Checkpoints for local undo, git for permanent history. Use both together.
Mastering Claude Code
Lesson 19 of 70