dmint hook)Bash / run_commands, file edits (Write, Edit, apply_patch, pre_write_code), file reads (Read, read_files, pre_read_code), and subagent delegation—through built-in native tools in addition to external MCP servers.dmint hook places Dmint's deterministic policy evaluator and single-use Ed25519 human approval engine directly into the official pre-execution hook lifecycle of each coding harness, provisioning a dedicated policy file per harness (.dmint/policies/<harness>.policy.json) tailored to that harness's complete built-in tool inventory.┌─────────────────────────────────────────────────────────────────────────┐ │ AI Coding Harness (Local / Container) │ │ (Claude Code · OpenAI Codex CLI · OpenCode · Cursor · Windsurf · Cline)│ └───────────────────────────────────┬─────────────────────────────────────┘ │ │ 1. Official Pre-Tool Hook Event ▼ ┌─────────────────────────────────────────────────────────────────────────┐ │ dmint hook run │ │ • Unpacks harness-specific envelope & de-stringifies JSON params │ │ • Inspects all batch items (multi-file apply_patch / run_commands) │ │ • Evaluates .dmint/policies/<harness>.policy.json (native + canonical) │ │ • Enforces strict precedence: DENY > APPROVAL_REQUIRED > ALLOW │ └───────────┬───────────────────────┼───────────────────────┬─────────────┘ │ │ │ ▼ ▼ ▼ [ ALLOW ] [ APPROVAL_REQUIRED ] [ DENY ] │ │ │ Exit 0 ("allow") Persists PENDING apr_... Exit 2 ("deny") Tool executes or consumes APPROVED Tool blocked assertion once
dmint init --harness all (or dmint hook install --harness <name>) to configure any or all supported harnesses. Each harness is wired to its own dedicated policy file in .dmint/policies/<harness>.policy.json:| Harness | Flag Value | Generated Hook Configuration File(s) | Dedicated Policy File | Official Hook Mechanism & Output Schema |
| Claude Code | claude-code | .claude/settings.json | .dmint/policies/claude-code.policy.json | hooks.PreToolUse (matcher: "*") returning hookSpecificOutput.permissionDecision ("allow" | "deny" | "ask") |
| OpenAI Codex CLI | codex | .codex/hooks.json & .codex/dmint-hook.sh | .dmint/policies/codex.policy.json | hooks.PreToolUse (matcher: "Bash|apply_patch|mcp__.*") returning hookSpecificOutput.permissionDecision ("allow" | "deny") + exit 2 on block |
| OpenCode | opencode | .opencode/plugins/dmint-guard.ts & .opencode/plugin/dmint-guard.ts | .dmint/policies/opencode.policy.json | Native TypeScript plugin hooking tool.execute.before (input.tool, output.args) |
| Cursor | cursor | .cursor/hooks.json ("version": 1) | .dmint/policies/cursor.policy.json | preToolUse, beforeShellExecution, beforeReadFile, beforeMCPExecution, subagentStart (failClosed: true) returning {"permission": "allow" | "deny"} |
| Windsurf Cascade | windsurf | .windsurf/hooks.json | .dmint/policies/windsurf.policy.json | pre_run_command, pre_read_code, pre_write_code, pre_mcp_tool_use (show_output: true), blocking via exit code 2 |
| Cline / Roo Code | cline | .clinerules/hooks/PreToolUse, .cline/hooks/PreToolUse.sh, .clinerules/hooks.json | .dmint/policies/cline.policy.json | Executable PreToolUse scripts returning {"cancel": false} on allow and {"cancel": true, "errorMessage": "..."} on block |
TodoWrite in Claude Code, update_plan in Codex, todowrite in OpenCode, or attempt_completion in Cline).src/dmint/templates/data/<harness>.json) for every harness:| Harness | Allowed Safe Built-In Tools (ALLOW) | Approval-Gated Tools (APPROVAL_REQUIRED) | Strictly Blocked Targets (DENY) |
| Claude Code | Read, NotebookRead (workspace), Glob, Grep, LS, LSP, Agent, Task, AskUserQuestion, EnterPlanMode, ExitPlanMode, ExitWorktree, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskStop, TodoRead, TodoWrite, ToolSearch, WaitForMcpServers, ListMcpResourcesTool, ReadMcpResourceTool, ListAgents, ReportFindings, SubagentHandback, SendFeedback, PushNotification, CronCreate, CronList, CronDelete, ScheduleWakeup, WebSearch, safe Bash/PowerShell (git status, pytest, npm test, ls) | Edit, MultiEdit, Write, NotebookEdit (workspace), Skill, SlashCommand, Workflow, EnterWorktree, WebFetch, Artifact, ShareOnboardingGuide, RemoteTrigger, SendMessage, SendUserFile, mutating Bash (git push *, docker *, npm install *, pip install *, curl *) | Destructive Bash (rm -rf /, sudo *, mkfs *, * | sh, * *.env*), reading or writing .env*, *.key, *.pem, .dmint/**, .claude/**, /etc/** |
| OpenAI Codex CLI | read_file, Read, view_image (workspace), list_dir, grep_files, search_files, update_plan, web_search, wait, close_agent, safe Bash/exec_command/shell | apply_patch, Edit, Write, write_file (workspace), spawn_agent, send_input, mutating Bash/exec_command | Destructive Bash/exec_command, reading or patching .env*, *.key, *.pem, .dmint/**, .codex/**, /etc/** |
| OpenCode | read (workspace), grep, glob, list, lsp, todowrite, todoread, question, websearch, safe bash | edit, write, apply_patch, patch (workspace), skill, task, webfetch, mutating bash | Destructive bash, reading or editing .env*, *.key, *.pem, .dmint/**, .opencode/**, /etc/** |
| Cursor | Read, beforeReadFile, beforeTabFileRead, read_file (workspace), Grep, Glob, LS, codebase_search, grep_search, file_search, list_dir, Task/subagentStart (explore, generalPurpose), safe Shell/beforeShellExecution | Write, Edit, MultiEdit, Delete, edit_file, write_file, delete_file, search_replace (workspace), subagentStart (shell), beforeMCPExecution, mutating Shell/beforeShellExecution | Destructive Shell/beforeShellExecution, reading or writing .env*, *.key, *.pem, .dmint/**, .cursor/**, /etc/** |
| Windsurf Cascade | pre_read_code, read_file, view_file, view_code_item (workspace), grep_search, find_by_name, list_dir, pre_user_prompt, safe pre_run_command | pre_write_code, write_to_file, replace_file_content, multi_replace_file_content (workspace), pre_mcp_tool_use, mutating pre_run_command | Destructive pre_run_command, reading or writing .env*, *.key, *.pem, .dmint/**, .windsurf/**, .devin/**, /etc/** |
| Cline / Roo Code | read_files, read_file (workspace), search_files, list_files, list_code_definition_names, ask_followup_question, attempt_completion, load_mcp_documentation, access_mcp_resource, safe run_commands/execute_command | editor, write_to_file, replace_in_file, apply_patch, apply_diff, insert_content (workspace), new_task, switch_mode, browser_action, use_mcp_tool, web_fetch, web_search, mutating run_commands/execute_command | Destructive run_commands/execute_command, reading or modifying .clineignore, .clinerules/**, .cline/**, .env*, *.key, *.pem, .dmint/**, /etc/** |
apply_patch): Codex CLI, OpenCode (output.args.patchText), and Cline embed multiple file headers (*** Add File: ..., *** Update File: ..., *** Delete File: ..., *** Move to: ...) in one patch body.read_files): Cline accepts {"files": [{"path": "src/app.py"}, {"path": ".env"}]}.run_commands): Cline accepts {"commands": ["git status", "rm -rf /"]}.dmint hook run extracts every target file path or command in the batch, evaluates each against the harness's dedicated policy (checking both the native tool name and the normalized capability), and enforces the strictest decision (DENY > APPROVAL_REQUIRED > ALLOW). A denied file or command cannot be smuggled inside an otherwise benign batch call.approval_required rule (for example, git push origin main or editing src/main.py):dmint hook run creates a tamper-evident PENDING record (apr_...) in .dmint/approvals.sqlite3.DMINT_SLACK_WEBHOOK_URL, etc.), a real-time alert is dispatched.Dmint APPROVAL_REQUIRED [apr_8k9P...]: shell.execute on 'git push origin main' requires human sign-off. To approve, run: `dmint approve apr_8k9P...` (or use `dmint dashboard`), then retry.
dmint approve apr_8k9P... --by alice@company.com
git push origin main, dmint hook run computes the RFC 8785 request fingerprint, finds the matching APPROVED assertion in .dmint/approvals.sqlite3, verifies the Ed25519 signature, atomically transitions the record from APPROVED $\to$ CONSUMED, and returns ALLOW.git push origin main --force, the fingerprint does not match apr_8k9P... and execution is blocked.git push origin main a second time, the consumed assertion cannot be reused.