Rewind Claude Code Edits With Checkpoints

3 prompts ago the approach was fine. Then Claude decided the fix needed a refactor, and now 6 files are different and the tests are worse. You do not need to describe what to put back. Claude Code took a snapshot of your files before each prompt, and the rewind menu puts them back.

This post covers how checkpoints are taken, the menu and its 5 options, what is and is not tracked, and why git is still the real undo. The shortcut and menu are from the current docs, linked at the end. The post assumes a working install; Install Claude Code on Windows, Native and in WSL is the start if you need it.

How Checkpoints Work

Every prompt you send that starts a turn creates a checkpoint, and Claude Code keeps file snapshots for the 100 most recent in a session. Snapshots are saved with the conversation, so /rewind still works after you resume a session, until the 30 day sweep removes them with the transcript; the transcripts post covers cleanupPeriodDays, which keeps both longer.

Only files Claude changes with its own editing tools are tracked. That line matters later.

Open the Menu

Code
Esc Esc      with the prompt empty: open the rewind menu
/rewind      the same, as a command (aliases /checkpoint and /undo)

If the prompt has text in it, double Esc clears the text instead; it is saved to history, so Up brings it back. The menu lists every prompt you sent this session. Pick the one you want to go back to, then choose:

  • Restore code and conversation: files and chat both go back to that point.
  • Restore conversation: the chat rewinds, the files stay as they are now.
  • Restore code: the files go back, the chat keeps everything that happened since.
  • Summarize from here: compress everything after that prompt into a summary, to free context.
  • Summarize up to here: compress everything before it, keeping the recent messages whole.

The 2 code options only appear when the selected checkpoint has file changes to revert. After a conversation restore, the prompt you selected is put back in the input so you can edit and resend it, which is the usual move: same ask, better wording.

Here is the menu on my machine after I asked for the same small edit twice, worded differently. Each prompt is listed with what it changed:

The rewind menu in Claude Code after the same edit was made twice: the first prompt says Can't restore changes.txt (changed while a command ran), the second, made with the edit tool, shows changes.txt +1 and can be restored

The second prompt shows changes.txt +1, so it can be rewound. The first says Can’t restore changes.txt (changed while a command ran). Both prompts asked for the same line. The difference is how Claude made the change: the first time it ran a shell command that appended the line, and the second time, when I asked it to use its file edit tool, it edited the file directly.

That is the whole mechanism in one picture. Each prompt is a checkpoint, and what a checkpoint can put back is the changes Claude Code’s own edit tools made. A shell command is just a program running on your machine, so Claude Code cannot see what it did to the file, and there is nothing saved to put back. If you want a change to be undoable from this menu, ask Claude to make it with its edit tool, or commit to git first. The next sections cover what else is and is not tracked.

Restore Code, Keep the Lesson

Restore code on its own is the option to reach for when the approach was wrong but the conversation was not. The files go back to the checkpoint, Claude still has the context of what it tried and why it failed, and your next prompt can say “the refactor was the mistake, keep the original structure and fix only the null check”. Plan mode is the other half of this: on a big change, plan first and there is less to rewind.

Summarise to Free Context

The 2 summarise options are a targeted /compact. A long debugging stretch in the middle of a session can be collapsed while the instructions before it and the work after it stay whole. Highlight a summarise option and type guidance in the add context field before pressing Enter to steer what the summary keeps. Nothing on disk changes, and the original messages stay in the transcript.

What Is Not Tracked

This is the section to read before trusting the menu with something that matters:

  • Changes made by shell commands to a file Claude never edited with its tools. A git checkout, a build that rewrites a file, a script Claude ran: not tracked. Once Claude has edited a file, later shell changes to that same file are undone with it.
  • Subagent edits. A subagent’s changes to files your main session had not already edited stay. The subagents post covers why they run apart.
  • Your own edits in VS Code while the session was open, and edits from another Claude Code session in the same folder, unless they touch a file Claude had already edited.
  • Symlinked and hard-linked files are skipped with a Restored the code, but skipped N files warning.
  • A message you sent mid-turn has no checkpoint of its own and shows as No code restore; select the prompt that started the turn instead.

The first entry in the screenshot under Open the Menu is the first case on this list happening: an edit made by a shell command, listed but not restorable.

For all of those, the undo is version control. The docs say it plainly: checkpoints are session-level recovery, not a replacement for git. Commit before a big change and git diff after it, and the rewind menu is a convenience on top of that rather than the safety net.

Other Considerations

Rewound messages can come back if you exit before sending another prompt, because the rewound state is saved with your next prompt. Send one before you close the terminal.

After /clear, the menu gains a top entry, /resume <session-id> (previous session), that takes you back to the conversation you cleared. It lasts until you exit or resume something else.

Rewind is not branch. To keep the current path and try another from an earlier point, /branch copies the session instead; the sessions post covers it.

/diff shows what Claude has changed in the working tree so far, which is the quicker check before deciding whether to rewind at all.

Not sure which option you want? Ask Claude first. Tell it what you want back and what you want to keep, and let it talk you through the choice before you pick one.

Frequently Asked Questions

Is /rewind the same as git reset?

No. It restores files Claude edited this session from its own snapshots, nothing more. Git covers everything else, including files only a command changed.

Why does the menu offer only Restore conversation?

No file edits were captured after that prompt. The code options appear only when there is something to revert.

Can I rewind after resuming a session?

Yes, checkpoints are saved with the conversation. If the snapshots have been swept, after 30 days by default, the restore fails with No files were restored.

Does rewinding cost tokens?

No. Restoring is local. A summarise option sends a request to produce the summary, like /compact does.

Esc twice opens nothing.

The prompt had text in it, so the first double Esc cleared the draft. Press it again on the empty prompt, or type /rewind.


If SQL Server is part of your day job, my current work lives over at sqldba.blog: production DBA scripts, an error library and the SSMS guide.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *