
Checkpoints Aren't Git: What /rewind Can and Can't Undo
- كاتب موثّق
- Claude Code 2.x
محتويات المقال
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
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 /rewindstill works after you resume a session.The docs encourage it: rewinding makes it "low-risk to try the bolder approach first".
What actually happens
What a checkpoint captures
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
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,/rewinddoes 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 fileswarning. Files pnpm hard-links into place fall into this category.
Git sees what checkpoints don't
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
# 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"# Branch and commit first, so git can undo anything on diskgit switch -c chore/date-fnsgit add -A && git commit -m "Checkpoint before date-fns migration"claude "Migrate src/billing/ to date-fns, run its tests, then stop."# Review every change, whichever tool made itgit status --short && git diff --stat# Discard it all and return to the commit (tracked and new files)git reset --hard && git clean -fdgit diff shows the Bash-made changes the rewind menu would have missed.
/rewind) | ||
|---|---|---|
ask rule makes Claude Code stop and ask you before it runs a command you can't take back:
{ "permissions": { "ask": ["Bash(git push *)", "Bash(pnpm db:migrate *)"] }}How to apply it in your project
Start from a commit Before 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. Commit at every green check Small commits after each passing step give you rewind points that cover shell commands and survive the session. Use `/rewind` inside the session Restore 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. Review with git, not the rewind menu git statusandgit diffshow every change on disk, including the ones a Bash command or a subagent made. Inside the session,/diffgives you the same picture: itsCurrentview reads the working tree from git, while its per-turn views show only Claude's file edits.Gate what nothing can undo Put askrules 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 /rewindfor quick experiments, commit at each green check, and gate irreversible commands.
التعليقات (0)