Agent-readable docs index: /llms.txt. Full docs in one file: /llms-full.txt. Download /docs.zip to grep all markdown files locally.

OpenAI Codex CLI Integration

OpenAI Codex CLI dispatches local tool calls (Bash / exec_command, apply_patch, read_file, update_plan, view_image, web_search, and mcp__<server>__<tool>) through its PreToolUse lifecycle hook. Dmint integrates with Codex CLI via both pre-execution hooks (.codex/hooks.json and .codex/dmint-hook.sh) and the dmint-mcp gateway, provisioning a dedicated .dmint/policies/codex.policy.json tailored to Codex CLI's built-in tools.

1. One-Command Setup (dmint init)

In your repository root, initialize Dmint for Codex CLI:
dmint init --harness codex
This creates:
  • .dmint/policies/codex.policy.json — Dedicated policy covering all built-in Codex CLI tools (Bash, exec_command, shell, apply_patch, read_file, view_image, list_dir, grep_files, update_plan, web_search, spawn_agent).
  • .dmint/signing.key & .dmint/integrity.key (0600) — Local Ed25519 signing and HMAC integrity keys.
  • .codex/hooks.json & .codex/dmint-hook.sh — Official PreToolUse hook configuration pointing directly to .dmint/policies/codex.policy.json.
.codex/hooks.json
{ "version": 1, "hooks": { "PreToolUse": [ { "matcher": "Bash|apply_patch|mcp__.*", "hooks": [ { "type": "command", "command": "dmint hook run --harness codex --policy \"/abs/path/.dmint/policies/codex.policy.json\" --db-path \"/abs/path/.dmint/approvals.sqlite3\"" } ] } ] } }

2. How Codex CLI Tool Calls Are Evaluated

dmint hook run --harness codex handles every Codex CLI tool surface:
  • Shell & Unified Exec (Bash / exec_command): Extracts commands whether passed as {"command": "git status"} or ["bash", "-lc", "git status"] and evaluates them against both Bash and shell.execute rules in codex.policy.json.
  • Multi-File Unified Patches (apply_patch): Parses every *** Add File:, *** Update File:, *** Delete File:, and *** Move to: header in the patch envelope. If a single patch touches both src/app.py and .env, Dmint evaluates every path and blocks the call with DENY.
  • Fail-Closed PreToolUse Output: Because Codex CLI PreToolUse enforces "allow" and "deny" (and does not enforce "ask"), Dmint returns permissionDecision: "deny" with exit code 2 whenever a call is DENY or APPROVAL_REQUIRED, ensuring unapproved commands never execute silently.
Test how your Codex policy evaluates calls from the terminal:
# Simulate a Codex Bash call: dmint hook run --harness codex --policy .dmint/policies/codex.policy.json \ --input '{"tool_name": "Bash", "tool_input": {"command": "git status"}}'

3. Approving Paused Commands

When Codex attempts an action governed by approval_required (such as git push origin main, apply_patch on src/app.py, or docker compose up):
  1. dmint hook run exits with code 2, blocking execution, and records a PENDING request (apr_...) in .dmint/approvals.sqlite3.
  2. Review and approve the request from your terminal or web dashboard:
    dmint pending dmint approve apr_... --by dev@company.com
  3. Ask Codex to retry the exact command. Dmint verifies the Ed25519 signature against the RFC 8785 fingerprint, transitions the approval to CONSUMED, and lets the command run once.