Claude Code /rewind can't undo shell commands. Here's what can.

What Claude Code's rewind restores, where it stops, how to recover what it misses, and an agent that undoes both.

Updated October 9, 2026

Claude Code's /rewind puts back the files Claude edited with its own edit tools. It does not put back files that a shell command created, changed or deleted. If Claude ran rm, mv, cp, a code generator or a formatter, rewinding leaves those changes in place. Claude Code's own documentation says so: "Checkpointing does not track files modified by Bash commands."

This page explains what Claude Code's rewind restores, where it stops, how to recover what it misses, and how Darce's /undo handles the same cases.

What Claude Code /rewind restores

Claude Code takes a checkpoint before each prompt you send. To open the rewind menu, run /rewind or press Esc twice with an empty prompt. Pick a message, then choose:

  • Restore code and conversation: files and chat both go back to that point.
  • Restore conversation: the chat goes back, your files stay as they are.
  • Restore code: files go back, the chat stays.
  • Summarize from here or up to here: compresses the conversation without touching files.

Checkpoints are saved with the session, so /rewind still works after you resume. Claude Code keeps the most recent 100 checkpoints per session and deletes snapshots about 30 days after the session last saved one (configurable with cleanupPeriodDays).

What /rewind can't undo

From Claude Code's checkpointing docs, rewind does not restore:

  • Files changed by Bash commands, such as rm file.txt, mv old.txt new.txt or cp source.txt dest.txt.
  • Most subagent edits. Background subagents, including background forked skills, edit files that rewind won't put back.
  • Symlinked or hard-linked files, which includes files pnpm hard-links into place. They are skipped with a warning.
  • Changes made outside the session, by you or by another session.
  • Anything outside your machine: deploys, migrations, API calls, a git push. No local tool can undo these.

The first one is the one that hurts. An agent cleaning up "unused" files with rm -rf, renaming a folder with mv, or running a script that rewrites twenty files does all of it through the shell, and none of it is in the checkpoint.

How to recover what rewind missed

If Claude Code deleted or overwrote a file through the shell and you're in a git repository:

  1. The file was committed. Run git restore path/to/file (or git checkout -- path/to/file) to get the last committed version back.
  2. The file was staged but not committed. Run git fsck --lost-found. Staged content exists as a blob even if it was never committed.
  3. The file was never added to git. Git can't help. Check your editor's local history (VS Code Timeline, JetBrains Local History), Time Machine, or another backup.

None of this restores uncommitted work you had in progress before the agent ran. That's why the safest habit with any agent is to commit or stash before you hand it a task.

How Darce's /undo is different

Darce is an open-source terminal coding agent built around one rule: every change it makes should be reversible. Before every step that can change your project, Darce snapshots your working tree, including steps that run shell commands. So /undo also puts back what rm, mv, a formatter, a generator or an install did to your files.

~/acme-todos · a real session

A real Darce session: rm -rf deletes four files, /undo brings them back.

Claude Code /rewindDarce /undo and /rewind
Files the agent edited or wroteRestoredRestored
Files a shell command deleted, moved or changedNot restoredRestored (in a git repo)
package.json and lockfile after an installNot restoredRestored (in a git repo)
Untracked files (never committed)Only if edited by Claude's edit toolsRestored, unless gitignored
Rewind the conversation tooYesYes
Survives quitting and resumingYes, for about 30 daysNo, undo history lasts for the session
Outside a git repoEdit-tool changesEdit and Write changes only
Deploys, migrations, API callsNot undoableNot undoable, so Darce asks first

In a git repository, each snapshot is a commit object stored under private refs (refs/darce/<session>/…). It includes tracked and untracked files and respects .gitignore. Darce never touches your branch, your index or your stash. Snapshots are taken per step, not per prompt, so you can step back one command at a time.

Some honest limits:

  • Gitignored files aren't snapshotted. After undoing an npm install, package.json and the lockfile are back, but node_modules still has the package until you run npm install again.
  • Undo history doesn't survive quitting. Claude Code is better here. Darce removes its refs when the session ends.
  • Outside git, Darce can only undo its own Edit and Write changes, like Claude Code.

What no agent can undo

A deploy, a database migration, a git push, a message sent to an API, a package published to a registry: these happen somewhere else, and no local snapshot reaches them. Darce scores every command before it runs. Commands like these wait for your approval, and the prompt tells you that /undo can't reverse them. Everything else runs, because it can be taken back. See Safety for how commands are scored.

Try it

Run npx darce-cli in a git repository, ask it to delete a folder, then type /undo. Your first 10 requests are free with no account. It works with 250+ models, including Claude, so you can keep the model you like and add the undo. More: how undo works, Darce as a Claude Code alternative.

FAQ

Can Claude Code undo an rm command?

No. Claude Code's checkpoints only track files changed by its own file editing tools. Files deleted, moved or changed by Bash commands such as rm, mv or cp are not restored by /rewind. If the file was committed, git restore brings it back.

How do I undo changes in Claude Code?

Run /rewind or press Esc twice with an empty prompt, pick a message, and choose Restore code, Restore conversation, or both. This reverts edits made with Claude's edit tools since that message.

How long does Claude Code keep checkpoints?

Checkpoints are saved with the session and survive resuming. Claude Code keeps the 100 most recent per session and deletes snapshots about 30 days after the session last saved one, configurable with cleanupPeriodDays.

Is there a coding agent that can undo shell commands?

Darce, an open-source terminal coding agent, snapshots your working tree before every step, including shell commands, so /undo restores files that rm, mv, formatters or installs changed. It works in git repositories and respects .gitignore.