Hooks
Hooks run automatically — you don’t invoke them. They fire at points in the Claude Code lifecycle to capture your prompts and responses and keep the session’s context accurate.
| Hook | Claude Code event |
|---|---|
SessionStart | Claude Code launches |
UserPromptSubmit | You hit enter |
CwdChanged | You switch working directory |
PostCompact | You run /compact |
PostToolUse | A SendMessage tool call |
Stop | Claude finishes a turn |
What you’ll see
Section titled “What you’ll see”Almost nothing. The hooks are quiet by design.
SessionStart prints one line confirming what it found — your key, the OTEL settings, the Prism it’s talking to — and a notice when a newer plugin version has been published. After a plugin reload it also reminds you to restart.
Nothing else is printed unless you turn on the realtime summary:
/prism:config set show_realtime_summary trueThe plugin does not print prompt-quality coaching, rewrites, or context nudges. Scoring runs on the server; coaching surfaces on the dashboard (see Where coaching lives).
What each hook does
Section titled “What each hook does”SessionStart
Section titled “SessionStart”- Reads your API key from
~/.prism/config.json. If it’s missing or malformed, prints a setup prompt and exits without blocking the session. - Checks that the key still matches the Prism it was issued for, and says so if it doesn’t.
- Checks the OTEL settings in the scope the plugin is installed in, and warns if two scopes both carry them.
- Checks — at most once a day — whether a newer version has been published, and folds that into its one startup message. A failed check stays silent and reuses the last known answer.
UserPromptSubmit
Section titled “UserPromptSubmit”- Lets
/prism:…commands through immediately. - If no API key is configured, prints a setup reminder and exits 0 — the prompt still goes through.
- Captures the prompt to Prism.
The submit hook always exits 0. It never blocks or delays your prompt.
CwdChanged
Section titled “CwdChanged”Runs when you change working directory, so the session’s project context stays correct when you move between repositories mid-session.
PostCompact
Section titled “PostCompact”Runs after /compact completes, resetting the per-compaction session state so counting restarts from a clean baseline.
PostToolUse
Section titled “PostToolUse”Runs after a SendMessage tool call. Captures git and prompt “evidence” — the changes tied to the prompt that drove them — and queues it for Prism. /prism:status shows this evidence queue.
Runs after Claude finishes a turn. Measures the elapsed time and sends the response and the turn’s metadata to Prism. Delivery is queued on disk and retried until the server confirms receipt, so a network blip or a restart doesn’t lose a response — and retries never record the same response twice.
Error behavior
Section titled “Error behavior”Every hook catches its own exceptions and exits 0. Hooks are fail-open: if a step inside one fails, your session continues normally. Failure detail goes to the plugin debug log; /prism:doctor reports whether debug logging is on and which file it writes to.