Short answer: Stop the agent, don’t write anything new to the database, and check your provider’s backups and point-in-time restore right away. Then find the exact command in the agent’s history and block that kind of action for the future.
1. Stop the agent
Press Escape or close the session so it can’t “fix” things further. Don’t ask it to undo; it may run more commands.
2. Don’t write to the database
New writes can overwrite what a restore would bring back. Pause deploys and jobs that write to it.
3. Check every restore option
- Point-in-time restore on managed Postgres or MySQL (AWS RDS, Google Cloud SQL, Supabase, Neon and others): restore to a minute before the delete.
- Snapshots or scheduled backups from your host.
- Replicas or a staging copy that was recently synced.
- Exports anyone on the team made recently.
Contact your provider’s support quickly. Some keep deleted resources for a short time.
4. Find out exactly what ran
Look at the agent’s history for the command or API call. Note which credentials it used; if keys were exposed, rotate them.
5. Make sure it can’t happen again
- Keep backups where the same token can’t delete them.
- Give agents read-only or test credentials by default.
- Add a guard that blocks wiping databases and backups before the command runs. Antelog does this for Claude Code, Cursor, Codex and more, and keeps a record of every action.
Install Antelog
Free for developers. On macOS and Linux:
$ curl -fsSL https://antelog.dev/install.sh | shWindows and other tools: see the docs.