Letting My AI Delete Things (Carefully)

My AI assistant could write, edit and publish here, but it couldn't delete anything. Here's how I gave it the smallest useful delete permission, and why the machine check matters more than my approval.

Letting My AI Delete Things: a circuit raven carefully carrying one rune tile past a guarded shelf

My AI assistant can do a fair amount on this site. It drafts posts, fixes typos in live ones, uploads images, and publishes when I say so for a specific item. Until this week, there was one thing it couldn’t do at all: delete anything.

Then I replaced the featured images on a batch of posts and was left with a few orphaned files in the media library. Deleting them by hand takes a minute. But it raised a better question: what would it take to let an AI delete things safely?

The answer isn’t trust. It’s constraints.

Start with the smallest useful power

I didn’t give it “delete”. I gave it “delete one image”. Not posts, not pages, not comments, not anyone else’s uploads. One narrow tool that does one thing, so the worst case is easy to reason about.

The rules, enforced in code

Every one of these is checked by the tool itself, not left to the model’s good behaviour:

  • Images only. If the ID isn’t an image in the media library, the request fails.
  • Only images its own account uploaded. My uploads are off limits.
  • Only if nothing uses it. Not a featured image, not referenced in any post, page or template, not the site icon or logo. If it’s in use, the tool refuses and says where.
  • Only with my approval for that specific image. The request needs an explicit approval flag, and the assistant’s standing rules say it sets that flag only when I’ve said so in chat for that item.
  • Logged. Every deletion writes a line to the server log: who, which image, which file.

A refusal is specific, so neither of us has to guess. Ask it to delete an image that’s still the featured image on a post, and the answer comes back as something like Not deleted: the image is still in use (featured image of 106), naming exactly what depends on it.

Why the machine check matters more than my approval

Human approval is the part everyone focuses on, and it’s the weakest link. Approvals get rubber-stamped. I approve what I think image 75 is. If I’m wrong about that, my “yes” doesn’t protect anything.

The in-use check catches exactly that case. It doesn’t care what either of us believes; it looks at what the site actually references. The human check and the machine check fail in different ways, which is the whole point of having both. That’s defence in depthdefence in depth Layering several independent controls so that one failure doesn't open the gate. A firewall, then authentication, then hardening, then monitoring. at the scale of a single button.

On the first real run, it deleted the three images I named. A fourth ID I’d asked about came back as “no such image”: I’d already removed it by hand days earlier and forgotten. It said so instead of guessing, which is the behaviour you want.

Permanent means permanent

WordPress media has no trash. A deleted image is gone, file and all, and the nightly backup is the only way back. I wrote that into the tool’s own description, so the assistant reads it every time it considers using it. Being honest about the rollback, including when there isn’t a good one, is part of designing a destructive action.

What I deliberately didn’t add

The obvious next step would be letting it clean up my uploads too. In WordPress, that needs a capability called delete_others_posts, and capability names are blunt: the one that would let it delete my images would also let it delete my posts.

When the platform’s permission model is coarser than the job, don’t widen the role to fit. Keep the role small and do the narrowing in the tool. My images I can delete myself.

The pattern

Give an AI agent a destructive capability the way you’d approve a production change:

  1. The smallest scope that does the job.
  2. A precondition the system checks for itself.
  3. Explicit approval for each item, not a blanket yes.
  4. A log entry you can read later.
  5. A known rollback, or an honest statement that there isn’t one.

None of that is new. It’s change managementchange management Recording why a change is safe, who approved it and how to roll it back, before it happens.. The only new part is remembering that the thing asking for permission is a language model, so the guardrails have to live outside it.

ᛟ ᛟ ᛟ