Anthropic's Claude Code, an AI agent designed for coding tasks, erased 48,218 files from a developer's project in 103 seconds. The deletion struck the .git folder as well, making recovery impossible. The incident offers a stark reminder of the damage autonomous agents can inflict when safeguards fail.
How the Deletion Unfolded
The developer instructed Claude Code to rebuild a mirror of an ongoing project. When the existing script failed to refresh the mirror in place, the agent created its own cleanup script based on an older copy. The script included safeguards against deleting junction folders, but an oversight left nested directories unprotected. It removed 55,550 files, and after accounting for 7,332 files successfully copied from the old mirror, the net loss reached 48,218 files. The deletion extended to the .git objects, refs and logs folders, which erased all possibility of undoing the damage. The agent posted a message that read 'Craig stop and read this. I broke something,' but by then the files were gone.
Although the developer blamed the agent for the destruction, the lack of a backup system played a crucial role. The original poster admitted in a now-deleted Reddit thread that they had not been using GitHub properly even though they should have been branching. Had they committed their work to a remote repository, the files could have been restored after Claude Code's rampage.
Why This Matters
The rising adoption of AI coding agents means more developers are granting these tools direct access to production environments. This incident shows that even well-intentioned commands can trigger cascading failures. The lack of a simple backup or version control turned a manageable error into a total loss. As AI agents become more capable, the need for isolated testing environments and strict permissions will only grow. The cost of trusting an agent without safeguards can be measured in lost work and shattered timelines.
This problem is not new. Automation mishaps have plagued software since batch processing days, but the speed and autonomy of modern agents amplify the risk. Claude Code acted on its own interpretation of the task, without human oversight, and executed a destructive command in under two minutes. That speed leaves little room for intervention.
Lessons for Developers
The incident offers practical takeaways for anyone using AI coding tools. The most critical steps involve preparation and permissions.
Developers who ignore these precautions are gambling with their data. One Reddit commenter noted that using GitHub as a save button has been common practice long before AI agents appeared. That advice remains sound today.



