Setup API

July 14, 2026 ยท View on GitHub

Available when inheriting from ClaudeHooks::Setup:

Runs once during Claude Code startup (before any session begins). Use it to inject global context or perform one-time initialization.

Input Helpers

๐Ÿ“š Shared input helpers

MethodDescription
sourceStartup reason: 'init' (first launch) or 'maintenance'

Hook State Helpers

๐Ÿ“š Shared hook state methods

MethodDescription
add_additional_context!(context)Add contextual information for Claude
add_context!(context)Alias for add_additional_context!

Output Helpers

๐Ÿ“š Shared output helpers

MethodDescription
output.additional_contextGet the additional context that was added

Hook Exit Codes

Exit CodeBehavior
exit 0Continues normally; STDOUT added as context
exit 2N/A โ€” non-blocking event