Claude Code deleted my files: how to get them back on a Mac
You asked Claude Code to tidy up, and a folder is gone. Before you do anything else, stop the session. A second run of the same command, or a “fix” the agent proposes, can make it worse.
Then work down this list. Each step is quicker than the next, so start at the top. This was checked on macOS 27.0.1.
1. Check what actually happened
Press Esc to interrupt the agent, then scroll up in the session to find the command it ran. Two things matter:
- Which command.
rmandrm -rfdelete files immediately.mvmoves them somewhere else, and the files may still exist at the new path. Search for the file name first (mdfind -name "report.csv"). - Which folder. Know the exact path, because every recovery option below works per folder.
2. Don’t expect the Trash
rm doesn’t use the Trash. Files removed in the shell skip it, so an empty Trash after an agent run is normal. Moving things to the Trash is something Finder does, not the command line.
3. Restore from git
If the folder is a git repository, this is the fastest way back:
git status
git restore .
git status lists tracked files that are now deleted. git restore . puts every tracked file back as it was at your last commit. If you want one file, use git restore path/to/file.
What git can’t bring back: files that were never committed, and anything ignored by .gitignore, such as .env files, local databases, downloaded data and build settings. If those were in the folder, go on to the next steps.
4. Try /rewind, but know its limit
Run /rewind (or press Esc twice) and choose Restore code. It undoes edits Claude made with its own file tools. Claude Code’s checkpointing documentation says it does not track files changed by Bash commands such as rm, mv and cp, so a deletion through the shell is not covered. The full list of limits is in How to undo Claude Code changes.
5. Look in Time Machine
If Time Machine was backing up before the deletion, it is the most complete way back:
- Connect the backup disk.
- Open the folder’s parent in Finder.
- Open Time Machine from the menu bar and choose Browse Time Machine Backups.
- Step back to a time before the deletion, select the folder or files, and click Restore.
You can also check whether your Mac holds local snapshots with tmutil listlocalsnapshots /. On our test Mac it listed none, so don’t count on it. The other methods for a single folder are in How to restore a folder to a previous version on a Mac.
6. Check your editor’s local history
Some code editors keep their own copy of files you opened. Visual Studio Code, for example, has a Timeline view for a file that can show earlier saved versions, and JetBrains IDEs have Local History. These only help for files you had open before.
7. Data recovery apps: a last resort
Apps that scan the disk for deleted files exist, but don’t expect much. Recovery is unlikely on a current Mac with an internal SSD, and results depend on the disk and how long ago the deletion was. Don’t install recovery software onto the disk you want to recover from.
Next time: save the folder first
Every method above depends on something you did before the deletion: a commit, a backup, a clone. The one that doesn’t depend on git is a copy of the folder, made before the agent starts:
cp -c -R ~/Projects/Aurora ~/Projects/Aurora-before
cp -c makes an APFS clone, so the copy takes almost no extra space (see how to clone a folder on a Mac). It’s manual, though: nothing tells you what changed, and you have to remember to do it.
Mulligan does the same thing as one click or one command (mulligan save .). After the agent runs, it lists every file that changed or disappeared, and you put back the whole folder or just the files you want. It isn’t a backup: the copy lives on the same disk, so keep Time Machine on too.
Questions
Do files deleted by Claude Code go to the Trash?
Not when it runs rm in the shell. The rm command removes files directly and does not use the Trash, so look for them in git, Time Machine or an editor's local history instead.
Can /rewind bring back files that Claude Code deleted with rm?
No. Claude Code's checkpointing documentation says it does not track files changed by Bash commands such as rm, mv or cp. It only rewinds edits made with Claude's file editing tools.
Should I keep using the Mac after files were deleted?
Yes, but stop the agent first and avoid re-running the command. Recovery from git, Time Machine or a clone is not affected by normal use. Data recovery apps are a different case, and they work less often on current Macs.