Skip to content
Skuto

Guides

Claude Code /rewind and Checkpoints: Undo Any AI Mistake (Esc Esc)

Published: · Updated:

When an AI coding step goes wrong, you want one thing: a fast way back. Claude Code gives you exactly that. Type /rewind, or press Esc twice on an empty prompt, to roll your code and the conversation back to an earlier checkpoint. Claude Code saves one automatically every time you send a prompt. It’s the safety net that makes experimenting fearless. There are four kinds of change it won’t undo, and we’ll get to them, but first let’s see how it works.

What a checkpoint is

As you work, Claude Code quietly takes a snapshot, a checkpoint, of the state of your code before each prompt you send. Every prompt that starts a turn creates a new checkpoint. (A message you type while Claude is still working, and that joins the running turn, doesn’t get one of its own; to undo it, rewind to the prompt that started the turn.) 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 “save game” taken every time you hit enter.

Two practical details. Claude Code keeps the file snapshots for the 100 most recent checkpoints in a session, so on a long session the oldest ones drop off. And the snapshots are stored with the conversation, which means /rewind still works after you resume a session. A cleanup sweep deletes a session’s snapshots about 30 days after the session last saved one, a window you can change with the cleanupPeriodDays setting. Rewind to a checkpoint whose snapshots are already gone and you’ll see No files were restored.

How to rewind

Two ways to open the rewind menu:

  • Type /rewind, or
  • Press Esc twice while the prompt input is empty.

That second word matters more than it looks. If there’s text sitting in the input, double Esc clears the text instead of opening the menu, which is a good way to conclude the shortcut is broken when it’s working exactly as designed. Press Esc twice again on the now-empty input and the menu appears. Nothing is lost in the meantime: the docs say the cleared text goes into your input history, so press Up to bring it back once you’re done.

You’ll see a list of checkpoints to jump back to, and (this is the useful part) a choice of what to do with the one you pick:

  • Restore code and conversation: revert both to that point and take a different path.
  • Restore conversation: rewind to that message while keeping the code you have now.
  • Restore code: revert the file changes while keeping the conversation. Good when one edit went wrong but the discussion is still on track.
  • Summarize from here: compress the conversation from that point forward into a summary, freeing up context window space.
  • Summarize up to here: compress the conversation before that point into a summary, keeping the later messages as they are.
  • Never mind: go back to the list of checkpoints without changing anything.

The two code options only show up when the checkpoint you selected has tracked file changes. 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.

Two smaller details make the menu less frightening to open. The summarize options don’t touch your files, and the original messages stay in the session transcript, so Claude can still refer to the detail; you’re compressing the context, not deleting the history. And after a conversation restore, or after Summarize from here, the prompt from the message you picked is dropped back into the input for you, so you can edit it and try again rather than retyping it from memory.

Summarizing is also the wrong tool if what you actually want is a second attempt kept side by side with the first. For that, /branch (or claude --continue --fork-session) splits off a new line of work and leaves the original session untouched.

If you already ran /clear

This one catches people out and looks unrecoverable. Clearing the conversation seems to take the checkpoints with it, so the instinct is to give up and reach for git. You don’t have to. As long as you’re still in the same Claude Code process, the rewind menu carries an extra entry at the very top labelled /resume <session-id> (previous session), and picking it brings back the conversation that was live before /clear. It stays there until you exit or resume a different session, and it needs Claude Code v2.1.191 or newer. On an older version, run /resume and choose the previous session from the list.

The limits that trip people up

Here’s the honest caveat: rewind only covers the file edits Claude made with its own editing tools, in your own session. Four kinds of change survive a rewind:

  • Shell commands Claude ran. A script that deleted or moved files, a database migration, an install step. Only direct file edits made through Claude’s file editing tools are tracked.
  • Anything changed outside Claude Code: by you, by another tool, by your editor, or by a second Claude Code session running at the same time. The docs say these are normally not captured, unless they happen to touch the same files as your session.
  • Edits made by a subagent. A subagent uses the same file editing tools, but Claude Code usually doesn’t capture those edits in your session’s checkpoints. The line is where it runs: a skill forked in the foreground edits your working tree during your own turn, so rewind restores it as normal. Anything else is out of reach and git is your only way back, and the docs name two cases people run into without thinking of them as subagents at all: a forked skill running in the background, which is the default, and a background /code-review --fix.
  • Files reached through a symlink or a hard link. Checkpointing does not restore those paths.

So if Claude runs a command that reshapes your project, or hands the work to a subagent, and you then rewind, your own edits come back but those changes don’t. This is why checkpoints are best understood as a quick local undo, not a complete time machine.

The symlink case is the sneaky one, because a restore can look like it worked. It doesn’t fail silently, though: Claude Code skips each linked path and prints a Restored the code, but skipped N files warning, and those files keep whatever they contained a moment ago. If you want the names, turn on /debug before you restore and the log at ~/.claude/debug/<session-id>.txt lists every path it stepped over. Two ordinary setups fall in this trap without anyone realising: dotfiles that a config manager symlinks into your project, and packages that pnpm hard-links into place.

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 undo of Claude’s own edits, one checkpoint per prompt, capped at the last 100 and swept away about 30 days after the session last saved one. Perfect for “oops, go back one prompt” 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 a prompt’s own edits can be undone in two keystrokes, you stop being precious about each one. 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? +

Type /rewind, or press Esc twice while the prompt input is empty, to open the rewind menu. Pick a checkpoint, then pick an action: restore code and conversation, restore conversation, restore code, summarize from here, summarize up to here, or never mind. The two code options only appear if that checkpoint has tracked file changes. Claude Code saves a checkpoint every time you send a prompt that starts a turn, so you can step back to any of your last 100 prompts in the session.

Why doesn't Esc Esc open the rewind menu? +

Almost always because you have text in the prompt input. Claude Code's docs say double Esc clears the input when it contains text, and only opens the rewind menu when the input is empty. Press Esc twice again on the now-empty input and the menu appears. Your cleared text isn't lost either: it goes into your input history, so press Up to bring it back afterwards.

Can I rewind after running /clear? +

Yes, in the same Claude Code process. The rewind menu shows an extra entry at the top of the list labelled /resume, followed by the previous session's id and the words (previous session). Selecting it resumes the conversation that was active before /clear ran. It stays available until you exit Claude Code or resume a different session, and it needs Claude Code v2.1.191 or later. On older versions, run /resume and pick the previous session from the list instead.

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 undo for the file edits Claude makes with its own editing tools. They do not track changes made by commands run in the terminal or by other programs, they only keep the 100 most recent checkpoints in a session, and a cleanup sweep deletes a session's snapshots about 30 days after it last saved one, by default. 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? +

Four kinds of change stay put. Files touched by a shell command Claude ran (like a script that moved files), anything changed outside Claude Code by you or another tool or a second session, edits made by a subagent, and files reached through a symlink or a hard link. The subagent case has one exception: a skill forked in the foreground edits your working tree during your own turn, so rewind restores it. Any other subagent, including a forked skill running in the background (the default) and a background /code-review --fix, needs git to revert. That's the reason to commit to git before risky steps.

Set location

Tunes each tool to where you are. Stays on this device.

Set your AI

Which AI do you use?

Not sure? Help me choose →