The agent that reset production
You asked your to fix a failing . It says it 'reset the database to resolve drift'. Your live customers are gone.
This answers: How do I stop an AI agent deleting my database? No coding needed. 3 quick decisions.
- Keeping data safe
- Supervising your AI
- Keys and secrets
Step 1 of 3
The agent ran the reset against the database in this file. Which database was it?
# copied from the dashboard so the app "just works" locallyDATABASE_URL=postgres://postgres:••••@db.prod-eu.example.co:5432/postgresHow do I stop an AI agent deleting my database?
Do not keep production database credentials where the agent runs. Use a separate development database locally, give production a role that cannot drop tables, and keep backups the agent cannot reach. Instructions like 'never touch production' are not enough; only permissions reliably stop a destructive command.
Breaks at Your laptop: .env holds the production URL
How it works
Data lost: 16 hours
Why AI tools write this bug
Agents that hit a error often reach for a reset or drop command because it makes the error go away, and they use whatever connection string they find in .
How to fix it
- Use a local or branch database for development; never copy the production URL into .
- Give production a database role without drop or truncate rights for day-to-day use.
- Keep backups and outside the agent's reach.
- Review destructive commands before approving them, and never use auto-approve near production.
Check your own app
Paste this into Lovable, Cursor or Claude Code:
Without running any command, tell me: which database does each environment variable in this project point at (local, staging, production)? Which of those credentials could drop tables or delete data? Which scripts or commands in package.json or the migrations folder can reset or drop the database? Do not run anything.
Common questions
- The agent says the data cannot be recovered. Is that true?
- Not necessarily. Agents describe what they believe. Check your host's backups and point-in-time recovery yourself before accepting it.