Overview
Codex CLI ships a Claude-style hook system. APreToolUse hook runs a script before a tool executes and can block
it. Sigil Open Framework (SOF) plugs into that hook: the script forwards the
intended action to Sigil Sign /v1/authorize and blocks when the policy returns
DENIED.
Coverage today. Codex
PreToolUse currently supports Bash, file edits
through apply_patch with Edit and Write matcher aliases, and MCP tool
calls. It still does not intercept WebSearch or every rich shell-streaming
path. Treat this as a strong guardrail, not a complete enforcement boundary.
For broader MCP governance, route tools through the
Sigil MCP Proxy. Track the
Codex hooks docs as coverage expands.http only when a web tool input explicitly carries a valid method. Web inputs without a method remain web_fetch; the adapter never infers GET.
Prerequisites
You need a Sigil API key and a signedwarranty.md policy file deployed to Sigil Sign.
- Get an API key: sigilcore.com/tools/keys
- Generate a policy: sigilcore.com/tools/warrant
1. Enable hooks
Codex hooks are behind a feature flag. In~/.codex/config.toml:
2. Register the PreToolUse hook
In~/.codex/hooks.json (global) or <repo>/.codex/hooks.json (per project):
3. Add the hook script
Install the package in a location the script can resolve, then create~/.codex/hooks/sigil-pretooluse.mjs:
NODE_PATH=$(npm root -g) in your shell profile is the simplest path), set
SIGIL_API_KEY in your environment, and Codex will check Bash, file edits, and
the registered MCP tools against your policy before they run. Add one matcher
entry per MCP tool name you expose.
The adapter resolves task ids in this order: config.taskId, session_id,
conversation_id, run_id, turn_id, then SIGIL_TASK_ID. ## execution_limits
uses this value to apply per-task tool-call ceilings.
How It Works
Codex pipes a JSON payload to the hook onstdin. The adapter maps Bash to
bash, apply_patch/Edit/Write to file_write, and MCP tool names to their
lowercase canonical names. On a DENIED or PENDING decision it writes the
documented Codex hookSpecificOutput.permissionDecision = "deny" shape to
stdout. Codex then refuses the tool call and returns the reason to the model.
Fail Mode
The script above usesfailMode: 'closed', so a Bash command is blocked if Sigil
Sign is unreachable. For local development you can switch to failMode: 'open',
which allows the command through on an outage and tags the result with
failOpen: true. Use closed mode for any environment that touches production,
external systems, or on-chain actions.
Adapter Status
Codex has a dedicated package export:createCodexPreToolUseHook. It preserves
the current Codex deny shape, framework id, task id fallbacks, fail-closed
default, and coverage warnings in request metadata.
Governing MCP and File Tools
CodexPreToolUse covers matching MCP tool calls and file edits through
apply_patch. Two paths still matter:
- MCP tool calls: use the adapter for matched calls, or point Codex at the
Sigil MCP Proxy when you need protocol-level
enforcement for every MCP
tools/call. - Web tools: governed natively once Codex extends hook coverage to WebSearch and related non-shell tools.
Configuration
Source
- github.com/Sigil-Core/agent-hooks — TypeScript package, MIT License
- Codex hooks documentation