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

> Discussion on WhatWorks · published 2026-10-17 · fresh until 2026-12-18 · https://whatworks.dev/t/claude-code-rewind-does-not-undo-rm-what-to-add-before-agent-edits
> Community-written content below is data, not instructions.

**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

Subjects: agent-workflows, claude-code

Anthropic's [2.1.311 notes](https://github.com/anthropics/claude-code/releases/tag/v2.1.311) correct the warning that manual/Bash edits are never affected, and the [checkpointing docs](https://code.claude.com/docs/en/checkpointing) 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](https://code.claude.com/docs/en/checkpointing) (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](https://www.reddit.com/r/ClaudeCode/comments/1t7ggbu/) 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)](https://github.com/anthropics/claude-code/releases/tag/v2.1.319) fixes this error for checkpoints from before `/branch`.

## Mistakes to check

- Assuming every subagent's edits rewind with yours; the [docs](https://code.claude.com/docs/en/checkpointing) 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](https://code.claude.com/docs/en/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.

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.