Lesson 7.216 min · 5 cards · 8 exercises · 1 mission

Checkpoints and rewind

Going back when the code is written and the direction is wrong: three restore options, summaries to free context, what rewind can't see, and why you still need git.

Plan mode in lesson 7.1 helps you choose a direction before there's code. But sometimes you only see the wrong choice once the code exists: a function name that reads badly, a file split that makes the tests messier, a refactor step that goes too far. This lesson is about going back: checkpoints and the /rewind command, what they can undo, what they can't, and why you still need git.

What a checkpoint is

Claude Code automatically saves the state of your code before each prompt you send. Every prompt that starts a turn is a checkpoint. You don't have to do anything to get them.

A few numbers worth remembering:

  • Each session keeps snapshots for the 100 most recent checkpoints.
  • Checkpoints are saved with the conversation, so you can still rewind after reopening yesterday's session.
  • Snapshots are cleaned up about 30 days after they were last saved. Rewinding to a checkpoint that's been cleaned up reports No files were restored. To keep them longer, change cleanupPeriodDays.

Checkpoints track the files Claude changes with its file editing tools (Edit, Write). That matters, and section 4 comes back to it.

Opening the rewind menu

Two ways:

  • Type /rewind (or its shorter alias, /undo).
  • Press Esc twice while the prompt input is empty. If the input has text, double Esc clears it instead of opening the menu; the text stays in your history, so press Up to get it back.

The menu lists the prompts you've sent in the session. Pick the point you want to go back to, then choose what to do. Lesson 1.3 mentioned Esc for stopping Claude mid-action: one Esc stops, two Esc on an empty input go back.

Three ways back

At the point you pick, the menu offers:

Option Code Conversation When to use it
Restore code and conversation Back to that point Back to that point The whole direction was wrong; redo from there
Restore conversation Kept as it is Back to that point The code is fine, but the conversation has got muddled
Restore code Back to that point Kept as it is Drop the changes, but keep what Claude learned

The two code options only appear when there are tracked file changes after that point. After "Restore conversation", your original prompt goes back into the input: improve it and send it again, instead of typing another correction on top of the old one.

"Restore code" is often overlooked but very useful. Say Claude renamed the list function to findAll everywhere and you don't like it. Restore code puts the files back, while Claude still remembers what it tried and why you didn't like it, so the next attempt is closer.

The menu also has two summarize options: "Summarize from here" and "Summarize up to here". They compress part of the conversation into a summary to free context, without changing files. Type instructions on the "add context (optional)" row to steer the summary. It's like a targeted /compact; lesson 7.3 says more about context.

What rewind can't see

This is the most important part of the lesson. Checkpoints can't undo:

  • Files that only Bash commands changed. In lesson 6.2, Claude inserted a line with printf … >> src/app.js instead of Edit. If Claude hadn't already edited app.js with Edit in that session, that line isn't undone. (If it had, later Bash changes to that file are tracked.)
  • Subagent changes, in most cases. The debugger in lesson 4.3 worked in a separate worktree; a background subagent edits files your session doesn't record.
  • Changes outside Claude Code: your own edits in an editor, another Claude session working on the same repo.
  • Symlinked and hard-linked files: skipped, with a Restored the code, but skipped N files warning.
  • Messages typed while Claude was working can be marked "No code restore"; pick the prompt that started that turn instead.

The docs are blunt: checkpoints are for quick recovery within a session, not a replacement for git.

Rewind, branch and git

Three tools, three jobs:

  • Rewind: step back once or twice in the session you're in. Fast, no planning needed.
  • /branch name: copies the conversation so far into a new branch and switches you into it; the original stays intact, and /resume takes you back. Use it to try another direction while keeping the old conversation. Note that both conversation branches still work on the same code folder. For two truly separate copies of the code, use a git branch or a worktree as in lesson 4.3.
  • Git: long-term history, sharing with the team, and the safety net for everything rewind can't see.

One simple habit ties them together: commit before a big change. Then rewind handles the small steps within a session, while git diff and git checkout handle everything else, including what Bash or subagents did.

Try boldly, step back when needed

With checkpoints, you can try the bold approach first, because stepping back is cheap. The docs pair that with two habits:

  • Watch the first minute and press Esc as soon as Claude drifts.
  • Two failed corrections, then stop. A third correction just piles onto a conversation that already holds two failed attempts. Rewind to before them (or /clear) and write one better prompt that folds in what you've learned.

For todo-api, refactoring a module looks like this: commit a clean state, plan in plan mode (lesson 7.1), approve, let Claude work step by step, and when a step goes wrong press Esc Esc, pick the point just before it, choose "Restore code and conversation", fix the prompt and send it again. The lesson's mission does exactly that with the input checks in the routes.

The next lesson, 7.3, covers the rest of long sessions: background work, managing and resuming sessions, and keeping context lean over hours of work.

Practice lesson 7.2

5 flashcards, 8 exercises checked right on the page, 1 mission on your machine.

Start practice

Related reference

Type to search the reference, templates and lessons.