# How to stop an AI agent from deleting data

To stop an AI agent from deleting data, remove the access it does not need, check every command and query before it runs, hold irreversible ones for a person, and keep backups for what gets through.

## Steps

1. **Take away what is not needed.** No production credentials in a development agent. Read-only database users where the task is reading. See [least privilege](/glossary/least-privilege-for-ai-agents).
2. **Isolate.** Run commands in a [sandbox](/glossary/agent-sandboxing) with a working copy, not the real thing.
3. **Check each action before it runs.** Read the command and its arguments: `rm -rf` on a path outside the workspace, `DROP` or `TRUNCATE`, a `DELETE` with no `WHERE`, a force push, a bucket deletion, a `terraform destroy`.
4. **Hold what cannot be undone.** Send it to a person with the exact command and its target. See [human-in-the-loop](/glossary/human-in-the-loop).
5. **Make undo real.** Backups, soft deletes, protected branches, versioned buckets.
6. **Record it.** Keep the trace of what ran and who approved it.

## What does not work alone

- **"Never delete anything" in the system prompt.** The model can be argued out of it, or forget it forty steps in. See [system prompt vs guardrails](/glossary/system-prompt-vs-guardrails).
- **A blocklist of command strings.** `rm` has many spellings, and a script can do the same thing.
- **Approving everything.** People stop reading.

## With White Circle

[Control](/products/control) checks terminal commands, code execution and API calls against your policies before they run, and a policy can block the call or hold it for confirmation.

