AI coding agents can edit files, run shell commands, and touch infrastructure. One bad rm -rf, force-push, or docker compose down -v can wipe hours of work or production data.
This documents a generic integration pattern for OpenAI Codex-style coding agents. It is not a built-in Codex feature.
When the agent proposes a shell command:
agent-guard check --json 'git push --force origin main'
Parse JSON decision / reason / risk. Surface BLOCK/WARN to the user.
agent-guard run --allow-risk -- pytest -q
Use --allow-risk only when the human intentionally accepts a WARN. It does not unlock BLOCK.
Keep .agent-guard.yml in the repo (see examples/agent-guard.yml). Point Codex workspace instructions at:
All shell commands must pass
agent-guard checkor be executed viaagent-guard run -- ….
agent-guard analyzes command text. Obfuscated or multi-stage payloads may evade static rules. Treat it as a seatbelt, not a vault.