الانتقال إلى المحتوى
Claude وأدوات الـ AI للبرمجةClaude Code· 6 دقائق للقراءة

Checkpoints Aren't Git: What /rewind Can and Can't Undo

Rewind restores what Claude's file tools edited in this session. Shell commands, subagents and databases are on you.

ReadIn

مقال كل يوم يفرق معاك

21 نوفمبر 2026
  • كاتب موثّق
  • Claude Code 2.x
محتويات المقال

A developer asks Claude Code to migrate the billing module from one date library to another. Claude edits a dozen files with its edit tool, then runs a codemod script through Bash that rewrites forty more, installs the new package, which updates the lockfile, and applies a migration to the local dev database. The tests go red. The developer presses Esc twice and chooses Restore code. The dozen edited files snap back. The forty codemod files, the lockfile and the database stay as they are. Nothing was committed before the session started, so git can't help either.

The common misconception

"Checkpoints can undo anything the session changed, so committing to git along the way is unnecessary." It's an understandable belief:

  • Rewind feels like time travel. Open the menu, pick a prompt, and the code and the conversation go back.
  • It's automatic. Every prompt you send creates a checkpoint, with no setup.
  • It lasts. Checkpoints are saved with the conversation, so /rewind still works after you resume a session.
  • The docs encourage it: rewinding makes it "low-risk to try the bolder approach first".

The half-truth: for edits Claude makes with its file tools in your main conversation, rewind is fast and reliable. But that is exactly its boundary, and most real sessions cross it.

What actually happens

What a checkpoint captures

Claude Code captures the state of your code before each prompt you send that starts a turn, and it tracks the changes made by Claude's file editing tools. Each is saved with the conversation. Claude Code keeps file snapshots for the 100 most recent checkpoints in a session, and its retention sweep deletes a session's snapshots, 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.

What the rewind menu offers

/rewind, also available as /checkpoint or /undo, or Esc twice on an empty prompt, lists the prompts you sent. For each one you can restore the code and the conversation, only the conversation, or only the code, or summarize part of the conversation. The code options appear only when that checkpoint has tracked file changes to revert.

What it can't undo

The checkpointing docs list the limits:

  • Files that only Bash commands changed: codemods, npm install, a formatter run from the shell. Once Claude has edited a file with its file tools, /rewind does undo later Bash changes to that file.
  • Edits by most to files Claude hadn't already edited in your conversation. A forked skill running in the foreground is the exception.
  • Your own edits outside Claude Code and edits from other concurrent sessions, unless they touch the same files.
  • Symlinked and hard-linked files, which a restore skips with a Restored the code, but skipped N files warning. Files pnpm hard-links into place fall into this category.

Beyond files, the overview is explicit: actions that affect remote systems, such as databases, APIs and deployments, "can't be checkpointed."

Git sees what checkpoints don't

Git doesn't care which program changed a file. A codemod, a package manager or your own editor all show up in git status. The docs put the roles plainly: checkpoints are for "quick, session-level recovery", and git stays the tool for commits, branches and long-term history. The best-practices guide adds that they "work alongside git rather than replacing it."

A session with no way back vs one with a commit under it

Bash terminal
# Uncommitted work in the tree, a big change, no branchgit status --short   # 14 files modified, nothing committedclaude "Migrate the billing module from moment to date-fns"

In the first session, the only way back is the rewind menu, and it can't restore what the codemod rewrote. In the second, the commit is a floor you can always return to. git diff shows the Bash-made changes the rewind menu would have missed.

Checkpoints (/rewind)Git
What it tracksEdits by Claude's file tools in this sessionEvery change to files in the repo, by anything
When it's createdAutomatically, before each promptWhen you commit
How long it lastsThe last 100 checkpoints, swept after about 30 daysUntil you rewrite history
Undo a codemod run through BashOnly for files Claude had already editedYes
Shared with teammatesNoYes, once you push
Undo a database migrationNoNo: you need a down migration or a backup

An ask rule makes Claude Code stop and ask you before it runs a command you can't take back:

JSON .claude/settings.json
{  "permissions": {    "ask": ["Bash(git push *)", "Bash(pnpm db:migrate *)"]  }}

How to apply it in your project

  1. Start from a commitBefore a large change, commit or stash what's in the tree and switch to a branch, so there's a clean point to return to.
  2. Commit at every green checkSmall commits after each passing step give you rewind points that cover shell commands and survive the session.
  3. Use `/rewind` inside the sessionRestore Claude's edits, or just the conversation, when an approach fails. It's faster than git for that, and it can summarize a stale stretch of conversation too.
  4. Review with git, not the rewind menugit status and git diff show every change on disk, including the ones a Bash command or a subagent made. Inside the session, /diff gives you the same picture: its Current view reads the working tree from git, while its per-turn views show only Claude's file edits.
  5. Gate what nothing can undoPut ask rules on pushes, migrations and deploys. A rule matches the command text Claude writes, not every way to run the program, so it's a speed bump, not a security boundary.

Key takeaways

  • Checkpoints track edits made by Claude's file tools in your session, captured before each prompt.
  • They miss files only Bash changed, most subagent edits, your own edits and symlinked or hard-linked files.
  • Remote effects such as databases, APIs and deployments can't be checkpointed at all.
  • Git sees every change on disk, lasts beyond the session and is shared with your team.
  • Use /rewind for quick experiments, commit at each green check, and gate irreversible commands.

📚 المصادر

  1. Checkpointing — Claude Code Docs
  2. Commands — Claude Code Docs
  3. How Claude Code works — Claude Code Docs
  4. Best practices for Claude Code — Claude Code Docs
  5. Interactive mode — Claude Code Docs

التعليقات (0)