Skip to content

Checkpointing

How Claude Code snapshots files before each prompt, how to rewind code or conversation with /rewind, and what checkpoints cannot undo.

Every time you send a prompt that starts a new turn, Claude Code quietly records the state of the files it is about to touch. If the next few minutes go sideways (a refactor that breaks the build, an approach you regret, a conversation that wanders into a dead end), you can wind back to any of those points. I lean on this constantly when exploring: let Claude try something bold, and rewind if it does not land.

This page explains what is captured, how to rewind or summarise, and the gaps you need to cover with git.

What gets captured

  • One checkpoint per turn. Each prompt you send that starts a turn creates a checkpoint before Claude acts on it.
  • Only edits made with Claude's file tools. Writes and edits through Claude's own editing tools are tracked. Shell commands are not (see limitations).
  • The last 100 checkpoints per session keep their snapshots. When an older checkpoint is discarded, snapshot files no longer referenced by any remaining checkpoint are deleted, except each file's very first snapshot, which the VS Code extension keeps as the baseline for its session diffs.
  • They survive resume. Checkpoints are stored with the conversation, so /rewind still works after claude --resume.
  • They expire. The retention sweep removes a session's snapshots roughly 30 days after it last saved one. Rewinding to a checkpoint whose snapshots have gone can fail with No files were restored (see Errors). Increase cleanupPeriodDays in settings to keep them longer; the .claude directory page describes what the sweep cleans.

Opening the rewind menu

Either run /rewind, or press Esc twice with an empty prompt.

Note: If there is text in the prompt, double Esc clears it rather than opening the menu. The cleared text goes into your input history, so press Up afterwards to get it back.

The menu lists the prompts you sent this session. Pick one, then pick what to do:

ActionFiles on diskConversation
Restore code and conversationReverted to that pointRewound to that point
Restore conversationLeft as they are nowRewound to that point
Restore codeReverted to that pointLeft as it is
Summarize from hereUntouchedMessages from this point on are compressed into a summary
Summarize up to hereUntouchedMessages before this point are compressed; later ones kept
Never mindUntouchedUntouched; back to the list

The two code options only appear when the chosen checkpoint actually has tracked file changes to undo. If nothing was edited after that point, you get Restore conversation, the two summarise options and Never mind.

What happens to the prompt box afterwards:

  • After Restore conversation, Restore code and conversation or Summarize from here, the original prompt from the message you picked is put back in the input, ready to edit and resend. This is the bit I use most: rewind, tweak the instruction, go again.
  • After Summarize up to here, you stay at the end of the conversation with an empty prompt.

Either summarise option leaves a Summarized conversation marker where the compressed messages used to be.

Getting back to a conversation you cleared

If you ran /clear earlier in the same Claude Code process, the top of the rewind list includes an extra entry, /resume <session-id> (previous session). Choosing it resumes the conversation that was active before the clear. It stays available until you exit or resume a different session.

Steering a summary

Summarising never touches files, and the full original messages remain in the transcript on disk, so Claude can still look details up. To tell the summariser what matters, move to a Summarize option with the arrow keys, type your guidance on the row marked add context (optional), and press Enter. Pressing the option's number key instead summarises straight away with no guidance.

For example, after a long debugging detour I might pick the message where the detour started, choose Summarize from here, and add "keep the root cause and the final fix, drop the dead ends".

Tip: Summarising keeps you in the same session, like a targeted /compact. If you want to try an alternative approach while keeping the original session intact, branch instead with /branch or claude --continue --fork-session (see Sessions).

When checkpoints earn their keep

  • Trying two designs. Let Claude build approach A, rewind code, ask for approach B, and compare.
  • Backing out a bad change. Restore code to before the edit that broke the tests, keep the conversation so Claude remembers what went wrong.
  • Iterating on UI. Tweak, look, rewind, tweak again, without polluting git history.
  • Recovering context. Summarise a noisy investigation from its midpoint so your original brief stays verbatim. Context window explains why this matters.

What checkpoints cannot undo

Shell commands

Anything Claude does through Bash is invisible to checkpoints. If Claude runs something like:

npx prettier --write "src/**/*.tsx"
git mv lib/legacy.ts lib/old/legacy.ts
rm -rf .next

those changes stay put however far you rewind. Only edits made by Claude's file editing tools are restored.

Most subagent edits

Subagents also use the file tools, but their edits usually are not recorded in your session's checkpoints:

  • A skill with context: fork running in the foreground edits your working tree during your own turn, so rewinding restores those edits normally. Set background: false to run a forked skill in the foreground; certain situations described on Skills force the foreground anyway.
  • Everything else (background forked skills, which is the default, background /code-review --fix runs, and other subagents) is not restored. Use git.

Changes made outside the session

Edits you make yourself in an editor, or edits from another Claude Code session running at the same time, are normally not captured, unless they touch the same files this session also edited.

Messages that join a running turn

If you queue a message while Claude is working and it is delivered into the turn already in progress, it becomes part of that turn and gets no checkpoint of its own. To undo what followed it, rewind to the prompt that started the turn, which also undoes the work before your message arrived. A queued message that is sent as the start of a new turn (including several queued messages sharing one) gets a checkpoint as normal.

Restores skip any tracked path that is a symbolic or hard link, with a Restored the code, but skipped N files warning; those files keep their current contents. Common examples are config files symlinked in by a dotfiles manager and packages hard-linked by pnpm. Ask Claude to reverse the edit, or fix the file yourself. To see exactly which paths were skipped, turn on /debug before restoring and check ~/.claude/debug/<session-id>.txt; Errors lists every skip reason.

Real version history

Checkpoints are a session-level undo, not a history. Keep committing to git for anything you want to keep, share or review. My habit is to commit whenever a step works, and use checkpoints for the messy minutes in between.