Claude Code renamed a symbol across the repo with sed through Bash — why can't /rewind undo it, and what else escapes its checkpoints?
answer
- which tools take snapshots
- shell commands leave no snapshot
- edits from outside the session
- subagents and linked files
- git is the fallback
basics
~20 sCheckpoints snapshot only files changed by Claude Code's file-editing tools, so a sed rename through Bash is not tracked. Manual or other-session edits (normally), most subagent edits, symlinked or hard-linked files and remote side effects also escape; use git.
solid answer
~40 sClaude Code snapshots a file before its file-editing tools (`Edit`, `Write`) change it, and only those snapshots can be restored. A `sed -i` rename, like `rm`, `mv`, `cp`, a formatter or a code generator run through `Bash`, changes files without a snapshot, so **Restore code** leaves it in place; if the same turn also used `Edit`, a restore can leave the tree half-reverted. Also outside checkpoints: edits you make outside Claude Code or from another concurrent session (normally, unless they hit files this session edited), most subagent edits (only a foreground forked skill is restored), symlinked or hard-linked paths (skipped with a `Restored the code, but skipped N files` warning), and side effects on databases, APIs or deployments. For all of those the undo is git, or asking Claude to reverse the change.
go deeper
Remember that only edits made by Claude Code's file-editing tools are restorable, and that shell commands like sed, rm or mv are not.
Explain the snapshot-before-edit mechanism and list what escapes it: shell changes, external edits, most subagent edits, linked files and remote effects.
Spot the half-reverted tree after a mixed turn, verify with git after every restore, and know which subagent runs land outside checkpoints.
Treat rewind as a convenience over the agent's own edits and make version control and permissions carry the guarantees a team depends on.
## How checkpoints capture changes Claude Code creates a **checkpoint** before every prompt that starts a turn, and before one of its file-editing tools (such as `Edit` or `Write`) changes a file, it saves a snapshot of that file's current contents. A **Restore code** action in the rewind menu (opened with `Esc` twice on an empty prompt, or `/rewind`) writes those snapshots back. The consequence is the whole answer: rewind can restore exactly what it snapshotted, and it snapshots only what the file-editing tools touched. Anything that changes the disk by another route is invisible to it. ## Why the sed rename survives a rewind A rename done as `sed -i 's/oldName/newName/g'` over many files runs through the `Bash` tool. The shell process rewrites the files directly; no file-editing tool is involved and no snapshot is taken. The checkpointing documentation names the same class with `rm file.txt`, `mv old.txt new.txt` and `cp source.txt dest.txt`: these modifications cannot be undone through rewind. Two practical effects follow: - **Restore code does not undo the rename.** The renamed files keep their new contents. - **A mixed turn can half-revert.** If Claude also edited some files with `Edit` in that turn, those go back to their snapshots while the files only `sed` touched keep the rename, which can leave a tree that does not build. Check `git status` and `git diff` after any restore that followed shell work. ## Everything else checkpoints miss | Change | Restored by rewind? | Why | | - | - | - | | Edits by `Edit` / `Write` in this session | Yes | Snapshotted before each edit | | Shell commands through `Bash` | No | No snapshot is taken | | Your manual edits outside Claude Code | Normally no | Only files edited in this session are tracked | | Edits from another concurrent session | Normally no | Same reason | | Subagent edits, except a foreground forked skill | No | Made outside your session's checkpoints | | Symlinked or hard-linked paths | Skipped | Restore refuses to write through links | | Databases, APIs, deployments | No | Remote state cannot be checkpointed | Some details behind the table: - **Subagents.** A subagent edits with the same file-editing tools, yet Claude Code usually does not capture those edits in your session's checkpoints. The exception is a skill that forks into a subagent and runs in the **foreground** (`background: false` in its frontmatter): it edits during your own turn, so rewind restores it. A forked skill left at its default background setting, a background `/code-review --fix` run and any other subagent are not restored. - **Linked files.** On a code restore Claude Code skips tracked paths that are symlinks or hard links, leaves their current contents, and reports `Restored the code, but skipped N files`. Config files a dotfile manager links into the project and files pnpm hard-links into place hit this. Turning on `/debug` before restoring makes the debug log name each skipped path. - **External edits.** Edits you make in your editor, or another session makes, are normally not captured unless they touch the same files the current session edited. - **Queued messages.** A message you type while Claude works that joins the running turn has no checkpoint of its own; you rewind to the prompt that started the turn instead. ## Recovering what rewind cannot 1. Inspect the damage with `git status` and `git diff`, which see every change regardless of which tool made it. 2. Revert with git (for example `git restore` on the affected paths), or ask Claude to reverse the specific change. 3. For remote side effects, recovery belongs to that system; inside Claude Code the control is the permission mode and rules that decide whether such a command runs at all. ## The takeaway Checkpoints are a convenience for undoing the agent's own file edits within one session. They are not a record of everything that happened to the working tree, which is why they sit alongside version control and never replace it. A useful habit follows from the table: when you see the agent reach for `sed`, `mv`, a codemod or a package manager, treat that step as outside the undo button and make sure git can take you back across it.
- In Claude Code, does /rewind undo edits made by a skill that runs in a forked subagent?It depends on where the fork runs. A forked skill running in the foreground, `background: false` in its frontmatter, edits your working tree during your own turn, so rewind restores it. The default for a forked skill is the background, and those edits land outside your session's checkpoints, like any other subagent's; revert them with git.
- A Claude Code code restore reports 'Restored the code, but skipped 2 files'. How do you find and fix them?Restore skips tracked paths that are, or became, symlinks, hard links or other non-regular files, whose directory changed, or whose backup can't be read safely, and leaves their contents. Run `/debug` before restoring so the debug log names each skipped path, or find links with `find . -type l`. Then reverse those edits yourself, or ask Claude to.
A checkpoint is like an editor's undo history: it remembers every change typed in that editor, but a script that rewrote the file from outside left no entry to undo.
- Every tool call, including Bash, takes a file snapshot
- Rewind undoes anything that changed in the working directory
- Subagent edits are always restored because subagents use the Edit tool
- A restore writes through symlinks to put the target file back
- Checkpoints can roll back a migration that ran against the database