~ / guides / deleted-files

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.

freeze

2. Do not run more writes

A recovery attempt can overwrite evidence or make undelete tools less useful.

preserve

3. Copy the repo

If possible, make a read-only copy of the damaged folder before attempting repair.

snapshot

Quick Recovery Checklist

These steps are deliberately boring. Boring is good when your work is on fire.

CheckWhat to look forWhy it matters
Git statusDeleted, modified, untracked, and renamed filesShows whether the damage is tracked and reversible
Recent shell historyRemove, move, clean, overwrite, format, or generated-file commandsFinds the exact action that caused the loss
Editor local historyVS Code, JetBrains, Cursor, or system file historyMay recover files that were not committed
Cloud sync historyOneDrive, Dropbox, iCloud, Google Drive, NAS snapshotsCan restore non-git assets and documents
Build output foldersGenerated files mixed with source foldersAgents 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.

path risk

Over-broad cleanup

A command meant for one cache, build folder, or temp directory matches too much.

scope risk

Context drop

The agent forgets the constraint that a folder is precious, external, linked, or manually edited.

memory risk

False confidence

The agent reports that a command is safe without verifying the resolved path.

trust risk

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.

baseline

Require delete approval

Any recursive delete, move, cleanup, or generated-file purge should show the resolved absolute path first.

approval

Separate scratch space

Keep agent-generated experiments away from source, assets, documents, and manually curated data.

isolation

Ask for a dry run

Before a destructive command, make the agent list affected files and explain the boundary.

evidence

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.