# Claude Code Checkpoints: How /rewind Works and What It Can't Undo

> How Claude Code checkpoints work: what /rewind restores, the rewind menu's actions, what isn't tracked, how long snapshots last, and where git fits in.

Claude Code creates a checkpoint for every prompt that starts a turn and tracks the edits its file-editing tools make. Run /rewind (or /undo, /checkpoint, or Esc twice) to restore code, the conversation, or both, or to summarize part of the session. Files only Bash touched, most subagent edits and outside changes aren't tracked, so keep git for real history.

Checkpoints are [Claude Code's](/tools/claude-code) undo. Anthropic's "Checkpointing" page puts it in one line: "Claude Code automatically tracks Claude's file edits as you work." When an approach goes wrong, you rewind to an earlier prompt instead of asking the agent to dig itself back out.

The feature arrived in v2.0.0 on September 29, 2025, as "/rewind a conversation to undo code changes." As of November 2026 it has more to it: two aliases, five actions in the menu, and partial tracking of Bash changes. The [Claude Code tips](/guides/getting-started/claude-code-tips) page gives the one-line version; this guide covers what is restored, what isn't, and how long snapshots last.

## What a checkpoint captures

Two rules from the docs define the feature:

- "Every prompt you send that starts a turn creates a new checkpoint."
- "Claude Code tracks all changes made by its file editing tools."

Bash sits in between. "Once Claude has edited a file with its file editing tools in your conversation, `/rewind` undoes changes that Bash commands make to that file afterward. A file that only Bash commands changed isn't tracked and stays as it is." If Claude edits `config.ts` and later runs a script that rewrites it, a rewind covers both changes. A file that a generator created through Bash isn't covered.

Messages you send while Claude is mid-turn can appear in the menu marked "No code restore." Checkpoints are listed among the features available on every provider, so they aren't limited to the Anthropic API.

## Opening the rewind menu

"Run `/rewind`, or press `Esc` twice when the prompt input is empty, to open the rewind menu." If the input has text in it, "double `Esc` clears it instead of opening the menu." In vim mode, press Esc twice from NORMAL mode. `/undo` (added in v2.1.108) and `/checkpoint` are aliases for `/rewind`.

If you ran `/clear` earlier in the same Claude Code process and want to get back to what came before, the menu shows a `/resume <session-id> (previous session)` entry for the earlier session.

## The rewind actions

Pick a message, then one of these:

| Action | Files | Conversation |
| --- | --- | --- |
| Restore code and conversation | Reverted to the checkpoint | Rewound to the selected message |
| Restore conversation | Unchanged | Rewound to the selected message |
| Restore code | Reverted to the checkpoint | Unchanged |
| Summarize from here | Unchanged | Compressed into a summary |
| Summarize up to here | Unchanged | Compressed into a summary |
| Never mind | Unchanged | Unchanged |

"The two code restore options appear only when the selected checkpoint has tracked file changes to revert." After you restore the conversation, "the original prompt from the selected message is restored into the input field," so you can fix the prompt and send it again instead of patching the result. The Summarize actions work "like a targeted `/compact`" and don't change files; "Summarize up to here" arrived in v2.1.141.

How to choose:

- **The approach was wrong from a given prompt.** Restore code and conversation, then edit the prompt that sent things sideways.
- **The code is fine but the discussion went off track.** Restore conversation, which keeps the files as they are.
- **The plan was right but the edits weren't.** Restore code and keep the conversation, so Claude still knows what you agreed.
- **The session is long but nothing is broken.** Use a Summarize action to free context. The [memory and context guide](/guides/configuration/claude-code-memory-context) covers when compaction helps.

## What checkpoints don't track

Assume these are not restored:

- **Files that only Bash changed**, as described above.
- **Most subagent edits.** "Claude Code usually doesn't capture those edits in your session's checkpoints." A foreground forked skill is the exception. Otherwise "rewinding restores only the files Claude had already edited in your conversation." The [subagents reference](/guides/configuration/claude-code-subagents) covers when work is delegated.
- **Your edits and other sessions' edits.** "Manual changes you make to files outside of Claude Code and edits from other concurrent sessions are normally not captured, unless they happen to modify the same files as the current session."
- **Symlinked and hard-linked files.** "Checkpointing doesn't rewind symlinked or hard-linked files." You'll see a warning such as `Restored the code, but skipped N files`.

Checkpoints cover local file edits only. They don't reverse what a command did elsewhere, such as pushing a branch or calling an API. Run `git status` after any rewind in a session where Claude used Bash or subagents.

## A rewind, step by step

A fictional session shows how those rules combine. In your first prompt you ask Claude to add rate limiting to `api/server.ts`. It edits the file with its edit tool, then runs a formatter through Bash that rewrites the same file. In your second prompt you ask for a database migration. Claude runs a generator through Bash, which creates `migrations/0042_rate_limits.sql`, and hands test-writing to a subagent, which adds `tests/rate_limit.test.ts`.

You decide the whole approach is wrong, open `/rewind`, select the first prompt, and choose Restore code and conversation. Here is what happens:

- **`api/server.ts` goes back to its original state**, including the formatter's rewrite, because Claude had edited the file with its file tools before Bash touched it.
- **`migrations/0042_rate_limits.sql` stays.** Only Bash created it, so it was never tracked.
- **`tests/rate_limit.test.ts` most likely stays**, because subagent edits usually aren't captured.
- **Your first prompt returns to the input field**, ready to rewrite.

`git status` now shows the two leftover files, and you delete them by hand. That cleanup step is the habit to build: a rewind restores what Claude's own file tools touched, and git shows you everything else.

## How long checkpoints last

- **Per session:** "Claude Code keeps file snapshots for the 100 most recent checkpoints in a session."
- **Across resumes:** "Claude Code saves checkpoints with the conversation, so you can still run `/rewind` after you resume a session."
- **On disk:** "Claude Code deletes a session's file snapshots in the retention sweep, by default about 30 days after the session last saved one… To keep snapshots longer, set `cleanupPeriodDays`." That setting defaults to `30`.

A long session can push early checkpoints past the 100 limit, and the sweep removes old sessions' snapshots on its own. Commit anything you want to keep.

## Checkpoints and git

The docs draw the line: "Checkpoints are designed for quick, session-level recovery. For permanent version history and collaboration, continue using version control, such as Git."

| | Checkpoints | Git commits |
| --- | --- | --- |
| Created | Automatically, per prompt that starts a turn | When you commit |
| Covers | Claude's file-tool edits (and later Bash edits to those files) | Whatever you stage |
| Lifetime | 100 per session; swept about 30 days after the last save | Permanent until you rewrite history |
| Collaboration | Not the job; the docs point to Git for it | Yes, when you push |

The working rhythm is to let checkpoints handle undo inside a task and commit at each point you'd be sorry to lose. To try a different direction without throwing away the current one, branch the conversation instead of rewinding: `/branch`, or `claude --continue --fork-session` from the shell. To run alternatives side by side on separate copies of the code, use [parallel git worktrees](/guides/advanced/parallel-claude-code-worktrees).

## Turning checkpoints off

Code checkpoints are on by default. Turn them off with the `fileCheckpointingEnabled` setting, shown in `/config` as "Rewind code (checkpoints)", or set `CLAUDE_CODE_DISABLE_FILE_CHECKPOINTING=1`, after which "the `/rewind` command will not be able to restore code changes."

## Why didn't /rewind restore my file?

Work through the causes in this order:

1. **The code options were missing from the menu.** They appear only when the selected checkpoint has tracked file changes. If Claude only ran commands during that turn, there is nothing to restore.
2. **Only Bash changed the file.** Files that Claude never edited with its file tools aren't tracked.
3. **A subagent made the change.** Subagent edits usually aren't in your session's checkpoints.
4. **You or another session edited it.** Outside edits are normally not captured unless they hit files the current session also changed.
5. **It's a symlink or hard link.** Look for the `Restored the code, but skipped N files` warning.
6. **The snapshot is gone.** Only the 100 most recent checkpoints keep file snapshots, and the retention sweep removes them about 30 days after the session last saved one.
7. **Checkpointing is off.** Check `fileCheckpointingEnabled` and `CLAUDE_CODE_DISABLE_FILE_CHECKPOINTING`.

In every one of these cases, a git commit from before the task is the fallback.

## VS Code, the Agent SDK and headless runs

The [VS Code extension](/guides/getting-started/claude-code-vscode-extension) offers the same idea as three message actions: "Fork conversation from here", "Rewind code to here", and "Fork conversation and rewind code".

In the Agent SDK, file checkpointing is an option (`enableFileCheckpointing`) with a `rewindFiles()` method. From the CLI, the docs show a hidden flag for a [headless](/guides/configuration/claude-code-headless-mode) session:

```bash
CLAUDE_CODE_ENABLE_SDK_FILE_CHECKPOINTING=true claude -p --resume <session-id> --rewind-files <checkpoint-uuid>
```

"The `--rewind-files` flag doesn't appear in `claude --help` output," so use the documented form exactly.

## Sources and further reading

- [Checkpointing](https://code.claude.com/docs/en/checkpointing) — Anthropic
- [Commands reference](https://code.claude.com/docs/en/commands) — Anthropic
- [Settings reference](https://code.claude.com/docs/en/settings-reference) — Anthropic
- [Environment variables](https://code.claude.com/docs/en/env-vars) — Anthropic
- [File checkpointing in the Agent SDK](https://code.claude.com/docs/en/agent-sdk/file-checkpointing) — Anthropic
- [Use Claude Code in VS Code](https://code.claude.com/docs/en/vs-code) — Anthropic
- [Feature availability by provider](https://code.claude.com/docs/en/feature-availability) — Anthropic
- [Claude Code changelog](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md) — Anthropic

---

_Source: https://agentscamp.com/guides/getting-started/claude-code-checkpoints — Guide on AgentsCamp._
