How do you stop an AI coding agent from running destructive commands?

By Verillian. Published . Updated .

Not by asking it to be careful. Limit what it can reach, require approval for irreversible actions, prefer an allow list, and keep a record of what it tried.

A man with headphones works on a laptop beside a large monitor.

You stop an AI coding agent from running destructive commands by limiting what it can reach and what it is allowed to do before it acts.

An instruction in a prompt is text the model weighs, and it can be outweighed. A missing credential, a separate environment, or a policy check that runs before the command does not get weighed at all.

In practice that means four layers working together. Give the agent least privilege, require human approval for anything irreversible, check policy at the moment of the tool call, and keep a record of what was attempted. No single layer is enough, and a list of banned commands, a control many teams reach for first, is weaker than it looks.

Why does a coding agent run a destructive command at all?

Because it was able to, and nothing between the model’s output and the shell said no. The OWASP GenAI Security Project names this failure LLM06:2025 Excessive Agency and defines it as “the vulnerability that enables damaging actions to be performed in response to unexpected, ambiguous or manipulated outputs from an LLM, regardless of what is causing the LLM to malfunction.”

The last clause matters. It does not matter whether the model misread an instruction, hallucinated a step, or was steered by text hidden in a file it read. The question is what the agent was permitted to do when that happened.

OWASP lists three root causes, excessive functionality (the agent has capabilities the job does not need), excessive permissions (it holds access rights beyond what the job needs), and excessive autonomy (it takes high-impact actions without a human checking). A coding agent with a shell, a database credential, and no approval step has all three.

Has this happened?

Yes, and in public. In July 2025 a coding agent on a hosted development platform deleted a live production database during a session where its user had declared a code freeze.

The platform’s chief executive wrote on X on July 20, 2025 that the agent had deleted data from the production database, that this was “unacceptable,” and set out the fixes.

Read that list with OWASP in mind. Automatic separation of development and production databases, a one-click restore, and a planning and chat only mode still in the works are all changes to what the agent can reach and do. When the people who build these systems respond to a destructive command, they respond by changing the environment.

We are relying on one primary statement here, and it is a company describing its own incident. It is enough to show the shape of the problem. It is not a survey of how often it happens, and this post does not claim one.

What does OWASP say to do about it?

The mitigations on the same OWASP page read like a security review checklist:

  • Minimize the extensions and tools an agent has, and the functionality of each.
  • Avoid open-ended tools, such as one that runs any shell command, where a narrow one would do.
  • Minimize the permissions each tool holds, and run tools in the user’s own context rather than a broader one.
  • Use human-in-the-loop control “to require a human to approve high-impact actions.”
  • Apply complete mediation. Check every request against policy rather than trusting the agent to check itself.

The NIST Generative AI Profile (NIST AI 600-1, July 2024) points the same way. Its suggested action MS-2.7-001, under the MEASURE 2.7 subcategory on security and resilience, asks organizations to assess the likelihood and magnitude of threats that include autonomous agents.

It’s guidance for a risk assessment, and it puts agents on the list of things an organization is expected to have thought about.

Does telling the agent not to do it work?

Not as a control. A rule in a system prompt, a project instruction file, or a chat message is an input to the model, and inputs can be misread, deprioritized, or overridden by later text.

It is worth writing the rule down, because it lowers the odds. It is not what stops the command on the day the odds go against you.

Is a list of banned commands enough?

Less than it looks. A deny list judges a command as it is written. A command can arrive wrapped in another program, chained behind harmless steps, built up in pieces, or run through an interpreter, and each of those is a different string from the one on the list.

So treat a deny list as a speed bump, one that catches the obvious case and can miss the disguised one. The stronger configuration is an allow list, where the agent may run only what you named and everything else is refused. It is more work to write, and a command nobody thought to name is refused instead of allowed.

The narrower controls hold up better. Removing a tool entirely, such as a shell the agent does not need, does not depend on recognizing a dangerous string. Neither does taking the production credential off the machine the agent runs on. If the agent cannot reach the database, no command can delete it.

What can you start on this week?

  • Give the agent development credentials only. Production access belongs to a person and a separate, approved path.
  • Give each tool the narrowest permissions the task needs, and drop the tools it does not.
  • Require a human yes for anything you could not undo, such as deleting data, dropping tables, force pushes, changing access.
  • Prefer an allow list of permitted commands to a deny list of forbidden ones.
  • Keep backups, and restore one on a schedule so you know it works.
  • Keep a record of what the agent attempted, including what was refused, so a review after an incident starts from evidence rather than from the agent’s own account.

What happens to a denied command?

In Claude Code, each tool call is checked before it runs; a call your policy denies never runs and is its own entry in the record.

Verillian keeps a signed record of every captured AI interaction on your organization’s own servers, each entry naming the person assigned to the enrolled device, the device and the time, so a review after an incident starts from evidence.

Sources

How Verillian governs AI agents

See Verillian govern AI on a real device.