Skip to content

Architecture & Real-Run Walkthrough ​

Two-Layer Enforcement Flow ​

text
Agent Tool Call (Write / Edit / Bash / Read / Grep)
  └─▶ Claude Code PreToolUse (offline, no --net, 30s–120s timeout)
        ├─ Parse error / rule match / stale cache ──▶ deny JSON + exit 2
        └─ Exact pass ──────────────────────────────▶ silent exit 0 (host prompts preserved)

Git Lifecycle (pre-commit / pre-merge-commit / commit-msg / pre-push)
  └─▶ Git Client Hooks (--net enabled: lazy cache refresh + single-slug lookup)
        └─▶ Single Policy Engine policy/check.py (R1–R7 + ssh-keygen -Y check-novalidate)
              ├─ pass ──────────────────────────────▶ exit 0
              └─ violation / error ─────────────────▶ exit 1 + masked diagnostics
Claude Code Antileak Hooks Workflow (Interactive Archify diagram; pan / zoom / inspect)
Open Fullscreen ↗

One Real Run: Write Tool Interception ​

  1. Extract Payload (hooks/forbid-content.sh): Reads stdin JSON on Write, Edit, or NotebookEdit (content / new_string / new_source). Invalid JSON triggers fail-closed deny; empty content exits 0 silently.
  2. Offline Engine Call (hooks/_lib.sh -> policy/check.py content): Invokes check.py content without --net so the check completes well inside the 120s hook timeout (a killed hook defaults to "no decision" in Claude Code).
  3. Static & Cache Evaluation (full_check): Runs scan() (R2 with in_b64_run filtering + R7 unskipped secret regexes masked to 8 chars) followed by private_check() (R4 local seed patterns + R1 cached private repo names within the 6h TTL). Missing or expired caches return error, never pass.
  4. Output Mapping: Only exact stdout pass exits 0 silently (never emitting permissionDecision: allow). Any violation or error outputs permissionDecision: deny JSON and exits 2.
  5. Final Git Gate (hooks/git/*): Real git commit, git merge, and git push events re-run the same engine with --net, adding R3 authorship, R5 agent branch checks, R6 SSH cryptographic verification, and known_content checks against git ls-remote tips.

See the Code Map for exact source locations and maintainer entry points.