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

Claude Code, Codex & OpenCode Integration

AI coding agents execute two kinds of tools:
  1. Built-in native tools (Bash / exec_command, Read, Write, Edit, MultiEdit) that run directly inside the agent harness.
  2. Model Context Protocol (MCP) tools (mcp__postgres__query, etc.) that run over stdio or Streamable HTTP.
Dmint protects both layers:
  • dmint hook intercepts built-in shell, filesystem, and MCP tool calls via the harness's native PreToolUse / tool.execute.before hook before a command ever runs.
  • dmint-mcp wraps downstream MCP servers in a fail-closed proxy.

1. 30-Second Setup (dmint init)

In your project directory, run a single command to generate cryptographic keys (.dmint/), a starter policy.json (covering shell and filesystem tools), and pre-tool hooks for your coding agent:
# Install for Claude Code, Codex, OpenCode, Cursor, Windsurf, and Cline at once: dmint init --harness all # Or target a specific harness: dmint init --harness claude-code dmint init --harness codex dmint init --harness opencode
What this creates:
  • .dmint/policies/<harness>.policy.json & policy.json — Dedicated per-harness policies covering all built-in tools for Claude Code (claude-code.policy.json), Codex (codex.policy.json), and OpenCode (opencode.policy.json).
  • .dmint/signing.key & .dmint/integrity.key (0600 permissions) — Ed25519 approval signing key and HMAC store integrity key.
  • .claude/settings.json — Claude Code PreToolUse hook matching Bash|Read|Write|Edit|MultiEdit|NotebookEdit|WebFetch|mcp__.*.
  • .codex/hooks.json & .codex/dmint-hook.sh — OpenAI Codex CLI pre-execution hook.
  • .opencode/plugin/dmint-guard.ts — OpenCode tool.execute.before guard plugin.

2. Test Your Policy from the Terminal (dmint check)

Before launching your agent, verify how your policy.json evaluates any tool call:
# Safe inspection command -> ALLOW (exit code 0) dmint check --tool shell.execute --resource "git status" # Sensitive command -> APPROVAL_REQUIRED (exit code 1) dmint check --tool shell.execute --resource "git push origin main" # Destructive command -> DENY (exit code 2) dmint check --tool shell.execute --resource "rm -rf /"

3. How the Approval Loop Works in Practice

When Claude Code, Codex, or OpenCode attempts an action marked approval_required (such as git push origin main or docker run ...):
  1. Intercept & Pause: dmint hook run halts the tool call, saves a tamper-evident PENDING record (apr_...) in .dmint/approvals.sqlite3, and returns the exact approval command to the agent/user:
    Dmint APPROVAL_REQUIRED [apr_9k2L...]: shell.execute on 'git push origin main' requires human sign-off. To approve, run: `dmint approve apr_9k2L...` (or use `dmint dashboard`), then retry.
  2. Human Sign-Off: In another terminal (or via dmint dashboard), approve the exact request:
    dmint pending dmint approve apr_9k2L... --by alice@company.com
  3. Single-Use Retry: Tell the agent to retry the command. dmint hook run verifies the Ed25519 signature against the exact RFC 8785 canonicalized arguments, atomically transitions the record from APPROVED to CONSUMED, and lets the command execute once.
  4. Tamper & Replay Protection:
    • If the agent changes any argument on retry (e.g., git push origin main --force), the request fingerprint does not match and the call is blocked.
    • If the agent tries to run the same command a second time later, the consumed approval cannot be reused.

4. Managing Hooks (dmint hook)

# Check which harnesses have Dmint hooks installed in the current workspace: dmint hook status # Install hooks into your global home directory (~/.claude/settings.json, ~/.config/opencode/plugin/, etc.): dmint hook install --harness claude-code --global # Remove hooks cleanly: dmint hook uninstall --harness all

5. Wrapping External MCP Servers with dmint-mcp

If you also connect Claude Code to external MCP servers (PostgreSQL, GitHub, Stripe), wrap them with dmint-mcp:
claude mcp add dmint-gateway -- dmint-mcp run --config /absolute/path/to/mcp_protection.json