Skillforge Field notes on shipping with AI tools

Claude Code /rewind: What Checkpoints Restore and Skip

claude-codeai-workflows

/rewind is Claude Code's undo button, but it is not git. It restores the edits Claude made with its file-editing tools, and it quietly skips several things you might expect it to cover: files only a shell command touched, most subagent edits, symlinks and hard links. This page lists what it does, what it does not, and one behavior we reproduced ourselves: a headless claude -p run takes no checkpoints unless you opt in.

Verified against: the Claude Code checkpointing, settings reference and environment variables pages (fetched 2026-11-23) and claude --version (2.1.330). The -p behavior in the last section was run, not just read. The interactive rewind menu was not: we could not drive /rewind from a headless session, so everything about the menu is as documented.

What gets tracked

Every prompt you send that starts a turn creates a checkpoint, captured before Claude edits anything. Tracking covers changes made by Claude's file-editing tools. Per the docs:

  • Claude Code keeps file snapshots for the 100 most recent checkpoints in a session. When an older checkpoint is discarded, snapshot files no remaining checkpoint references are deleted, except each file's first snapshot (the VS Code extension uses it as the baseline for session diffs).
  • Checkpoints are saved with the conversation, so /rewind still works after you resume a session.
  • Snapshots are deleted by the retention sweep, by default about 30 days after the session last saved one. Rewinding to a checkpoint whose snapshots are gone can fail with No files were restored. Set cleanupPeriodDays to keep them longer (the setting is validated, 0 is rejected, and the docs suggest a large value such as 3650 for long retention).

Opening the menu and choosing an action

Run /rewind (alias /undo), or press Esc twice with an empty prompt. If the prompt has text in it, double Esc clears the text instead (it is saved to input history, so Up recalls it). In vim mode, press Esc twice from NORMAL mode.

Pick a prompt from the list, then one of:

ActionCodeConversation
Restore code and conversationrevertedrewound
Restore conversationkept as isrewound
Restore coderevertedkept
Summarize from hereunchangedcompressed from that point on
Summarize up to hereunchangedcompressed before that point
Never mindunchangedunchanged

The two code-restore options only appear when the selected checkpoint has tracked file changes to revert. Summarizing does not touch files, and the original messages stay in the session transcript. It is like a targeted /compact. To branch and try another approach while keeping the original session intact, the docs point to /branch or claude --continue --fork-session instead.

Three details worth knowing:

  • After a conversation restore (or Summarize from here), the original prompt is put back in the input box so you can edit and re-send it.
  • If you exit right after rewinding without sending another prompt, the rewound messages can come back on resume. Send Claude a prompt before you exit so the rewound conversation is saved. Files you restored stay as the rewind left them.
  • If you ran /clear earlier in the same process, the menu shows a top entry /resume <session-id> (previous session) that returns you to the pre-clear conversation, until you exit or resume a different session.

What /rewind does not undo

This is the part that causes surprise. All of these are from the checkpointing page.

Bash-only changes. A file that only a Bash command changed is not tracked and stays as it is. The subtlety: once Claude has edited a file with a file-editing tool in your conversation, /rewind also undoes later Bash changes to that file. So sed -i on a file Claude never edited is invisible to rewind; the same sed -i on a file Claude already edited gets reverted.

Subagent edits. Claude Code usually does not capture subagent edits in your checkpoints. A foreground forked skill (context: fork, run in the foreground) edits during your own turn, so rewinding restores it as usual. Any other subagent, including a forked skill running in the background (the default) and a background /code-review --fix run, is restored only for files Claude had already edited in your conversation. Its edits to other files stay.

External changes. Only files edited within the current session are tracked. Your manual edits and edits from other concurrent sessions are normally not captured, unless they touch the same files.

Mid-turn messages. A message you type while Claude is still working can show No code restore in the menu because it has no checkpoint of its own. To undo edits made after it, select the prompt that started the turn and choose a code-restore action. That reverts the whole turn's edits, including those from before your message arrived.

Symlinks and hard links. Restore skips any tracked path that is a symlink or hard link and shows Restored the code, but skipped N files. Dotfile-manager symlinks into a project and files pnpm hard-links into place both fall in this category. Turn on /debug before restoring to get the skipped paths in ~/.claude/debug/<session-id>.txt.

The docs say it plainly: checkpoints are for quick session-level recovery, not a replacement for version control.

Turning it off, and headless mode

Two controls exist. The fileCheckpointingEnabled setting (default true, shown in /config as "Rewind code (checkpoints)") and the CLAUDE_CODE_DISABLE_FILE_CHECKPOINTING=1 environment variable, which overrides the setting. When off, /rewind cannot restore code.

The settings page adds an exception: in a -p run or an Agent SDK session Claude Code ignores fileCheckpointingEnabled. The SDK turns checkpointing on with its enableFileCheckpointing option, and a bare -p run needs CLAUDE_CODE_ENABLE_SDK_FILE_CHECKPOINTING=true.

We ran that on 2.1.330. In a scratch directory containing a.txt with the text v1, we ran:

claude -p --permission-mode acceptEdits --allowedTools Read Edit \
  "Read a.txt, then use the Edit tool to change v1 to v2. Reply done." < /dev/null

Result without the variable: the edit applied (v2), the session transcript had no file-history-snapshot entries, and no ~/.claude/file-history directory was created. Result with CLAUDE_CODE_ENABLE_SDK_FILE_CHECKPOINTING=true: the edit applied, the transcript gained one file-history-snapshot and one file-history-delta entry, and ~/.claude/file-history/<id>/ appeared containing one file named like <hash>@v1 whose content was the pre-edit text v1. That matches the documented design: a pre-edit copy of each file, stored outside your project.

What we did not test: actually restoring from that snapshot (no interactive menu in -p), the Agent SDK option, or any of the limitations above. If you run unattended -p jobs and want an undo path, do not assume checkpoints exist: either set the variable, or rely on git (commit or stash before the run).

Practical rules

  • Commit before long agent runs. Rewind covers Claude's edits, git covers everything.
  • Do not count on rewind after delegating to background subagents or running shell scripts that write files Claude never edited.
  • For long-lived sessions, raise cleanupPeriodDays if you want to rewind days later.
  • Use Summarize options when the problem is context size, not bad edits. They do not change files.

FAQ

Does /rewind delete my git history or commits? The checkpointing page describes it as restoring files Claude edited and the conversation. It does not describe touching git, and it says to use version control for permanent history. We did not test an interaction with commits.

Is /undo different from /rewind? The docs call /undo an alias of /rewind.

How many checkpoints can I go back? Snapshots are kept for the 100 most recent checkpoints in a session, one checkpoint per prompt that starts a turn.

Can I rewind a session I resumed yesterday? Yes, checkpoints are saved with the conversation, as long as the snapshots have not been removed by the retention sweep (about 30 days by default).