PostToolUse API

January 4, 2026 ยท View on GitHub

Available when inheriting from ClaudeHooks::PostToolUse:

Input Helpers

Input helpers to access the data provided by Claude Code through STDIN.

๐Ÿ“š Shared input helpers

MethodDescription
tool_nameGet the name of the tool that was used
tool_inputGet the input that was passed to the tool
tool_responseGet the tool's response/output
tool_use_idGet the unique identifier for this tool use (e.g., "toolu_01ABC123...")

Hook State Helpers

Hook state methods are helpers to modify the hook's internal state (output_data) before yielding back to Claude Code.

๐Ÿ“š Shared hook state methods

MethodDescription
block_tool!(reason)Block the tool result from being used
approve_tool!(reason)Clear any previous block decision (default behavior)
add_additional_context!(context)Add context for Claude to consider after tool use

Output Helpers

Output helpers provide access to the hook's output data and helper methods for working with the output state.

๐Ÿ“š Shared output helpers

MethodDescription
output.decisionGet the decision: "block" or nil (default)
output.reasonGet the reason that was set for the decision
output.blocked?Check if the tool result has been blocked
output.additional_contextGet the additional context that was added

Hook Exit Codes

Exit CodeBehavior
exit 0Operation continues
STDOUT shown to user in transcript mode
exit 1Non-blocking error
STDERR shown to user
exit 2N/A
STDERR shown to Claude (tool already ran)