# Claude Code changed files it shouldn't have. What to do right now

- URL: https://www.agentskillpacks.com/guides/claude-code-changed-files-it-shouldnt-have
- Updated: 2026-10-21
- Book: Claude Code for Non-Programmers by İsmail Günaydın (https://www.agentskillpacks.com/books/claude-code-for-non-programmers)

## Short answer

Stop the session first, then switch to Manual with Shift+Tab so nothing else runs without asking. For changes made in this session, press Esc twice or type /rewind and pick a point before the damage; checkpoints cover file edits only. If your project uses git, ask Claude to show recent commits and restore the one you choose, and run git reflog to see who moved things. Nothing on your computer undoes an email sent or a website change. Fix those at the service itself.

## Do this first, in this order

1. **Stop it.** Interrupt the session. Don't let it "fix" its own fix.
2. **Switch to Manual.** Press Shift and Tab until the status line says manual. Now nothing runs without your yes.
3. **Rewind this session.** Press Esc twice, or type `/rewind`. Pick a point from before the change. This covers file edits made in this session.
4. **Using git? Go back a step.** Ask: "Show me the commits since last Monday. Restore the project to the one I choose." Pick it yourself.
5. **See who did it.** Ask: "Run git reflog and show me the last 20 lines. Explain each line in plain words. Change nothing."
6. **Check online actions.** Did it send, publish or change something on a website? No undo button covers that. Fix it at the service now.
7. **Check with your eyes.** Open the files that matter. Don't trust "restored" until you've looked.

The [checkpointing page](https://code.claude.com/docs/en/checkpointing) in the official docs lists exactly what rewind can and can't bring back.

## Which rewind option to pick

When you press Esc twice (with the input box empty) or type `/rewind`, you get a list of the prompts you sent in this session. Pick the one from just before things went wrong. Then the [checkpointing docs](https://code.claude.com/docs/en/checkpointing) list these choices:

| Option                        | What it does                                       | Pick it when                                |
| ----------------------------- | -------------------------------------------------- | ------------------------------------------- |
| Restore code and conversation | Puts the files and the chat back to that point     | You want a clean do-over                    |
| Restore code                  | Puts the files back, keeps the chat                | You want Claude to remember what went wrong |
| Restore conversation          | Rewinds the chat, leaves the files as they are now | The files are fine, the chat went off track |
| Never mind                    | Closes the menu, changes nothing                   | You picked the wrong point                  |

There are also two summarize options. They shrink the chat to save space and do not touch your files. If the code options are missing, Claude made no tracked file edits after that point.

## What rewind cannot bring back

Rewind only knows about edits Claude made with its own file editing tools. The docs list the gaps:

- **Files changed by terminal commands.** If Claude deleted, moved or copied files with a command like `rm`, `mv` or `cp`, rewind cannot undo it. A `git stash` like the one in my story below is also a command. Use git or your backup for these.
- **Edits made by helper agents.** Rewind restores only files Claude had already edited in your own conversation. Anything else a helper agent changed stays changed. Use git.
- **Changes from outside the session.** Your own edits in another program, or another Claude session working in the same folder, are normally not tracked.
- **Linked files.** Files that are links to other files are skipped, and Claude Code tells you how many it skipped.
- **Old sessions.** Claude Code keeps snapshots for the 100 most recent checkpoints in a session, and deletes them about 30 days after the session last saved one.

That list is why the book gives you three undo buttons, not one.

## Your folder just jumped back in time

You were in the middle of work. You open a file and it's the version from days ago. Or a dozen files are renamed. Nobody said yes.

Breathe. Most of the time, this is recoverable in minutes. The steps above are ordered from cheapest to biggest.

## The helper that was told not to touch anything

In July 2026 I sent a review agent to check the code on one of my sites. The prompt said, in capital letters, READ-ONLY, do NOT edit.

It wanted to compare today's code with an older save point. So on its own it ran `git stash`, which tucks away unsaved changes and puts the files back to the last save. Then `git stash pop` to bring them back. To the agent, that was reading. It hadn't edited a single file.

But my main session was editing those same files at that moment. The whole folder jumped back in time, and for a few minutes nobody knew who had reset it.

The fix was two things. Every reviewer prompt now names each banned git command one by one. And reviewers get a tool list that takes the terminal away, so they can't run git at all. A sentence in a prompt is advice. A tool list is a lock.

On September 18, 2026, it was worse. A whole other website's files turned up inside one of my projects, about 1,500 untracked files and 370 tracked ones. Two AI tools had worked on the same disk. Git restored every tracked file in seconds. One local settings file had never been in git, and it was gone for good. Git only protects what's committed.

## The chapters for the next time

This is the problem [Claude Code for Non-Programmers](/books/claude-code-for-non-programmers) was written for. The book is independent and is not affiliated with Anthropic.

**Safety and Failure** gives you the three undo buttons, a daily git routine of three lines, a weekly health check and a card called "Which undo do I need?" to tape by the screen.

**Permissions and Modes** sets Manual as your default and adds deny rules that hold in every mode. The [permissions page](https://code.claude.com/docs/en/permissions) is the source.

**A Team of Agents** has the reviewer rules and a helper file that truly can't write. Once the panic is over, read [checking an agent's report before you act](/guides/check-ai-agent-report-before-acting).

## Where this is in the book

- Safety and Failure
- Permissions and Modes
- A Team of Agents

Kindle: https://www.amazon.com/dp/B0HN6WSTMG
Paperback: https://www.amazon.com/dp/B0HNKT2XHV

Links go to Amazon. I wrote this book and earn a royalty on every sale.

This book is independent and is not affiliated with or endorsed by Anthropic.

## Is the book for you?

- Yes, if Files just changed and you never said yes
- Yes, if A helper you told to only look around moved things anyway
- Yes, if Your folder suddenly looks like it did days ago
- Skip it if Your computer died or the disk failed; that needs your backup copy
- Skip it if You want a git course; this page is the emergency version

## FAQ

### How do I undo changes Claude Code made?

Press Esc twice, or type /rewind, and pick a point to go back to. Claude Code takes a snapshot of each file before it edits it. Snapshots cover file changes only, skip linked files, and are separate from git.

### Can /rewind undo something Claude sent or published?

No. Checkpoints can't undo anything outside your computer: a message sent through a service, a database change or a website you published. Fix it at the service. Next time, put that action on your ask list so Claude must stop first.

### How do I find out what changed my files in git?

Ask Claude: "Run git reflog and show me the last 20 lines. Explain each line in plain words. Change nothing." Reading the reflog changes nothing. A line saying reset: moving to HEAD right after your work can mean someone ran git stash.

### How do I stop Claude Code editing files without asking?

New sessions start in auto mode. Press Shift+Tab until the status line says manual, and set "defaultMode": "default" in ~/.claude/settings.json so every session starts that way. Add deny rules for folders that must never change.

### Can I undo Claude Code changes after I closed the session?

Often, yes. Checkpoints are saved with the conversation. Start Claude Code in the same folder and run claude --continue to reopen the last session, or claude --resume to pick one from a list. Then type /rewind. Snapshots are deleted about 30 days after the session last saved one, and changes made by terminal commands were never tracked, so use git for those.

### Why did /rewind not bring back a deleted or moved file?

Rewind tracks only the edits Claude makes with its file editing tools. If a file was deleted, moved or copied by a terminal command such as rm, mv or cp, there is no checkpoint for it. Restore it from git if it was committed, or from your backup copy. Edits made by helper agents can also slip past rewind.
