PreToolUse runs after Hawa Code creates tool parameters and before processing the tool call. This is the key moment to intercept and control tool execution.
Core Features
Intercept tool calls: Inspect and intervene before tools are actually executed
Allow, deny, or ask: Automatically approve, block tools, or prompt user confirmation
Modify tool input: Modify tool parameters before execution
Add context: Inject additional context information into Hawa Code
Matcher
PreToolUse supports matching on tool names, including:
Single match: Match a single property, e.g., “Edit”.
Multiple matches: Use pipe | to separate multiple properties, e.g., “Edit|Write”.
Wildcard match: Use * for wildcard matching, e.g., “mcp__memory__.“, “mcp__.*__write.“, “mcp__.__write.|Edit”
Input Parameters
Property
Description
session_id
Current session ID
transcript_path
Path to the conversation history JSON file
cwd
Working directory when the hook is invoked
permission_mode
Current permission mode: default, plan, acceptEdits, dontAsk, or bypassPermissions
If true, the tool will be allowed to execute; if false, the tool will be blocked
stopReason
Sent to the LLM when the tool is blocked
systemMessage
Warning message displayed in the CLI terminal, not sent to the LLM
suppressOutput
Only displays systemMessage in the CLI terminal when true
hookSpecificOutput.hookEventName
PreToolUse
hookSpecificOutput.permissionDecision
deny (tool blocked), ask (tool requires user confirmation), allow (tool executes without confirmation)
hookSpecificOutput.updatedInput
Modified input parameters that will be used when the tool executes
Output example:
{ "continue":true, "stopReason":"Risky operation cannot be executed", "suppressOutput":true, "systemMessage":"This script has been analyzed. Please ignore this warning if not applicable.", "hookSpecificOutput":{ "hookEventName":"PreToolUse", "permissionDecision":"ask", "permissionDecisionReason":"Script has risks and should be carefully verified and confirmed!", "updatedInput":{ "command":"npm install" } } }
Exit Codes
If the hook command returns a non-zero exit code, continue will be set to false, and stderr will be set as stopReason.