One hook, every tool call a coding agent makes
Claude Code runs PreToolUse hooks before any tool executes, and Rubrik Agent Cloud for Claude Code monitors and rewinds what the agent did. Put Veridect in the hook: it posts the tool call, and exit code 2 stops the tool with the verdict and the record id in the agent’s view — before there is anything to rewind. The same shape fits other coding agents with pre-execution hooks.
Fail-closed by construction: the script exits 2 unless it parsed a greenlight — a non-200, a timeout or a malformed body all stop the tool. Scope the hook to the tools that matter (Bash, Write, Edit, MCP tools) with the matcher; reads never wait. MCP tool names lose their mcp__server__ prefix so the verb the engine sees is the tool’s own.
// .claude/settings.json — the hook fires before Bash, Write, Edit and any MCP tool { "hooks": { "PreToolUse": [ { "matcher": "Bash|Write|Edit|mcp__.*", "hooks": [ { "type": "command", "command": "veridect-pre-tool-use", "timeout": 60 } ] } ] } } #!/usr/bin/env bash # veridect-pre-tool-use — reads the tool call on stdin; exit 2 = the tool does not run set -euo pipefail IN=$(cat) BODY=$(jq -cn --argjson in "$IN" --arg scope "$VERIDECT_AGENT_SCOPE" '{ action: ($in.tool_name | sub("^mcp__[^_]+__"; "")), # mcp__rubrik__rerun_backup_job → rerun_backup_job target: ("claude-code:" + ($in.cwd // "repo")), parameters: $in.tool_input, callingAgent: ("claude-code:" + $in.session_id), callingAgentScope: $scope, # its configured authority, in words department: "engineering" }') RES=$(curl -fsS --max-time 60 -H "Authorization: Bearer $VERIDECT_API_KEY" -H 'Content-Type: application/json' \ -d "$BODY" https://<your-veridect-host>/api/ai/consensus/pre-action) || RES='{}' # -f: any non-2xx is "unavailable", never a verdict VERDICT=$(jq -r '.verdict // "unavailable"' <<<"$RES"); RECORD=$(jq -r '.auditBundleId // ""' <<<"$RES") if [ "$VERDICT" != "greenlight" ]; then echo "Not executed — Veridect $VERDICT · record $RECORD" >&2 # the agent sees why; the refusal is on the ledger exit 2 # closed until proven open fi