-
Notifications
You must be signed in to change notification settings - Fork 0
User Guide CLI
The CCH CLI (cch) is the deterministic runtime engine for Claude Context Hooks. It is a high-performance Rust binary that evaluates hook events, matches rules, executes validators, injects context, and enforces policy.
Think of it this way:
- CCH Skill → Policy author (intelligent assistant)
- CCH CLI (
cch) → Policy engine (deterministic runtime)
The Skill helps you generate rules. The CLI is what actually runs them.
Before using CCH, ensure the binary is available in your system.
cch --versionExpected output:
cch 1.0.0
For machine-readable metadata:
cch --version --jsonExample:
{
"name": "cch",
"version": "1.0.0",
"api_version": 1,
"config_schema_version": 1,
"log_schema_version": 1
}This is what the CCH Skill uses to verify compatibility.
If cch is not found:
Download from GitHub Releases for:
- macOS (Intel / Apple Silicon)
- Linux (x86_64 / ARM64)
- Windows (x86_64)
Place it in your PATH.
cargo install --git https://github.com/.../cchJust ask Claude:
“Install CCH for this project.”
The skill will:
- detect your OS/arch
- download the correct binary
- verify installation
These commands initialize and register CCH in a repository.
Scaffold a new configuration:
cch initThis creates:
.claude/
hooks.yaml
context/
validators/
Including example rules and templates.
This does not activate anything yet. It only creates files.
To activate CCH, it must be registered as a hook handler.
cch install --projectThis modifies:
.claude/settings.json
And registers cch for lifecycle events.
| Flag | Scope |
|---|---|
--project |
Project only (recommended) |
--user |
Global (~/.claude/settings.json) |
--dry-run |
Preview changes |
--force |
Overwrite existing hooks |
These commands operate on your policy configuration.
cch validateChecks:
- YAML syntax
- Schema validity
- Referenced files exist
- Regex/glob correctness
- Validator scripts exist
Exit codes:
-
0→ valid - non-zero → errors found
Strict mode:
cch validate --strictTreats warnings as errors.
cch config --showShows the fully resolved configuration, including:
- project vs user precedence
- default values
- normalized paths
This is extremely useful for debugging inheritance.
CCH is designed to be explainable and auditable.
cch explain rule <rule-name>Example:
cch explain rule no-console-logOutputs:
- matchers
- actions
- mode (enforce / warn / audit)
- priority
- provenance metadata
- recent trigger stats
This is your primary policy introspection tool.
All runtime decisions are logged to:
~/.claude/logs/cch.log
Query them:
cch logsLogs are JSON Lines:
{
"timestamp": "2025-01-21T14:32:11Z",
"event": "PreToolUse",
"rule_name": "block-force-push",
"mode": "enforce",
"decision": "blocked",
"tool": "Bash"
}This enables:
- root cause analysis
- audit trails
- policy analytics
- compliance evidence
Verbose tracing:
cch debug pre-tool-useUsed with simulated events:
echo '{"tool_name":"Bash","tool_input":{"command":"git push --force"}}' | cch debug pre-tool-useOutputs:
- which rules were evaluated
- why matchers passed/failed
- execution timing
- final decision
This is essentially --trace for policy.
These commands are normally called by Claude Code itself.
They read JSON from stdin and return JSON to stdout.
cat event.json | cch <event-command>| Command | Lifecycle Event |
|---|---|
pre-tool-use |
Before tool executes |
post-tool-use |
After tool completes |
permission |
Permission request |
user-prompt |
User submits message |
session-start |
Session begins |
session-end |
Session ends |
pre-compact |
Before context compaction |
Create test input:
{
"tool_name": "Bash",
"tool_input": {
"command": "git push --force"
}
}Run:
cat test_event.json | cch pre-tool-useOutput:
{
"continue": false,
"reason": "🚫 Force push is not allowed."
}This is exactly what Claude Code consumes internally.
Remove CCH from a project:
cch uninstall --projectRemove from global scope:
cch uninstall --userThis:
- removes only CCH hooks
- preserves other Claude hooks
- does not delete your config files
When integrating CCH into scripts or CI:
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | General error |
| 2 | Configuration error |
| 3 | Validation failure |
| 4 | Validator script failed |
| 127 | Command not found |
| Component | When it runs |
|---|---|
| CCH Skill | On demand, during setup |
| CCH CLI | On every hook event |
| hooks.yaml | Loaded every event |
| validators | Executed conditionally |
| context md | Injected dynamically |
CCH is a local AI policy engine. Claude is subject to it. The Skill merely authors policies.
This is why CCH is:
- deterministic
- testable
- auditable
- safe for real governance
The CCH CLI is not just a helper tool.
It is:
A deterministic, local-first policy enforcement engine for AI agents.