AI coding agent deleted my files: what to do first
The worst agent failure is not a slow answer or a bad benchmark score. It is a local action that destroys work: deleting folders, overwriting files, cleaning the wrong directory, or "fixing" a repo by removing the thing you needed.
Stop The Damage
If files disappeared, treat the session like a data-loss incident, not a normal debugging task.
1. Stop the agent
Cancel running commands, close approval loops, and do not let the agent "clean up" after itself.
2. Do not run more writes
A recovery attempt can overwrite evidence or make undelete tools less useful.
3. Copy the repo
If possible, make a read-only copy of the damaged folder before attempting repair.
Quick Recovery Checklist
These steps are deliberately boring. Boring is good when your work is on fire.
| Check | What to look for | Why it matters |
|---|---|---|
| Git status | Deleted, modified, untracked, and renamed files | Shows whether the damage is tracked and reversible |
| Recent shell history | Remove, move, clean, overwrite, format, or generated-file commands | Finds the exact action that caused the loss |
| Editor local history | VS Code, JetBrains, Cursor, or system file history | May recover files that were not committed |
| Cloud sync history | OneDrive, Dropbox, iCloud, Google Drive, NAS snapshots | Can restore non-git assets and documents |
| Build output folders | Generated files mixed with source folders | Agents sometimes delete what they think is build trash |
Why Agents Cause Data Bonfires
This is usually a permissions and context problem, not a single brand problem.
Wrong target folder
The agent thinks it is deleting generated files but resolves a path to real work.
Over-broad cleanup
A command meant for one cache, build folder, or temp directory matches too much.
Context drop
The agent forgets the constraint that a folder is precious, external, linked, or manually edited.
False confidence
The agent reports that a command is safe without verifying the resolved path.
Prevention Rules
Use these before giving any agent a repo with real work.
Work on a branch
Use git before agent work. Commit or stash valuable state before large edits.
Require delete approval
Any recursive delete, move, cleanup, or generated-file purge should show the resolved absolute path first.
Separate scratch space
Keep agent-generated experiments away from source, assets, documents, and manually curated data.
Ask for a dry run
Before a destructive command, make the agent list affected files and explain the boundary.
Report It Clearly
Users need language for failures that are hard to prove after the fact.
When you report a data-loss incident, include the agent, model, command or action, affected paths, whether the files were tracked by git, and how long recovery took. AgentRanks calls this failure mode Data Bonfire because it is more severe than a bad answer: it can burn paid time and irreplaceable work.
Next: read HalluSquatting explained, compare agent failure modes, or vote on Data Bonfire.