When the following data structure is returned, Hawa Code will end normally:
{"ok":true}
When the following data structure is returned, Hawa Code will continue working, and reason will be sent to the model as the reason for continuing:
{"ok":false,"reason":"your explanation"}
Exit Code Format
Exit code 0: Success, Hawa Code will stop the task
Exit code 2: Failure, Hawa Code will continue working, and stderr will be sent to the model as the reason for continuing
Configuration Methods
Prompt Method
Configure the prompt using the $ARGUMENTS placeholder:
{ "hooks":{ "Stop":[ { "hooks":[ { "type":"prompt", "prompt":"Evaluate if Hawa Code should stop: $ARGUMENTS. Check if all tasks are complete." } ] } ] } }
When the following data structure is returned, Hawa Code will end normally:
{"ok":true}
When the following data structure is returned, Hawa Code will continue working, and reason will be sent to the model as the reason for continuing:
{"ok":false,"reason":"your explanation"}
Exit Code Format
Exit code 0: Success, Hawa Code will stop the task
Exit code 2: Failure, Hawa Code will continue working, and stderr will be sent to the model as the reason for continuing
Configuration Methods
Prompt Method
Configure the prompt using the $ARGUMENTS placeholder:
{ "hooks":{ "SubagentStop":[ { "hooks":[ { "type":"prompt", "prompt":"Evaluate if Hawa Code should stop: $ARGUMENTS. Check if all tasks are complete." } ] } ] } }
Triggered before the Subagent starts execution. Unlike Stop and SubagentStop, the SubagentStart Hook does not prevent the Subagent from executing, but can provide suggestions or warnings to the Subagent through the model or shell scripts.
{ "hookSpecificOutput":{ "hookEventName":"SubagentStart", "additionalContext":"Please follow security guidelines: Do not access production databases" } }
Configuration Methods
Prompt Method
Provide suggestions to the Subagent through the model:
Use matcher to match Subagent names
Use pipe | to match multiple names, e.g., Explore|Test
Use * to match all Subagents
{ "hooks":{ "SubagentStart":[ { "matcher":"Explore", "hooks":[ { "type":"prompt", "prompt":"Review this subagent task: $ARGUMENTS. If the task description is vague or potentially dangerous, warn the user." } ] } ] } }
Current working directory when the hook was invoked
permission_mode
string
Current permission mode: "default", "plan", "acceptEdits", "dontAsk", or "bypassPermissions"
hook_event_name
string
Always "PostToolUse"
tool_name
string
Name of the executed tool (e.g., Write, Edit, Bash, etc.)
tool_input
object
Tool input parameters (varies by tool)
tool_response
object
Tool response result (varies by tool)
tool_use_id
string
Unique identifier for the tool invocation
Note: The exact schema for tool_input and tool_response depends on the specific tool.
Output Parameters / Decision Control
PostToolUse hooks can provide feedback to Hawa Code after tool execution.
"block": Block subsequent operations and prompt Hawa Code with reason
undefined: Do nothing. reason is ignored.
"hookSpecificOutput.additionalContext": Add additional context for Hawa Code
{ "decision":"block" | undefined, "reason":"Explanation for decision", "hookSpecificOutput":{ "hookEventName":"PostToolUse", "additionalContext":"Additional information for Hawa Code" } }
Field Descriptions
Field
Type
Description
decision
string | undefined
"block" to block and show reason, or undefined to do nothing
reason
string
Explanation for the decision
hookSpecificOutput
object
Hook-specific output information
hookSpecificOutput.hookEventName
string
Always "PostToolUse"
hookSpecificOutput.additionalContext
string
Additional context information for Hawa Code
Exit Code Behavior
Simple Exit Codes
Hooks communicate status through exit codes, stdout, and stderr:
Exit code 0: Success. stdout is shown to the user.
Exit code 2: Blocking error. Shows stderr to Hawa Code (tool has run). Format is [command]: {stderr}.
Other exit codes: Non-blocking error. Shown in stderr.
PostToolUse-Specific Exit Code 2 Behavior
Hook Event
Behavior
PostToolUse
Shows stderr to Hawa Code (tool has run)
PostToolUseFailure
PostToolUseFailure triggers when a tool execution fails. This event is triggered when a tool call throws an error or returns a failure result. Useful for logging failures, sending alerts, or providing corrective feedback to Hawa Code.
Matching: Matches by tool name, supports the same matcher values as PreToolUse.
Input Parameters
PostToolUseFailure hooks receive the same tool_name and tool_input fields as PostToolUse, along with error information as top-level fields:
Field
Description
tool_name
Tool name
tool_input
Parameters sent to the tool
tool_use_id
Unique identifier for the tool use
error
String describing what went wrong
is_interrupt
Optional boolean indicating if the failure was caused by user interruption
Input Example
{ "session_id":"abc123", "transcript_path":"/Users/.../.hcode/projects/.../00893aaf-19fa-41d2-8238-13269b9b3ca0.jsonl", "cwd":"/Users/...", "permission_mode":"default", "hook_event_name":"PostToolUseFailure", "tool_name":"Bash", "tool_input":{ "command":"npm test", "description":"Run test suite" }, "tool_use_id":"toolu_01ABC123...", "error":"Command exited with non-zero status code 1", "is_interrupt":false }
Output Parameters / Decision Control
PostToolUseFailure hooks can provide context to Hawa Code after a tool failure. In addition to the JSON output fields available to all hooks, the following event-specific fields can be returned:
Field
Description
additionalContext
Additional context for Hawa Code to consider, provided along with the error message
Output Example
{ "hookSpecificOutput":{ "hookEventName":"PostToolUseFailure", "additionalContext":"Additional information about the failure for Hawa Code" } }
Exit Code Behavior
Exit Code
Behavior
0
Success, parses JSON response from stdout
Non-zero
Failure, hook output is ignored
SessionEnd
SessionEnd triggers when a Hawa Code session terminates. Suitable for cleanup tasks, logging session statistics, or saving session state.
Note: Since SessionEnd triggers when the session ends, it cannot block session termination and only supports type: "command" hooks.
Key Features
Attribute
Description
Trigger Timing
When session terminates
Can Block
No - Cannot prevent session termination
Supported Hook Types
Only command
Decision Control
None - For side effects only (logging, cleanup, etc.)
Matcher Support
SessionEnd supports using matchers to filter by session end reason:
Matcher
Trigger Timing
clear
When using /clear command to clear session
other
Other exit reasons (normal exit, abnormal exit, etc.)
SessionEnd hooks have no specific output requirements. The script’s stdout and stderr will be logged but will not affect the session termination process.