Skip to content

Claude Code Antileak Hooks · Hooks, Engine & CLI Reference

6 specs documented

Deterministic specifications for all 6 PreToolUse wrappers, SessionStart sync, 4 --net Git hooks, the fail-closed R1–R7 engine (policy/check.py), and bootstrap/doctor/scan-repo tooling.

HOOKStrictly offline (never passes --net)Core Hook Entry

Claude PreToolUse (6) & SessionStart (1) Shell Wrappers

settings.json · forbid-{content,commit,push,read-secret,tamper,read-path}.sh + refresh-private.py

Six PreToolUse shell wrappers inspect writes, git commands, and sensitive reads offline before execution; passing calls exit 0 silently so interactive host permission prompts stay intact.

See Hook Payload Contracts ↗

✅ Supported Capabilities

  • forbid-content.sh (Write|Edit|NotebookEdit, 120s) and forbid-commit/push.sh (Bash(git *), 120s) enforce R1–R7 offline via check.py
  • forbid-read-secret.sh (Bash, 30s) and forbid-read-path.sh (Read|Grep, 30s) canonicalize paths via realpath to defeat ../ and symlink traversal
  • forbid-tamper.sh (Bash, 30s) blocks edits to core.hooksPath, disableAllHooks, and guard files; unparseable stdin fails closed with exit 2
  • SessionStart runs refresh-private.py (120s) so cloud sessions hydrate dynamic lists once runtime environment variables become available

⛔ Explicit Limits / Non-Goals

  • Wrappers never pass --net: a hook killed on network timeout turns into "no decision" in Claude Code; expired cache intentionally denies as error
  • Glob tool calls (filenames only, no file contents) are intentionally out of scope
  • Local shell checks cannot stop a privileged local user intentionally tampering outside Claude; mandatory remote rulesets and Git hooks remain the hard gate

Inputs, Environment Variables & Policy Limits

tool_input.file_path / path / contentstdinJSON (Claude Hook Payload)Required

Standard hook payload on stdin; parse errors emit deny JSON and exit 2.

forbid-commit.sh / forbid-push.shconfigif: "Bash(git *)" · 120s timeoutRequired

Blocks --no-verify, --no-gpg-sign, agent branch pushes, and leaked commit payloads.

forbid-tamper.shconfigmatcher: "Bash" · 30s timeoutOptional

Optional WARN-level item in doctor.py; keep enabled in production setups.

Outcomes & Exit Semantics

Pass -> exit 0 (silent stdout)Never emits permissionDecision="allow", preserving native user confirmation.
Deny -> JSON + exit 2Emits permissionDecision="deny" with credentials redacted via mask() to first 8 chars.