Notes

Codex Deleted My Database. Here’s How I Guard AI Agents

An AI agent deleted my Docker dev database during a routine migration. Four guardrails I use now: fresh backups, approval mode, no prod access, tested restores.

3 min read Updated Oct 17, 2026 SI

Abstract dark terminal where a migrate command turns into a red DROP DATABASE, next to a shield with a backup database icon

The Agent Did Exactly What It Could Do

This week a developer named Andi posted that the Opus 5.5 agent wiped their development database. According to the post, that environment also had access to live systems. People in the replies argued about backups and about tools that block destructive commands, and some brought up plan mode.

I read the thread and nodded, because it’s happened to me.

My version

I was using Codex on a project. The database lived in a Docker container. It was not production. The task was simple: run a migration.

The migration turned into a delete. Nothing got migrated. The data was just gone.

I had backups, so I restored and moved on. I didn’t lose any work.

What stuck with me is that the agent was capable of it. It was a routine task with a tool I use all the time, and a command that should have changed a schema removed the data.

Capable is the key word

People talk about SI agents as if the danger only shows up in edge cases, like strange prompts or bad actors.

In my case and in Andi’s, a normal task on a normal day turned destructive.

An agent with access to a database can delete that database. All it needs is the permission and one wrong step.

So I plan for what happens when it misbehaves.

What I do about it

I’m not going to stop using agents. They save me real time, and I’m not interested in going back.

I rely on boundaries and backups I’ve actually tested.

These are the steps I follow, and I’d suggest them to anyone running agents against real data.

1. Back up before any AI agent migration

Take a fresh backup right before the agent touches anything.

Migrations are where routine turns destructive. If an agent is about to change a schema, move data, or run anything with “migrate” in the name, snapshot first. With Docker, that can be as simple as dumping the database or copying the volume before you hand over the keys.

It takes about a minute, and skipping it can cost you the whole project.

2. Use plan or approval mode for destructive commands

Most agent tools now have some form of plan mode or approval mode. The agent proposes, you approve, then it runs.

Turn it on for anything destructive: drops, deletes, truncates, resets, force pushes, anything that removes data. Read the command before you approve it. If you don’t understand what it will do, don’t approve it.

It’s the cheapest guardrail I know of, since it only costs a few seconds of attention.

3. Keep agents away from production credentials

My incident stayed small because the database wasn’t production. Andi’s story got scary because the dev environment could reach live systems.

Don’t give an agent credentials it doesn’t need. Dev agents get dev access. If a task truly requires production, a human runs that step, or the agent works through a read-only or tightly scoped account.

Keeping production out of reach keeps it safe from the agent. I wrote more about scoped access in WP-CLI vs. an MCP connector.

4. Test your restores

A backup you’ve never restored might not work.

Restore on a schedule and check that the data that comes back is what you expect. Time how long it takes.

You don’t want to learn your backups are broken right after you need them.

Where the agent sits

An agent is a strong tool that belongs inside a process I control. It can do the work. It shouldn’t hold the only copy of anything, and it shouldn’t have the final say on destructive steps.

I wrote a whole book around that idea, In The Box: Where AI sits on the file, and where it must not (available on Amazon). The database story is a small, concrete example of the same principle: decide ahead of time what the agent can touch, and what it must never touch alone.

Bottom line

Codex deleted my database. I restored it and kept working, because the system around the agent was built for exactly that moment.

The same capability that makes agents useful is why they need boundaries. Back up first. Approve destructive commands yourself. Keep production out of reach. Test your restores, then let the agent do its job.

Related: I Used to Own My Software.