Skip to content

dispatch

dispatch

Hook dispatch: select matching hooks, run their handlers, and translate HookResult into the Claude Code stdout envelope.

execute_hook

execute_hook(
    entry: RegisteredHook,
    evt: BaseHookEvent,
    session_dir: Path | None = None,
) -> HookResult | None

Execute a single registered hook, respecting max_fires and persisting fire count.

format_output

format_output(
    event: Event, result: HookResult
) -> dict[str, Any] | None

Render a HookResult as the JSON envelope Claude Code expects on stdout for event.

dispatch

dispatch(
    event: Event,
    evt: BaseHookEvent,
    session_dir: Path | None = None,
    *,
    async_: bool = False,
) -> dict[str, Any] | None

Dispatch an event to all matching hooks and return the combined result.