Docs / Hooks
Where PinkyAI actually attaches
A hook is a small program Claude Code (or Cowork) calls at a fixed lifecycle point, feeding it JSON on stdin
and reading a verdict back. pinkyai install registers each event below once; every rule pack,
token-saving advisory, and audit mechanism this site describes runs from inside one of them.
The lifecycle events
- user-prompt-submit Runs once per prompt you send, before Claude sees it — where session-level advisories and budget nudges attach.
- pre-tool-use Runs before a tool call executes — where security rule packs and most token-saving guards attach; the only event that can deny.
- post-tool-use Runs after a tool call returns — where output auditing, redaction, and quarantine attach.
- pre-compact Runs right before Claude Code compacts context — where handoff notes and continuity guards attach.
- stop Runs when a session ends — informational only, never blocking: end-of-session summaries of subagent output and background tasks.
Run one directly with pinkyai hook <event>, feeding it the same JSON shape Claude Code would
— useful for debugging a specific advisory without triggering a whole session.
What runs by default
23 mechanisms run on a fresh install with nothing configured. Every other security guard waits
behind security.experimental, and every coaching advisory behind token_savings.coaching_enabled.
This list is generated from the engine's own mechanism table; pinkyai mechanisms --json prints the
same table, with each mechanism's tier and the reason for it, from your install.
- Security guards (9) deny_paths, project_jail, dangerous_commands, secrets, package_guard, git_guards, env_var_leak_guard, output_quarantine, repo_trust_check
- Token-saving guards (14) noop_edit_guard, dedupe, asset_guard, image_downscale_guard, pdf_page_range_advisor, notebook_output_stripper, fetch_cache, mcp_repeat_guard, retry_breaker, stale_rerun_guard, empty_search_guard, cache_keeper, foreground_server_guard, session_budget_advisor
Advisory vs. mandatory, and fail-open
Most token-saving hooks are advisory by default: they surface a nudge but don't block. Security rule packs can
be set to enforce, where a deny is real. Either way, PinkyAI's own hooks are built to fail open — if a hook
itself errors, the tool call it was evaluating proceeds and the failure is logged, never silently blocked by
a bug in the safety layer itself. pinkyai doctor and pinkyai audit-verify are the two
commands to check that hooks are actually installed and that the audit trail they write is intact.
Next: Reference MCPs →