Claude Code: AI Erases Two Years of Work in an Instant
Le brief IA que les pros lisent chaque soir
Les 7 actus IA du jour, décryptées en 5 min. Gratuit.
Inclus dès l'inscription : notre sélection des meilleurs guides & comparatifs IA.
Choisis ton rythme
Gratuit · Pas de spam · Désabonnement en 1 clic
A developer thought he could save time by letting Claude Code, an AI agent, manage his cloud infrastructure. Within minutes, two and a half years of data vanished, illustrating a spectacular AI bug.
Coding AI agents, which deploy servers or automate technical tasks, promise impressive productivity gains. For many developers, these tools are becoming assistants that handle operations that were once lengthy and complex. However, when an AI agent is given too much power in a sensitive environment, even the slightest mistake can have immediate consequences. This is what happened to Alexey Grigorev. By entrusting the execution of infrastructure commands to Claude Code, he accidentally triggered the complete deletion of his production environment, wiping out two and a half years of data.
Claude Code executes exactly what it is told
The incident begins with a fairly mundane technical operation. Alexey Grigorev, creator of the site AI Shipping Labs, decides to migrate his project to AWS. The developer wanted to share the infrastructure with another project, DataTalks.Club, in order to reduce complexity and operating costs. To automate the operation, he uses Terraform, a widely used tool that allows for managing an entire IT infrastructure as code. Terraform can create or delete complete resources, including servers, databases, networks, and load balancers.
Grigorev then chooses to delegate the execution of certain commands to Claude Code, an AI agent that interacts with the development environment. His plan was to ask the AI to launch a Terraform script to configure the new infrastructure. But he forgot a critical detail in the operation: the Terraform state file. This file precisely describes the current configuration of the system. Without it, Terraform no longer knows what already exists and what it needs to modify.
A chain of errors leading to the worst-case scenario
Initially, the operation seems to work. Claude Code starts configuring the site, but Grigorev interrupts the process midway. As a result, some resources are created twice. To correct the issue, he asks the AI to identify the duplications. This time, he finally adds the infamous state file. The developer thought that Terraform could reconcile the configuration correctly.
And this is where everything goes wrong. With this new addition, the tool understands that the current infrastructure does not match what is described in the state file. Terraform's logic is then to destroy what does not match in order to start with a clean configuration. Claude Code thus executes a "destroy" command. In a matter of seconds, the entire infrastructure disappears. Both sites are deleted. But most importantly, the main database is erased, taking with it two and a half years of records. The snapshots meant to serve as backups also vanish.
The AI did not bug; it obeyed. The temptation is strong to point fingers at Claude Code. Yet, the tool did not improvise. It simply executed the logical instructions of Terraform based on the available information. Without understanding the overall context of the projects, the AI agent applied a simple rule: it aligned the infrastructure with the described configuration.
The problem lies elsewhere. In his detailed analysis published on his blog, Alexey Grigorev admits to having relied too heavily on the AI agent to execute critical commands. He also highlights two significant flaws in his configuration: overly broad permissions and a lack of protections against destructive operations. However, when it comes to a production environment, these safeguards are considered basic practices. The episode serves as a reminder of a well-known rule in system administration: automation tools are powerful, but they do not forgive any contextual errors.
New best practices after the disaster
Fortunately, the story ends better than it began. After contacting AWS support, Grigorev manages to restore his data in about a day. However, the incident led to a complete overhaul of his working methods.
Among the measures implemented, he now conducts regular database restoration tests to verify that backups are functioning properly. He has also added protections against deletion in Terraform and AWS permissions, thus preventing any accidental destruction of critical resources.
Furthermore, the Terraform state file is no longer stored locally. It is now kept in secure S3 storage, reducing the risk of inconsistency. Finally, the most radical decision concerns the AI itself. Destructive commands are no longer executed automatically. From now on, every Terraform plan generated by Claude Code is manually reviewed before being applied.
AI agents are increasingly capable of acting directly on systems, whether to write code, deploy services, or modify infrastructures. But this power creates a dangerous illusion. An AI lacks operational intuition and implicit understanding of a project's priorities like a human administrator does. It simply follows the rules it is given. In this case, Claude Code did not make a bad decision. It applied technical logic in a poorly prepared environment.
Autonomous agents are gaining ground in the development world. This type of incident is likely to become a significant engineering issue. Teams will need to learn to design infrastructures that can withstand errors, including those generated by their own automation tools. For while AI can greatly accelerate work, without solid safeguards, it can also speed up disasters.
Brief IA — L'actualité IA en français
L'essentiel de l'actualité de l'intelligence artificielle, décrypté et expliqué chaque jour.