Quick Start
1
Create a Hook with HookRegistry
2
Block Tool Execution
3
Hook with Matcher
User Interaction Flow
HookEvent
Events that hooks can subscribe to.HookInput
Data provided to hooks.Builder Methods
HookResult
Result returned from hook execution.Factory Methods
Instance Methods
HookDecision
Decision types for hook outputs.HookDefinition
Define individual hooks with functions and metadata.Methods
HookRegistry
Manages a collection of hooks.Methods
Common Patterns
Rate Limiter Hook
Best Practices
Subscribe to specific events
Subscribe to specific events
Only subscribe to events you need - reduces overhead and improves performance.
Use priority for ordering
Use priority for ordering
Hooks with higher priority run first. Use for security checks before logging.
Keep hooks fast
Keep hooks fast
Hooks run in the hot path - avoid expensive operations.
Return clear deny reasons
Return clear deny reasons
When denying, provide actionable error messages.
Related
Guardrails
Output validation
Callbacks
UI event handlers

