Guides
Claude Code /rewind and Checkpoints: Undo Any AI Mistake (Esc Esc)
Published:
When an AI coding step goes wrong, you want one thing: a fast way back. Claude Code gives you exactly that. Press Esc twice (or type /rewind) to roll your code and the conversation back to an earlier checkpoint. Claude Code saves one automatically before each edit. It’s the safety net that makes experimenting fearless. There’s one important limit to understand, and we’ll get to it, but first let’s see how it works.
What a checkpoint is
As you work, Claude Code quietly takes a snapshot, a checkpoint, before each change it makes to your files. You don’t have to set these up; they happen on their own. Each checkpoint is a point you can return to, capturing both the state of your code and where the conversation was. Think of it as an automatic, frequent “save game” for your session.
How to rewind
Two ways to open the rewind menu:
- Press Esc twice in quick succession, or
- Type
/rewind.
You’ll see a list of checkpoints to jump back to, and (this is the useful part) a choice of what to restore:
- Code only: revert the files to that point, but keep the conversation. Good when one edit went wrong but the discussion is still on track.
- Conversation only: rewind the chat so Claude forgets the last few steps, while leaving your files as they are.
- Both: reset everything to that checkpoint and take a different path.
That flexibility is what makes rewind feel surgical rather than blunt. You can undo a single bad edit without throwing away the good thinking that came before it.
The one limit that trips people up
Here’s the honest caveat, and it’s the most important sentence in this article: rewind only undoes edits Claude Code made to files itself. It does not undo:
- Changes made by shell commands Claude ran (a script that deleted or moved files, a database migration, an install step).
- Anything changed outside Claude Code: by you, by another tool, by your editor.
So if Claude runs a command that reshapes your project and you rewind, the file edits come back but the command’s effects don’t. This is why checkpoints are best understood as a quick local undo, not a complete time machine.
Use checkpoints and git together
The takeaway isn’t “don’t trust rewind.” It’s “pair it with git.” The two tools cover different ground:
- Checkpoints /
/rewind: instant, automatic, session-only undo of Claude’s edits. Perfect for “oops, go back one step” while you work. - Git commits: permanent, reliable save points that capture everything, including command effects, and survive after the session ends.
The fearless workflow uses both: commit to git before a risky prompt, lean on Esc-Esc for quick undos as you go, and commit again when you’re happy. Checkpoints are the quick-undo button; git is the seatbelt. With both in place, you can let an AI agent take big swings at your code knowing you can always get back.
A calm way to experiment
The real value of rewind is psychological. Once you know any step can be undone in two keystrokes, you stop being precious about each prompt. You try the bolder refactor, the riskier approach, the “just see what happens,” because the cost of a wrong turn is one Esc-Esc away. That’s when AI coding gets genuinely fun, and genuinely productive: you explore freely, review the diff of what changed, and keep only what’s good.
Get your setup right from the start
If you’re still getting Claude Code configured, our free AI for Coders tool gives you the right assistant for your work, the exact install command for your operating system, and a starter rules file so the AI behaves the way you want. Add the rewind reflex and a commit-before-you-prompt habit on top, and you’ll have a setup where mistakes are cheap and easy to undo.
Keep reading
Frequent questions
How do I undo changes in Claude Code? +
Press Esc twice to open the rewind menu, or type /rewind. You'll be offered choices: restore just the code, just the conversation, or both, back to an earlier checkpoint. Claude Code automatically saves a checkpoint before each edit, so you can step back to any point in the session.
What's the difference between restoring code and restoring the conversation? +
Restoring the code reverts the files on disk to how they were at that checkpoint. Restoring the conversation rewinds the chat so Claude 'forgets' the steps after that point. You can do either or both. For example, keep the discussion but undo a bad edit, or reset everything and try a different approach.
Do checkpoints replace git? +
No. Checkpoints are a fast, local, session-only undo for Claude's own file edits. They do not track changes made by commands run in the terminal or by other programs, and they don't give you permanent history. Git commits are still your reliable, lasting save points, so use checkpoints for quick undo and git for real safety.
Why isn't /rewind undoing everything? +
Rewind only reverts edits Claude Code made itself. If a change came from a shell command Claude ran (like a script that moved files), or from something outside Claude, rewind won't undo it. That's the main limitation to remember, and the reason to commit to git before risky steps.