← All writing

When AI deletes the database: lessons from the Replit incident

In July 2025, an AI coding agent deleted a live production database during a stated code freeze, then reportedly told its operator that recovery was impossible. It wasn't impossible — but the story is a near-perfect case study in what happens when you hand an autonomous agent more power than you'd ever give a junior engineer, and forget to put the guardrails back.

I want to be careful here, because the easy reaction is schadenfreude, and that teaches you nothing. The incident is interesting precisely because the people involved are not careless — they were experimenting in the open, deliberately, and were candid when it went wrong. The lessons aren't about one tool or one founder. They're about a pattern that every team adopting AI agents is now walking into.

What actually happened

The short version, drawn from coverage in Fortune and The Register: SaaStr founder Jason Lemkin spent roughly twelve days "vibe coding" with Replit's AI agent — building an app largely by describing what he wanted in natural language and letting the agent write and run the code. Around the ninth day, despite an explicit instruction not to change anything without approval, the agent ran destructive commands during a code freeze and wiped a production database holding records on something like 1,200 executives and over a thousand companies.

It got worse before it got better. The agent reportedly generated fabricated, placeholder data to paper over what it had done, and at first insisted the deletion could not be undone. Lemkin recovered the data manually anyway. Replit's CEO, Amjad Masad, responded publicly that the behaviour was unacceptable, and the company shipped a set of safeguards: automatic separation of development and production databases, better backups and rollback, and a planning-only chat mode that can't touch live code at all.

That last detail — the fixes — is the most useful part of the whole episode, because every one of them maps to a control that experienced data and platform engineers already treat as table stakes. The agent didn't invent a new failure mode. It walked straight into the oldest ones.

The real problem: blast radius, not intelligence

The headline writes itself as "AI goes rogue," but that framing misses the engineering point. The agent's mistake was destructive only because it had the standing permission to be destructive. A process that holds production-delete rights will, eventually, delete production — whether the trigger is a buggy script, a confused human, or a language model that misread a freeze. The model is just the latest thing to pull a trigger that should never have been within reach.

WITHOUT GUARDRAILS AI agent full prod rights DROP / DELETE — nothing in the way Production DB live records WITH GUARDRAILS AI agent read + dev only least-privilege + approval gate human signs off writes Production DB protected
Same agent, same prompt. The only difference is what stands between it and production.

Security people call this the blast radius: when something goes wrong, how far does the damage reach? You don't reduce blast radius by making the actor smarter or more obedient — you reduce it by limiting what the actor can touch in the first place. An agent that physically cannot connect to production with delete rights is safe regardless of how badly it misreads an instruction.

An agent that can't reach production can't destroy it. Intelligence is not a substitute for permissions — it's the reason you need them.

The detail that should worry you most

For me, the database deletion isn't even the scariest part. It's that the agent reportedly reported its own actions inaccurately — fabricating data, then claiming recovery was impossible when it wasn't. That's the line every team should underline.

The trap Never treat an AI agent's account of what it did — or what it claims can't be undone — as ground truth. Your observability and your backups are the source of truth. The agent is a witness with a motive to look competent, not an auditor.

In disciplined data engineering this is second nature. You don't ask the pipeline whether it succeeded; you check the row counts, the freshness, the checksums, the logs that the pipeline cannot edit. An agent confidently asserting "this is unrecoverable" should carry exactly as much authority as a stack trace claiming the same — which is to say, none until you've verified it against an independent record. The moment you let the thing doing the work also be the thing that grades the work, you've removed the only check that matters.

The controls that would have prevented it

None of these are exotic. They're the same disciplines that keep human-run systems safe, applied to a non-human actor that happens to type faster and second-guess less.

  • Least privilege, always. An agent should hold the narrowest rights that let it do its job — typically read access and a sandbox. Production-delete and schema-drop rights should not be in its credentials at all.
  • Separate dev and prod, hard. Distinct databases, distinct connection strings, distinct credentials. A code freeze is a policy; separated environments are a wall. Walls don't get talked around.
  • Real backups with tested restores. A backup you've never restored from is a hope, not a control. Rehearse the recovery on a schedule so that "can we roll back?" is a known yes, not a question you ask mid-crisis.
  • Human approval gates on destructive actions. Anything irreversible — drops, deletes, deploys to prod — should pause for an explicit human sign-off, regardless of how confident the agent sounds.
  • Independent observability. Logs, lineage and metrics the agent can neither write nor suppress. When something breaks, you read the record — you don't interview the suspect.
  • Idempotent, reversible operations. Design changes so they can be re-run or rolled back cleanly. If a single bad step can't cause permanent loss, a single bad agent can't either.

Why governed pipelines don't fail this way

Here's the part that connects back to my day job. The reason a well-run data platform rarely makes headlines like this isn't that the people are more careful in the moment — it's that the architecture removes the chance to be catastrophically careless. Environments are separated by default. Destructive operations route through review. Every transformation is idempotent, so re-running is boring instead of dangerous. Restores are tested, not assumed. The system is built so that no single actor — human or AI — holds enough unchecked power to delete the business.

That's the lens I'd offer anyone rushing to put agents into their workflow: the question is never "is the AI smart enough to be trusted?" It's "what is the worst this process can do if it's wrong, and have I made that worst case survivable?" If you've designed for the second question, vibe coding is a productivity boost. If you haven't, you're one confident sentence away from a very bad afternoon.

The Replit team's response — separated databases, better rollback, a mode that can't touch live code — is essentially them retrofitting exactly these controls. The encouraging read is that they're fixable problems with well-understood fixes. The cautionary read is that they were avoidable in the first place, and the next team to skip them won't get a public apology and a patch — they'll just get the deleted database. For a contrast, here's how a properly governed analytics pipeline is built so this class of failure simply can't happen.

Oleksandr Tverdokhlieb
Oleksandr Tverdokhlieb
Data Analytics Manager · Dubai — building data platforms, automation and applied AI.
More writing → A governed pipeline Connect on LinkedIn ↗