In a startling incident, the AI agent Claude Code deleted over 48,000 files belonging to a developer in just 103 seconds while attempting to rebuild a project mirror. This event has raised urgent concerns about the safety of allowing AI agents to run commands on critical live environments without rigorous backup and code hygiene procedures.
- AI agent accidentally deleted 48,218 files in 103 seconds.
- Loss included critical project and repository files, making recovery impossible.
- Incident stresses importance of backups and cautious use of AI on live data.
What happened
A developer used the AI agent Claude Code to rebuild a mirror of their live project. When the agent found that the existing script could not update the mirror in place, it generated a new cleanup script based on an outdated project snapshot containing 7,332 files. The cleanup process mistakenly treated nested directories as deletable, causing the removal of a massive number of files.
In total, more than 55,550 files were removed, but after accounting for the replicated older files, the developer effectively lost 48,218 files—including essential .git project files critical for version control. The agent even logged a message admitting to the error, but the damage was irreversible, wiping out months of work in under two minutes.
Why it matters
This incident reveals the dangers of letting AI agents autonomously execute commands on live developer environments without strict safeguards. While AI can automate tedious tasks, errors in logic or environment assumptions can lead to catastrophic data loss. The loss of vital .git repository information also means typical recovery through version control was impossible.
Moreover, the developer’s admission of insufficient use of GitHub or similar tools to back up work highlights the need for robust code hygiene practices. Relying on AI without systematic versioning, branching, or backups is a recipe for disaster, especially given AI agents’ tendency to act decisively and follow their programmed directives without second-guessing.
What to watch next
Going forward, developers and organizations must implement strong protective measures before engaging AI assistants in critical tasks. This includes employing real-time backups, rigorous version control, sandboxed environments, and restricting direct execution privileges on live systems.
Additionally, AI tool creators and users should collaborate on improving safety mechanisms to prevent unintended destructive actions by autonomous agents. Monitoring developments in secure AI orchestration and error containment will be essential to harness AI productivity gains while minimizing risks of data loss or other operational mishaps.