little cups of claude

tips and techniques for Claude and Claude Code

#10: Checkpoints and Rewind ⏪

Today we'll look at checkpoints in Claude Code, and how /rewind lets us back up when a session heads somewhere we didn't want.

Every time we send a prompt, Claude Code captures the state of our code first. If the next few changes go sideways, we can roll the code, the conversation, or both back to that point.

Let's get started.

How It Works

Each prompt that starts a turn creates a new checkpoint. A few details worth knowing:

  • Claude Code keeps file snapshots for the 100 most recent checkpoints in a session.
  • Checkpoints are saved with the conversation, so /rewind still works after we resume a session.
  • Snapshots get cleaned up around 30 days after the session last saved one.

To keep them longer, we can raise cleanupPeriodDays in our settings:

{
  "cleanupPeriodDays": 60
}

Opening the Menu

There are two ways in. We can type the command:

> /rewind

Or press Esc twice while the prompt input is empty. If there's text in the input, double Esc clears it instead, but the text goes into our input history, so Up brings it back later.

The menu lists the prompts we've sent this session. We pick the point we want to go back to.

Picking What to Restore

After choosing a prompt, we get a few options:

  • Restore code and conversation: everything goes back to that point
  • Restore conversation: rewind the chat, keep the current code
  • Restore code: revert the files, keep the chat
  • Never mind: back out without changing anything

Restore conversation is handy when the code turned out fine but the conversation went down a rabbit hole. Restore code is the reverse: we keep everything Claude learned along the way and throw away the edits.

After restoring the conversation, our original prompt comes back in the input field, ready to edit and resend.

Summarize Instead

The same menu has two options that don't undo anything. Summarize from here compresses everything after the selected point into a summary, and Summarize up to here compresses everything before it.

It works like a targeted /compact, and files on disk aren't touched. If we highlight a summarize option with the arrow keys, we can type instructions to steer what the summary focuses on.

To try a different approach while keeping the original session intact, the docs suggest branching instead:

claude --continue --fork-session

What Isn't Tracked

Checkpoints cover edits from Claude's file editing tools. Some changes fall outside that:

# Edited by Claude's Edit tool: restored
src/hal/pod-bay-doors.ts

# Only ever changed by a Bash command: not restored
generated/schema.ts

Once Claude has edited a file with its editing tools, later Bash changes to that same file are covered. A file that only Bash touched stays as it is.

Subagent edits usually aren't captured either, beyond files Claude had already edited in our conversation. Changes we make by hand outside Claude Code, edits from other sessions, and symlinked or hard-linked files are also left alone.

Not a Replacement for Git

Checkpoints are for quick, session-level recovery. For anything we want to keep, or anything a Bash command changed, version control is still the safety net:

git status
git diff
git restore generated/schema.ts

A small commit before letting Claude loose on a big refactor gives us both kinds of undo.

More info about checkpoints can be found at the Claude Code docs.

Share

Share on Threads

Similar Cups