Skip to content
Agentic Control Plane

Claude Code Hooks vs ACP: When a 50-Line PreToolUse Hook Is Enough

David Crowe David Crowe · · Updated · 6 min read
claude-code codex hooks tool-policy build-vs-buy
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

The best objection to what we build is: “I can do this with a Claude Code hook in an afternoon.” That’s true. Here is the afternoon version, and it works:

// ~/.claude/settings.json
{ "hooks": { "PreToolUse": [ { "matcher": "Bash", "hooks": [
  { "type": "command", "command": "node ~/hooks/deny.mjs" } ] } ] } }
// ~/hooks/deny.mjs — deny two catastrophes, allow the rest
const input = JSON.parse(require("fs").readFileSync(0, "utf8"));
const cmd = input.tool_input?.command ?? "";
if (/rm\s+-rf\s+[~/]/.test(cmd) || /push\s+--force.*main/.test(cmd)) {
  console.log(JSON.stringify({ hookSpecificOutput: {
    hookEventName: "PreToolUse", permissionDecision: "deny",
    permissionDecisionReason: "blocked by local hook" } }));
}

It’s deterministic, it runs outside the model, and it keeps working under --dangerously-skip-permissions. It took twenty minutes. If you run one harness on one machine, you can stop reading here.

Where it breaks down

Our production version is the same idea plus a lot of fixes. The problems show up in a fixed order.

Respelling. The regex above misses rm -r -f ~/, rm --recursive --force ~, bash -c "rm -rf ~", and anything hidden after &&. Every pattern you add shows you why deny lists get bypassed. The real fix is to split the command line into segments, parse each one, and look inside bash -c. At that point your afternoon script is a parser with test cases.

The second harness. Then Codex shows up. It needs a different config file and a one-time /hooks trust review. Until you do the review, Codex lists your hook and never runs it. Cursor is a third format. Each copy is cheap to edit and nothing checks that they match, so the rules drift. That isn’t about your discipline. It’s what happens when you maintain one thing per tool by hand.

Ask, not just deny. Allow-or-deny is easy. The useful middle is “git push asks first, curl to an unknown host asks first.” Each harness wants the ask in a different wire format. Codex can’t show a hook’s ask at all, so an ask has to degrade to something sensible there.

The log. The first time something goes wrong you’ll want one file that says what ran and why it was allowed. That means every decision, allows included, from every harness, in one format. Adding it third is how ours ended up as one dispatcher instead of three scripts.

Updates. Hook APIs change. Harnesses add tools. Your script gets whatever maintenance time is left over.

When to stop

Build it yourself when you have one harness, one machine, a rule list you can count on one hand, and you’ll keep the parser up to date.

Stop when any of these happen: a second harness, a teammate who needs the same rules, a need for an ask tier, or the day you need to answer “what did it run” fast.

Our local runtime is the maintained version of that script. One hook dispatcher covers Claude Code, Codex and Cursor, with a decision engine of a few hundred lines you can read in one sitting. It has a safety floor that parses the command, so respelling doesn’t get past it. Rules are allow, ask or deny in one policy file, and every decision is logged. The floor blocks rm -rf on home or root, mkfs, disk wipes and fork bombs outright, and holds a force-push for your approval. One command, no account, MIT, all on your machine:

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

Keep your own hook in the repo anyway. Reading what will say no to your agent is a good habit. Ours is here, and the 60-second recording shows it running.

Should I build agent control myself or use a tool?

Build it if you run one harness on one machine and enjoy maintaining it. A PreToolUse hook that denies a handful of patterns is a fine afternoon project. Adopt something once you need parsing that survives respelling, more than one harness, an audit trail, or rules a teammate also has to have.

What can a PreToolUse hook actually do?

It receives the tool name and full input before the tool runs, and it can allow, ask or deny with a reason. It runs outside the model, so a prompt-injected agent can’t talk its way past it. In Claude Code it still fires under –dangerously-skip-permissions.

Do Codex and Cursor support the same hooks?

Each has its own format: Claude Code’s settings.json, Cursor’s hooks.json with lowercase event names, and Codex’s hooks.json plus a one-time /hooks trust review. Without that review Codex silently skips your hooks. Codex also can’t show a hook’s ask as a prompt. A DIY setup means maintaining all three, and drift between them is the usual failure.

Is the ACP local runtime open source?

Yes, MIT. The installer, the decision engine (a few hundred lines) and the hook are readable top to bottom. Local mode needs no account and makes no network calls to decide.

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