Claude Code Deleted My Files: How to See What It Changed
If an AI coding agent just deleted files you needed, start with the checks below: most of them work in the next five minutes, without installing anything. After that, this post covers why agent deletions are so easy to miss, a few real cases from the last weeks, and how to see every file an agent touches the next time.
What to check right now
Work through these in order. Each one recovers a different kind of loss.
- Git, for tracked files.
git statuslists what is missing or changed,git diffshows the exact lines, andgit restore <path>brings a deleted tracked file back. If history itself was rewritten,git reflogstill lists the commits your branch pointed to. - Git, for staged but uncommitted work.
git fsck --lost-foundwrites the contents of files that were staged withgit addbut never committed into.git/lost-found/. The file names are gone, the contents usually are not. - Your editor's local history. VS Code keeps earlier versions of files you saved in it. Open the Timeline view in the Explorer and look for Local History entries.
- Snapshots and backups. A filesystem snapshot (btrfs, ZFS, LVM) or a backup of the machine is the only way back for files that were never in git and never opened in an editor.
git status # what is missing or changed git diff # the exact lines git restore <path> # bring back a deleted tracked file git reflog # commits a rewrite left behind git fsck --lost-found # staged content that was never committed
Two things that do not help. rm does not use the trash, so there is nothing to undelete there. And Claude Code's own /rewind only covers files Claude edited with its file editing tools: according to the checkpointing documentation, a file that only Bash commands such as rm, mv or cp changed is not tracked and cannot be restored that way.
Why agent deletions are easy to miss
The hard part is often not restoring the files, it is knowing which ones are gone. Several things work against you.
- The summary says nothing. An agent reports what it set out to do. A deletion it did not intend rarely makes the summary.
- Tests stay green. One developer described a 40-minute loop on a billing webhook that "shipped clean code, tests green, then i noticed it quietly deleted the retry logic." Tests check what is there, not what disappeared.
- Deny rules match commands, not effects. A rule that blocks
rmdoes not stop the same deletion done another way. One user tried seven ways to delete a folder against a deny-rm rule: plainrmwas blocked, python and a script file deleted it anyway. Another reported an agent that wrote a file deletion into a test harness, inside a heredoc the rm deny rules did not match, and ran it. - The transcript may be gone too. Claude Code removes old session data in a retention sweep, by default about 30 days after a session was last used. The record of what the agent did can disappear before you go looking for it.
Real cases from the last few weeks
These are first-person reports from public issue trackers and forums, not hypotheticals.
- A
find $T -type f -deletewith the variableTunset, which deleted an entire git checkout. - Asked to move a version-control root, an agent deleted the source code and the git repository on a VPS.
- A self-test's
rm -rffollowed a symlinked sibling repository and deleted the real.git. - On an Arch Linux laptop, "Suddenly Linux stops working … Claude code deleted the entire home folder."
- Left running without hooks, an agent deleted a developer's entire Supabase row-level security setup. It was the opening story of a thread titled "What's y'alls worst Claude Code incident? Deletion, bypassing, etc.", which collected many more.
None of these was malicious. Most were a reasonable command run in the wrong place: an empty variable, a symlink, a misread instruction. That is exactly why they are hard to predict and easy to miss.
How to see it next time
Every recovery step above starts with the same question: what exactly changed? kaimon answers it for AI coding agents on Linux.
- It records every file an agent changes or deletes, in the Linux kernel, with no hooks and no agent plugins. A deletion is recorded no matter which command did it:
rm,find -delete, a python script or a heredoc the deny rules never saw. - Each change is attributed and risk-rated. You see the agent, the tool it worked through and the file, with the event and its size. Deletions are flagged by risk category: MASS DELETE for recursive deletes, FILE DELETE for individual files, and LOG TAMPERING when an agent's own session transcript or a log disappears.
- You see it where you work. The VS Code status bar shows the count and severity, a hover lists the top findings, and the panel shows the findings with the files behind them. A report in HTML and JSON keeps the evidence.
- The record is tamper-resistant. kaimon runs as a root daemon, so an agent working as your user can read the record but not change or delete it.
What it does not do, stated plainly: kaimon observes and reports, it never blocks a deletion. It does not keep copies of your files, so it tells you what to restore rather than restoring it. It records from the moment it is installed, and keeps up to the last two days on your machine. It runs on Linux, including a Linux dev box or VM you work on from macOS or Windows over VS Code Remote-SSH.
Always free and 100% local: nothing leaves your machine. See how it works.
Making the next one smaller
- Commit before you hand over a task. A clean working tree turns most deletions into one
git restore. - Give the agent a smaller world. A container, a VM or a dedicated dev box limits what a wrong command can reach. A home folder with no backup is the worst place to run an agent with broad permissions.
- Treat deny rules as a speed bump, not a boundary. They match command text; the same effect has many spellings.
- Watch shared files when agents run in parallel. Two sessions writing the same file can silently overwrite each other's work.
FAQ
Can Claude Code's /rewind bring back a file it deleted with rm?
Only if Claude had edited that file with its own file editing tools earlier in the session. Checkpoints track those files, and rewind also undoes later Bash changes to them. A file that only a Bash command such as rm, mv or cp touched is not tracked, so rewind cannot restore it. Use git, editor local history, snapshots or backups.
Can kaimon restore deleted files?
No. It records every file an agent changes or deletes, with the agent, tool, path and size, so you know exactly what to restore and from where. It does not keep copies of file contents.
Does kaimon stop an agent from deleting files?
No. It observes and reports, and never interferes, so it cannot break an agent's workflow.
Does kaimon work on macOS or Windows?
kaimon runs on Linux hosts, which includes a Linux dev box or VM you work on from macOS or Windows through VS Code Remote-SSH.