Skip to main content

Checkpointing

Claude Code automatically tracks file changes while you work. It is a safety net that lets you return to a previous state anytime the code changes in ways you didn't intend.

How It Worksโ€‹

A checkpoint is created automatically every time Claude Code modifies files.

Prompt 1: "Build the login API"
โ†’ Checkpoint A created โ†’ code modified

Prompt 2: "Add error handling"
โ†’ Checkpoint B created โ†’ code modified

Prompt 3: "Write tests"
โ†’ Checkpoint C created โ†’ code modified

โ† Esc+Esc can roll back to point B

Key characteristics:

  • Auto-created: a checkpoint is made for each user prompt
  • Persists across sessions: checkpoints remain accessible when a session is resumed with /resume
  • Auto-cleanup: deleted along with the session after 30 days (configurable)

Rewindโ€‹

How to Accessโ€‹

Esc + Esc      # Keyboard shortcut (fastest)
/rewind # Slash command

A scrollable menu appears where you can select any prompt point in the session.

Even if you cleared the conversation with /clear, /rewind can restore the conversation from before the /clear (v2.1.191+).

Restore Optionsโ€‹

Selecting a point presents five options:

OptionReverts codeReverts conversationPurpose
Restore code + conversationOOFully return to that point
Restore conversation onlyXOKeep the code, rewind only the conversation
Restore code onlyOXKeep the conversation, rewind only the code
Summarize from hereXSummarizedCompress the conversation after this point
CancelXXReturn to the menu
Reusing the prompt after restoring

When you restore the conversation, the original prompt from that point is automatically restored into the input box. You can edit it and resend, or run it as-is.

"Summarize from here" vs. Restoreโ€‹

Restore rolls back state โ€” the code, the conversation history, or both, to an earlier point.

Summarize from here behaves differently:

  • Messages before the selected point are kept intact
  • Messages after the selected point are replaced with an AI summary
  • Files on disk are not changed
  • The original messages are preserved in the session transcript

Think of it as a targeted version of /compact. Instead of compressing the whole conversation, it keeps your early context intact and selectively compresses only the space-hungry parts.

/compact                          โ†’ compresses the whole conversation
Esc+Esc โ†’ "Summarize from here" โ†’ compresses only what comes after the selected point

Practical Scenariosโ€‹

Experimenting with a Different Approachโ€‹

> Implement OAuth login with passport.js
... not happy with the result ...

Esc + Esc โ†’ roll back to the earlier point

> Implement OAuth login from scratch (without passport.js)

Recovering from a Mistakeโ€‹

> Refactor this entire module
... the refactoring breaks the existing tests ...

Esc + Esc โ†’ "Restore code + conversation" โ†’ back to before the refactoring

> Refactor only within the bounds of not breaking the tests

Cleaning Up a Debugging Sessionโ€‹

> Fix the payment failure bug
... 30 minutes of debugging, lots of trial and error ...

Esc + Esc โ†’ "Summarize from here" at the point debugging started
โ†’ the trial-and-error is compressed into a summary, freeing up context

Iterating on a Featureโ€‹

> Build search feature v1        โ†’ Checkpoint A
> Add filtering โ†’ Checkpoint B
> Add autocomplete โ†’ Checkpoint C (bug appears)

Esc + Esc โ†’ "Restore code only" at point B
โ†’ conversation history kept, but the code returns to state B

> Implement autocomplete a different way

Limitationsโ€‹

Changes Made via Bash Commands Are Not Trackedโ€‹

Checkpoints only track changes made through Claude's file editing tools. File operations performed by Bash commands cannot be rolled back:

# These changes cannot be reverted by checkpoints
rm file.txt
mv old.txt new.txt
cp source.txt dest.txt

External Changes Are Not Trackedโ€‹

Only files edited by Claude within the current session are tracked. Edits made directly in another editor, or changes from another Claude Code session, are not included.

Not a Replacement for Gitโ€‹

Checkpoints are for quick, session-level rollback. Use Git for permanent version control.

CheckpointsGit
PurposeQuick rollback within a sessionPermanent version history
ScopeCurrent sessionFull project history
Retention30 daysPermanent
Analogy"Local undo""Permanent history"
Habit: git commit before big work

Independent of checkpoints, keep the habit of taking a snapshot with git commit before starting large tasks. It lets you safely recover even from Bash-command changes that checkpoints cannot cover.