Zero-code integration for Claude Code CLI users. Installs a hook that enforces contracts on every tool use.
pip install agentassert-typec-claude-codeagentassert-claude-code install --contract safety-minimal.yamlThis drops 00-agentassert-typec.py into ~/.claude-hooks/. The 00- prefix ensures it runs before any other hooks.
agentassert-claude-code statusOutput:
✅ Hook installed: /Users/you/.claude-hooks/00-agentassert-typec.py
AGENTASSERT_CONTRACT=/Users/you/safety-minimal.yaml
agentassert-claude-code uninstallagentassert-claude-code install --contract partner-mode.yaml
agentassert-claude-code install -c full-governance.yaml --force| Flag | Description |
|---|---|
--contract, -c |
Path to contract YAML (required) |
--force, -f |
Overwrite existing hook if already installed |
Removes the hook file from ~/.claude-hooks/.
Shows whether hook is installed and which contract is active.
Three templates ship with the package. Install with:
agentassert-claude-code install --contract safety-minimal.yamlBlocklist only. Blocks destructive commands (rm -rf /*, curl|bash, --no-verify). Zero false positives. Use this if you just want a safety net.
invariants:
process:
- tool_blocklist:
tools:
- "rm -rf /*"
- "rm --no-preserve-root"
- "curl|bash"
- "wget|bash"
- "*--no-verify"
scope: sessionAll 6 operators (minus allowlist). Designed to compress CLAUDE.md by encoding process rules as formal contracts:
must_precede: Challenge before recommendationmust_state: State cost before paid API callstool_blocklist: Destructive tools blockedcontext_budget: 60K tokens per turn capprocess_drift: JSD drift at 0.30 thresholdjudge_predicate: L99 conviction check (20% sample rate)
All 7 operators + ABC hard/soft constraints + drift/reliability config. Use for production-grade governance.
The hook intercepts Claude Code's event stream:
| Claude Code Event | Type-C Event | Action |
|---|---|---|
PreToolUse |
PreAction |
Evaluate → ALLOW / BLOCK / MODIFY |
PostToolUse |
PostAction |
Update drift + Θ |
UserPromptSubmit |
TurnStart |
Mark turn begin |
Stop |
TurnEnd |
Evaluate soft constraints |
SessionStart |
SessionStart |
Load contract, compile AST |
SessionEnd |
SessionEnd |
Final Θ score + drift report |
Fail-safe: If the hook encounters any internal error (missing contract env, broken YAML), it returns allow — never blocks on internal failure.
- The
00-prefix ensures AgentAssert runs first - Existing hooks continue to work — AgentAssert doesn't replace them
- Use
AGENTASSERT_CONTRACTenv var to point to your contract
export AGENTASSERT_CONTRACT=/path/to/contract.yamlSet before starting Claude Code. The hook reads this env var to find the contract.
See Case Study for real measurements:
- CLAUDE.md reduced by 47.8% (49,636 → 25,920 bytes)
- Process rules compressed by 96% (31,322 → 1,203 bytes)
- All behavioral rules moved from prompt to formal contract