Hooks
The chat runs Claude Code hook commands. A hook is a shell command that parmanu runs at a set point. It gets a JSON event on stdin and answers with its exit code and output. anu run and anu eval never run hooks.
Where hooks come from
parmanu reads the hooks key of these files, in this order:
~/.claude/settings.json(or$CLAUDE_CONFIG_DIR/settings.json), then~/.anu/settings.json. Skipped with--no-global.- In a trusted project (
anu trust):.claude/settings.json,.claude/settings.local.json,.anu/settings.json.
Hooks from every file run; none replaces another. --no-hooks turns them all off for one chat. /hooks lists what loaded.
{
"hooks": {
"PreToolUse": [
{ "matcher": "Bash", "hooks": [{ "type": "command", "command": "node .claude/no-rm.js", "timeout": 10 }] }
]
}
}timeout is in seconds (default 60). A hook still running at its timeout is killed with its children.
Events
| Event | When | Can it block? |
|---|---|---|
SessionStart | before the first message of a session in this chat (source: startup or resume) | no; its output is added below the message |
UserPromptSubmit | before each message goes to the model (prompt) | yes: the message is not sent |
PreToolUse | before a tool runs (tool_name, tool_input) | yes: the model gets the reason instead of the result |
PostToolUse | after a tool runs (tool_response too) | no; its output is added below the tool result |
Stop | when the agent ends its turn (stop_hook_active) | yes: the reason goes back to the agent as the next message |
SessionEnd | when a session that started in this chat ends (reason: clear on /new, prompt_input_exit when the chat closes) | no |
PreCompact | before the conversation is compacted (trigger: manual for /compact or auto; custom_instructions) | no |
Notification | when parmanu waits on you (message, notification_type: permission_prompt or elicitation_dialog) | no |
SubagentStop | when a subagent the task tool started ends its run (stop_hook_active) | yes: the reason goes back to the subagent, up to three times |
Every event also has session_id, cwd and hook_event_name. Hooks run with CLAUDE_PROJECT_DIR and ANU_PROJECT_DIR set to the project root.
matcher is a regular expression on the tool name, as Claude Code names them: Read, Write, Edit, Glob, Grep, Bash. An empty matcher or * matches every tool. Other parmanu tools use their own names. For PreCompact the matcher is matched against the trigger, for SessionEnd the reason, and for Notification the notification type.
Installed packages and Claude Code plugins can bring hooks too; see packages.
A Stop hook can send the agent back at most 3 times in a row. After that parmanu stops and shows the reason.
Answers
- Exit 0: success. If stdout is JSON, parmanu reads it (below). Plain stdout is context for
UserPromptSubmitandSessionStartand is ignored for the other events. - Exit 2: block. stderr is the reason.
- Any other exit: an error. parmanu shows a note and carries on.
The JSON fields parmanu reads:
"decision": "block"with"reason": blocks.hookSpecificOutput.permissionDecision: "deny"withpermissionDecisionReason: blocks a tool call.hookSpecificOutput.updatedInput: replaces the tool's arguments (PreToolUse).hookSpecificOutput.additionalContext: text added for the model.
parmanu asks before nothing on a hook's behalf: "allow" and "ask" decisions run the tool as usual.
This page is built from docs/hooks.md in parmanu 0.4.14.