Skip to content
Agentic Control Plane

How to Block Dangerous Commands From a Coding Agent (2026)

David Crowe David Crowe · · Updated · 7 min read
claude-code codex cursor tool-policy safety
Share X HN LinkedIn

Just want to govern Codex? If you're here to actually see, control, and price every Codex tool call, that's one command — hooks for Bash plus an MCP connector for everything else, in a single installer:

macOS · Linux · WSL
curl -sf https://agenticcontrolplane.com/install.sh | bash
Windows · PowerShell
irm https://agenticcontrolplane.com/install.ps1 | iex

Full Codex install guide →  ·  see your first governed call →  ·  free up to 5 agents

Real recording, nothing mocked. A coding agent tries to force-push main and the safety floor stops it before it runs, with no policy tuning. Then a network call is held for approval, normal work is allowed, and the closing audit.jsonl shows every decision. This is option 4 below.

The pattern is well known by now. An agent gets a confident idea, runs a destructive command, and then writes an apology. A database deleted during a code freeze. A home directory wiped by one malformed command.

The model can’t be the safety check. Something outside it has to say no, in the path between the agent and the command.

Here are five ways to do that, ranked by what they catch. I judged each on four questions. Is the block deterministic, or can the model talk its way past it? Does it survive respelling (rm -r -f, bash -c wrappers, chains after &&)? Does it cover every agent you run? Does it leave a record?

1. The permission prompts you already have

Claude Code, Codex and Cursor all ship approval prompts. With them on, most disasters die in the dialog. This is the baseline, and it’s good.

It wears down in two ways. After the hundredth “yes,” you’re no longer reading. And --dangerously-skip-permissions is popular: once the prompts get annoying enough, people turn them off.

2. Built-in deny lists

Next step up: rules like Claude Code’s permissions.deny. They’re free, they’re native, and you should set them. Here is our suggested list.

They match strings, though. rm -rf / is denied. rm -r -f / or bash -c "rm -rf /" may not be, and we’ve written up how the deny list gets bypassed. A string rule is a tripwire, not a wall. It’s also per-tool config. Your Codex rules live in a different file in a different format.

3. dcg

dcg does one job. It’s a Rust hook that blocks destructive shell commands, and per its README it supports Claude Code, Codex and Gemini CLI. It understands spelling variants far better than a string list does. If all you want is “stop rm -rf,” it’s the right small answer.

It doesn’t try to be a policy layer, with allow, ask or deny per tool, subcommand or host. It also doesn’t keep a record of everything else the agent did.

4. A local policy floor in the hook path

We build this one, so weigh it accordingly. The mechanism is open, though.

These harnesses all call a hook before a tool runs, and whatever answers that hook can stop the call. In Claude Code the hook keeps firing even under --dangerously-skip-permissions. So the hook can parse every segment of the command token by token, which catches rm -r -f and bash -c wrappers. Then it applies two tiers:

  • Always blocked: rm -rf of home or root, mkfs, writing to a raw disk, fork bombs.
  • Held for a human: force-pushes, destructive SQL through a database client, curl | sh, and recursive deletes outside the project. These are asks, not denies. The call waits until you approve.

On top of that you add your own allow, ask and deny rules, and every decision is logged. One command sets it up for Claude Code, Codex and Cursor, with no account and nothing leaving your machine:

curl -sf https://agenticcontrolplane.com/install.sh | bash -s -- --local

The decision engine is a few hundred lines you can read. The 60-second recording shows a real force-push stopped at the hook.

Its limits are real. It isn’t isolation. A hook only governs the harness it’s wired into, so a curl | sh you type yourself is out of scope. The floor reads shell command text only, so a destructive call made through an MCP tool or a non-shell tool never reaches it. And on some harnesses the hook can be turned off. Antigravity’s skip-permissions flag removes hooks, ACP’s included.

5. Devcontainers, when the input is untrusted

If your agent reads untrusted content like public issues, scraped pages or other people’s PRs, you want a boundary, not a filter. Use a devcontainer or a VM. No command-level check protects you from what a prompt-injected agent does with access it legitimately has.

A container doesn’t replace command control. Inside it, your repo credentials still work, and a force-push to main is still a force-push. Run both.

Which to pick

With prompts on, you’re mostly fine until fatigue wins. Set deny lists, and know they can be bypassed. dcg is the best pure shell tripwire. A policy floor in the hook path stops respelled commands, covers several harnesses and keeps a log. That’s the one we build. For untrusted input, start with a container and put everything above inside it.

Can Claude Code's built-in deny list block rm -rf?

It matches command strings, so the plain spelling is blocked. But rm -r -f, a bash -c wrapper, or a chain after && can slip past string rules. Blocking reliably means parsing every segment of the command line token by token.

Do hooks still run under --dangerously-skip-permissions?

In Claude Code, yes. The flag removes the permission prompts, not the hook calls, so a PreToolUse hook that answers deny still blocks the call. Not every harness works this way. On Antigravity, its skip-permissions flag removes hooks too, ACP’s included.

Is a sandbox enough on its own?

A sandbox limits the damage, but it can’t tell a good command from a bad one inside the boundary. An agent in a devcontainer can still force-push your repo to main, because the credentials you gave it work fine from inside. Containment and command control solve different problems.

What commands should always be blocked?

The list with no legitimate agent use is short: rm -rf of root or home, mkfs, dd onto a raw disk device, and fork bombs. ACP always blocks those. Force-pushes, destructive SQL through a database client, and curl piped to a shell are better as an ask, where a human says yes or no. Everything else is a judgment call that belongs in a policy you can edit.

Share X HN LinkedIn
Get the next data drop
What agents actually cost, new tool-surface captures, and the occasional incident post-mortem — sent when we publish something worth your inbox, not on a schedule. Unsubscribe anytime.
Share: Twitter LinkedIn
Related posts

← back to blog