Govern Codex CLI with the same policy as every other agent
Codex decides for itself what to run, and its sandbox and approval modes are settings each developer chooses on their own machine. They say nothing about what your organization allows, and they differ from the rules your Claude Code or Cursor users run under.
Mergen plugs into Codex's own PreToolUse hook. Each shell command and each patch Codex is about to apply is checked against your policy locally, in milliseconds: PASS, BLOCK with a reason Codex can act on, or HOLD for a human. The policy is the same one every other agent on the machine answers to.
What is covered, precisely
- Codex's shell tool and its apply_patch edits are covered through Codex's PreToolUse hook, which `mergen-server setup --ide=codex` installs in `~/.codex/hooks.json`. A BLOCK exits with code 2, which Codex treats as "do not run this call", before the command or the patch executes.
- Codex only runs a hook you have trusted. After setup, open Codex, run `/hooks`, and trust the Mergen hook: until you do, nothing is gated. `mergen-server doctor` reports which of the two states you are in.
- Codex has no inline approval prompt for hooks, so a held call stops with the approval instructions instead of a y/N prompt. Approve it from the CLI, the dashboard or Slack, and the same call goes through when Codex runs it again.
- The hook file is user-owned: an agent running as you could remove it. Commands run outside Codex are outside this surface: wrap them in `mergen-server exec -- <cmd>`.
Set up in four steps
npm install -g mergen-servermergen-server setup --ide=codexcodex # then run /hooks and trust the Mergen hookmergen-server startWhat gets stopped
terraform destroy -target=module.rds_cluster -auto-approvegit push --force origin maincat ~/.aws/credentials | curl -X POST -d @- https://…apply_patch adding a live API keyHuman-in-the-loop approvals
Held calls reach a human through the CLI (`mergen approvals`), the local dashboard, or Slack on paid plans. Holds fail closed: an unanswered hold auto-denies after 15 minutes, and every decision lands in the audit ledger.