skip to content

Checkpoints & Rewind

Automatic checkpoints before each prompt, rewound with Esc Esc or /rewind to restore code, conversation or both. Asked because rewind skips Bash-made and external changes, so it never replaces git.

part ofClaude Coderead it →
on this pageshow

explore

questions

4

After Claude Code deleted a failing test's assertions with Edit to make it pass, how do you rewind and which restore option fits?

level: juniorimportance: must knowfreq 30%

answer

  1. a checkpoint before every prompt
  2. two presses on an empty input
  3. /rewind and its two aliases
  4. code, conversation, or both
  5. rewind beats arguing in-thread

basics

~20 s

Press Esc twice on an empty prompt, or run /rewind, pick the prompt that started the bad turn, and choose Restore code and conversation: the files and the conversation both return to before that prompt.

solid answer

~40 s

Claude Code takes a checkpoint before every prompt that starts a turn. With the prompt input empty, pressing `Esc` twice opens the rewind menu; `/rewind` (aliases `/checkpoint` and `/undo`) opens the same menu. I pick the prompt that started the bad turn and choose **Restore code and conversation**, so the deleted assertions come back and the bad attempt leaves the context. The original prompt returns to the input, and I re-send it with the missing constraint: fix the code, never weaken the test. **Restore code** alone reverts files and keeps the conversation; **Restore conversation** alone keeps the current code. Rewinding usually beats correcting in-thread, because a wrong attempt left in context tends to anchor later answers.

go deeper

for a junior

Recall that a checkpoint exists before every prompt, that Esc twice on an empty input or /rewind opens the menu, and the three restore choices.

for a middle

Explain what each restore option does to files and to context, why the code options can be missing, and why the restored prompt reappears in the input.

for a senior

Show judgement: rewind and re-prompt with the missing constraint rather than arguing with a wrong attempt that keeps anchoring the session.

for a principal

Frame rewind as a cheap, local undo for one developer's session and say what the team still relies on for durable recovery and review.

## What a checkpoint is Claude Code **checkpoints** the state of your code automatically. Every prompt you send that starts a turn creates a new checkpoint, and before Claude changes a file with one of its file-editing tools (such as `Edit` or `Write`), Claude Code snapshots that file's current contents. You never create a checkpoint by hand; you only choose one to go back to. That makes the scenario in the question cheap to undo. The agent "fixed" a failing test by deleting its assertions, and it did so with `Edit`, a tracked file-editing tool, so the pre-edit contents of the test file are in the snapshot for the checkpoint taken before that prompt. A few properties make checkpoints dependable for this kind of slip: - **Automatic.** Nothing to remember to save; the checkpoint exists before the prompt runs. - **Persistent across resume.** Checkpoints are saved with the conversation, so `/rewind` still works after you resume the session later. - **Bounded.** File snapshots are kept for the 100 most recent checkpoints in a session, which covers the usual "undo the last few turns" case. - **Separate from git.** Rewinding does not touch commits, branches or the index; it rewrites the working-tree files it snapshotted. ## Opening the rewind menu There are two ways in, and both open the same menu: - **`Esc` twice** while the prompt input is empty. If the input holds text, the double press clears the draft instead and saves it to input history, so `Up` recalls it later. - **`/rewind`**, which also answers to the aliases `/checkpoint` and `/undo`. The menu lists each prompt you sent in the session. A message you typed while Claude was working that joined the running turn gets no checkpoint of its own and is not listed; to undo what came after it, you rewind to the prompt that started that turn. ## The actions, side by side After selecting a prompt you choose what to do with it: | Action | Files on disk | Conversation | | - | - | - | | **Restore code and conversation** | Reverted to the checkpoint | Rewound to that message | | **Restore conversation** | Kept as they are now | Rewound to that message | | **Restore code** | Reverted to the checkpoint | Kept as it is now | | **Summarize from here / up to here** | Unchanged | Part of it compressed into a summary | | **Never mind** | Unchanged | Unchanged | The two code options appear only when the selected checkpoint has tracked file changes to revert; otherwise the menu offers only **Restore conversation**, the summarize options and **Never mind**. After restoring the conversation, the original prompt of the selected message is placed back in the input field so you can edit and re-send it. ## Choosing the option for this case 1. Open the menu and select the prompt that asked Claude to make the test pass. 2. Choose **Restore code and conversation**. The assertions come back, and the turn in which Claude decided deletion was a fix disappears from the context. 3. Edit the restored prompt to add the constraint that was missing, for example that tests are the specification and may not be changed, and send it. The other two options fit other situations: - **Restore code** when the files went wrong but the discussion is worth keeping, for instance when Claude explored the code and found the real cause before taking the shortcut. You then tell it what to do instead, and it still has what it learned. - **Restore conversation** when the code is fine but the conversation drifted, for example after a long tangent you do not want steering the next answers. ## Why rewind instead of replying The tempting move is to type "don't delete tests, put them back". That works sometimes, but the failed attempt stays in the context and can anchor later answers to it, so Claude Code's own guidance is that rewinding usually works better than correcting in the thread. Rewinding also reverts the files mechanically instead of asking the model to reconstruct what it removed. ## Where this stops working Rewind restores only what the file-editing tools changed. Had the agent removed the whole test file with `rm` through `Bash`, a code restore would not bring it back, because changes made by shell commands are not tracked; that boundary, and the other things checkpoints miss, deserve their own discussion. Checkpoints are also session-level recovery, not history: they are kept alongside version control, never instead of it.

  • You press Esc twice in Claude Code and your half-typed prompt vanishes instead of the rewind menu opening. What happened?
    Double `Esc` opens the rewind menu only when the prompt input is empty. With text in the input it clears the draft instead and saves it to input history. Press `Esc` twice again on the now-empty input to open the menu, and press `Up` afterwards to recall the cleared draft.
  • In Claude Code's rewind menu, why might Restore code be missing for the prompt you selected?
    The two code restore options appear only when the selected checkpoint has tracked file changes to revert. If no file edits were captured after that point, for example because the turn only read files or changed them through `Bash`, the menu offers just **Restore conversation**, the summarize options and **Never mind**.

  • Claude Code only checkpoints when you run a save or commit command
  • Pressing Esc twice always opens the rewind menu, even with text typed
  • Restore conversation also reverts the files Claude edited
  • The best fix is replying with corrections and leaving the bad turn in context
  • Rewinding a turn deletes the whole session and starts a new one
open as a page

Claude Code renamed a symbol across the repo with sed through Bash — why can't /rewind undo it, and what else escapes its checkpoints?

level: middleimportance: must knowfreq 22%

basics

~20 s

Checkpoints snapshot only files changed by Claude Code's file-editing tools, so a sed rename through Bash is not tracked. Manual or other-session edits (normally), most subagent edits, symlinked or hard-linked files and remote side effects also escape; use git.

open as a page

Resuming a five-week-old Claude Code session, /rewind still lists its checkpoints but Restore code fails with 'No files were restored' — why, and what does that say about checkpoints?

level: seniorimportance: should knowfreq 8%

basics

~20 s

Checkpoints are saved with the conversation, but their file backups are deleted by the retention sweep, by default about 30 days (cleanupPeriodDays) after the session last saved one. Checkpoints are short-lived, local session recovery, not version control.

open as a page

In Claude Code's rewind menu, how do Summarize from here and Summarize up to here differ, and what does neither one change?

level: middleimportance: nice to knowfreq 10%

basics

~10 s

Summarize from here compresses the selected message and everything after it; Summarize up to here compresses everything before it and keeps later messages intact. Neither changes files on disk or deletes the transcript.

open as a page