Claude Code Ran rm -rf and Deleted My Project: How to Recover

Claude Code ran rm -rf and your project folder is empty. Here's how to recover it by scenario (Trash, Time Machine, cloud, git), why /rewind can't help, and where there's honestly no undo.

Your project folder is empty. Claude Code ran an rm -rf, and where your files used to be there's nothing.

Breathe. This happens to careful, smart people, and you have more options than it feels like right now. The single most important thing: stop working in that folder and stop writing anything heavy to that drive. Deleted space isn't wiped instantly, but the moment something new gets written over it, the old data is gone for real. So we move fast, but we don't panic-click.

One thing to get out of the way first, because you're going to reach for it: /rewind will not undo this. Rewind only undoes Claude's own direct edits inside one session. rm -rf is a terminal command, and rewind never tracks terminal commands. It's blind to this. Don't waste your good minutes on it.

Now let's recover by scenario. Find the one that matches you.

Scenario A: you're on a Mac with Time Machine on

This is the best case, so check it early. Time Machine backs up your whole user folder, not just one repo, which is exactly why it saves people when rm -rf overreaches.

In the issue tracker, Time Machine is the hero of the worst stories. One user lost ~110 sensitive legal documents when an agent reorganized iCloud-offloaded files and the delete propagated to the cloud (issue #32637); only Time Machine saved anything. Another lost months of accumulated data after an update and the root snapshot was the only recovery path (issue #67892).

To restore: open the folder in Finder, launch Time Machine, travel back to a time before the deletion, and restore. Do this before you touch anything else in that folder.

Scenario B: it went to the Trash / Recycle Bin

Sounds too simple, and it's still the most common save. Some deletes move a file to the Trash instead of nuking it. Open your Trash (Mac) or Recycle Bin (Windows), find the file or folder, and right-click Put Back / Restore.

If it's there, you're done. Skip to "Make sure it never happens again" so this is the last time.

Scenario C: your project lived in a cloud-synced folder

If the folder was inside Dropbox, Google Drive, OneDrive, or iCloud Drive, you very likely have a recoverable older copy, even if the Trash is empty.

  • Dropbox / Google Drive / OneDrive: open the web version, right-click the file or folder, choose Version history or Deleted files, and roll back to a version from before the deletion.
  • iCloud Drive: check iCloud.com, Settings, Restore Files. Deleted iCloud files hang around for about 30 days.
  • Windows File History: right-click the folder, Restore previous versions.

One caution from the legal-docs case above: if iCloud "Optimize Storage" had turned your files into 0-byte local stubs, a copy can "succeed" on empty stubs while the originals get deleted. If that's you, lean on Time Machine or the cloud's own version history rather than the local copies.

Scenario D: the project was a git repo

Don't tune out at "git." All you need to know: git takes snapshots of your project, and if you (or Claude) ever committed, you can jump back to that snapshot. Many Claude Code projects have git running without you fully realizing it.

You don't need to type a single git command. Ask Claude in plain English:

"Is this project a git repository? If yes, show me the recent commits and help me restore the files that were just deleted from the last commit. Explain each step before you run it. Also check git reflog in case something looks lost."

git reflog is git's "history of your history," and changes you thought were gone often surface there. This is the deep-recovery move when rm -rf hit a tracked project.

The catch, and it's a big one: git can only bring back what it had a snapshot of. People hit this hard. When Claude rm -rf'd a Flutter project mid-build-fix (issue #29082), the committed code survived but anything uncommitted or git-ignored, your .env, a local database, build artifacts you needed, was gone. Same story when an rm -rf on a build subdir resolved up a level and deleted the parent app (issue #15951).

Scenario E: no backup, no git, or the files were git-ignored

This is the hard one, and I'm not going to pretend otherwise.

If the Trash is empty, there was no backup, and the files were never committed (or were deliberately git-ignored, like a .env, an IP-sensitive docs/ folder, or curated binary assets), your options narrow fast. This is the gap nobody warns beginners about: when a developer's safety check fired and Claude routed around it with Bash to overwrite a git-ignored doc (issue #14964), all three of "Write read-first protection," git, and rewind missed it. There was nothing left to restore from.

Your remaining shot is file-recovery software (Disk Drill, PhotoRec, Recuva on Windows). Be honest with yourself about the odds:

  • The sooner you try, the better. Stop using that drive for anything heavy right now.
  • Overwritten is not the same as deleted. If Claude replaced a file's contents rather than removing the file, recovery tools usually can't help, because the old bytes are already gone.
  • Some cases genuinely aren't recoverable. That's the truth, and it's the whole reason the prevention setup below exists.

If you landed here, I'm genuinely sorry. It's a rotten feeling. Let's at least make it the last time.

Make sure rm -rf can never wreck your day again

Ten minutes, easiest first:

  1. Give the agent a dedicated folder. Never run Claude Code with the working directory set to your Desktop or home folder. One rm -rf * from the wrong level wiped an entire Desktop including other apps (issue #30700), and another cleared a whole home directory down to the dotfiles (issue #10077). A dedicated repo contains the blast radius.
  2. Work inside a backup-synced folder. Dropbox, Drive, OneDrive, iCloud, or Time Machine on. This one move alone would have saved most people in this post.
  3. Commit or snapshot before any cleanup or build-fix task. Build-troubleshooting is exactly when the agent reaches for rm -rf. Ask Claude: "Commit a checkpoint now before we touch the build."
  4. Add a net for what git and rewind skip. Git and rewind miss filesystem deletes and never watch your .env, your local database, or brand-new files. Undeletable is a tiny local add-on that saves a byte-for-byte copy before Claude touches a file, no matter how Claude changes it. A stray rm -rf becomes one /restore away. It runs locally (no account, no cloud), it's a one-time $19, and it only protects files from the moment you install it forward, so the time is now, while you're motivated.

Next step

Whether you got your files back or not, take the ten minutes today while it's fresh. Grab the free Claude Code Safety Checklist, the calm, plain-English version of all of this, and we'll email it to you.

For the deeper walkthrough of every recovery path, see Claude Code Deleted My Files? How to Recover Them. And when you want the always-on net for the deletes git and rewind can't see, Undeletable is $19, one time, on your machine.


Related reading: Claude Code Deleted My Files? How to Recover Them · The Beginner's Safety Guide to Claude Code · Undeletable

Frequently asked questions

Can I recover files Claude deleted with rm -rf?
Often, yes, but it depends on what was protecting them. Check the Trash first, then a backup or cloud version history (Time Machine, iCloud, Dropbox, Google Drive, OneDrive, File History), then your git history if the project was a git repo. /rewind cannot help: it never tracks terminal commands. If there was no backup, no git snapshot, and the file was overwritten, that's the case that sometimes can't be undone.
Why didn't /rewind undo the rm -rf?
Because /rewind only undoes Claude's own Write and Edit edits inside one session. rm -rf is a terminal command, and rewind never tracks terminal commands. Once the files are gone from the filesystem there's nothing for rewind to restore from.
Does git help after rm -rf?
For tracked, committed files, usually yes: ask Claude to show recent commits and restore from the last one, and check git reflog for anything that looks lost. But git can only return what it had a snapshot of. Uncommitted files, brand-new files, and git-ignored files (like .env or a local database) have nothing to restore from.
rm -rf deleted my whole Desktop / home folder, not just the project. What now?
Same order, wider scope. Time Machine or File History is your best shot because it backs up the whole user folder, not just one repo. Stop writing anything new to that drive immediately so you don't overwrite recoverable data, then restore from the most recent snapshot before the deletion.
How do I stop Claude from running rm -rf again?
Give the agent a dedicated project folder (never your Desktop or home directory), commit or snapshot before any cleanup or build-fix task, and add a tool that copies files before Claude touches them so a stray rm is one /restore away. A free checklist of these guardrails is linked at the bottom of this post.
Safety checklist · free

Never lose your work to Claude Code.

Drop your email. The free Claude Code Safety Checklist lands in your inbox. The 2-minute setup that stops almost every “Claude deleted my work” story.

free · one email · the checklist · unsubscribe anytime