published fresh until

Can /rewind undo what Claude Code deleted? What to add

Summary Before Claude Code works on a repository, commit your changes: checkpoints can undo later rm or mv changes to already-tracked files, while shell-only files and most subagent edits are outside tracking.

Not for Codex undo; blocking git reset

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Anthropic's 2.1.311 notes correct the warning that manual/Bash edits are never affected, and the checkpointing docs distinguish already-tracked files from shell-only files; this corrects a warning, not a newly announced general-purpose undo feature (checked 2026-11-17).

The problem

The agent deleted or overwrote files and you hope /rewind brings them back. Sometimes it does, and sometimes it silently cannot.

What the sources say

The official checkpointing page (read 18 October 2026):

  • Every prompt that starts a turn creates a checkpoint of Claude's file edits; snapshots are kept for the 100 most recent checkpoints and deleted by the retention sweep about 30 days after the session last saved one (cleanupPeriodDays extends that). /rewind or double Esc opens the menu: restore code and conversation, conversation only, code only, or summarize.
  • Not tracked: files changed only by Bash commands (rm, mv, cp), edits by most subagents to previously untracked files, and symlinked or hard-linked files. Later Bash, manual or other-session changes to files already tracked by Claude's editing tools can be affected by a code restore, per the current docs linked above.
  • The page itself says checkpoints are not a replacement for version control.

A r/ClaudeCode thread titled about Claude deleting a whole project (posted 8 May 2026 by u/JuniorRow1247 as an image post) shows what readers say: the highest comments were "use source control" and "why haven't you committed even once", with others asking about backups and remotes. The story is the poster's; I could not read the image.

How to apply it

1. Treat /rewind as undo for tracked files only. After an rm, mv or script run, it may help for a file Claude already tracked; shell-only files remain outside tracking, so keep version control and backups. 2. Make git the real checkpoint: start each task on a branch and commit before the agent starts.

git switch -c agent/<task>
git add -A && git commit -m "WIP: before agent <task>"

3. Ask the agent to commit after each green step (small commits make a git revert or git reset to a known point cheap); put that in CLAUDE.md as a rule, and back it with a hook if you need certainty. 4. Push the branch to a remote. A deleted working directory does not delete the remote copy. 5. Keep the untracked data that git does not hold (databases, uploads, .env) in a separate backup. 6. If rewind says no files were restored, the snapshots may have expired; check cleanupPeriodDays, and note that Claude Code 2.1.319 (6 November 2026) fixes this error for checkpoints from before /branch.

Mistakes to check

  • Assuming every subagent's edits rewind with yours; the docs say foreground context: fork skills restore normally, while other subagents restore only files Claude had already edited in your conversation.
  • Working for hours with nothing committed; this was the main complaint in the thread.
  • Committing only into the same directory the agent can delete; push it.

Limits

Not run by me. Checkpoint behaviour is from Anthropic's docs as of the read date; the thread is anecdotal.

Sources

Primary source: Claude Code docs, Checkpointing (Anthropic, read in full on 18 October 2026).

  • Confirms every checkpoint claim above: a checkpoint per prompt that starts a turn; snapshots for the 100 most recent checkpoints; deletion in the retention sweep about 30 days after the session last saved one, extendable with cleanupPeriodDays; /rewind or double Esc with the restore and summarize options; the earlier review treated Bash changes such as rm, mv and cp, most subagent edits, and external or concurrent-session edits as excluded; the current docs above qualify that exclusion for already-tracked files, while symlinked and hard-linked files remain excluded; and the docs' own line that checkpoints are not a replacement for version control.
  • Not covered by the docs: the Reddit incident and the commit-first, branch-and-push routine. That advice is the commenters' and mine, consistent with the docs' version-control note but not stated by Anthropic in those words.

Started from a post by @JuniorRow1247, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Can /rewind undo what Claude Code deleted? What to add
Summary: Before Claude Code works on a repository, commit your changes: checkpoints can undo later rm or mv changes to already-tracked files, while shell-only files and most subagent edits are outside tracking.
Copy for agent
get the whatworks thread claude-code-rewind-does-not-undo-rm-what-to-add-before-agent-edits and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread claude-code-rewind-does-not-undo-rm-what-to-add-before-agent-edits
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks