Hooks
Your own shell commands at fixed points: to check, block or add context.
| Event | When it runs |
|---|---|
| SessionStart | a conversation starts |
| UserPromptSubmit | you send a message, before PHRONEN reads it |
| PreToolUse | before a tool runs — can block it |
| PostToolUse | after a tool ran |
| Stop | PHRONEN is about to finish its turn |
.phronen/settings.jsonjson
{
"hooks": {
"PreToolUse": [
{ "matcher": "Bash", "hooks": [{ "type": "command", "command": "./scripts/check-command.sh", "timeout": 30 }] }
],
"PostToolUse": [
{ "matcher": "Edit|Write", "hooks": [{ "type": "command", "command": "npx prettier --write \"$(jq -r .tool_input.file_path)\"" }] }
]
}
}- The hook gets a JSON object on stdin: session_id, cwd, event, and — as they apply — tool_name, tool_input, tool_result, prompt.
- Exit code 2 blocks the action; what the hook wrote to stderr is shown to PHRONEN as the reason.
- Printing {"decision": "block", "reason": "…"} on stdout does the same; {"additionalContext": "…"} adds context instead.
- Any other exit lets the action proceed. matcher is a tool name or glob; several are separated by |. timeout is in seconds (default 60).
Was this page helpful?