Skip to content

HookMatcher

Base classes

Name Children Inherits
BaseModel
pydantic.main
!!! abstract "Usage Documentation"

⋔ Inheritance diagram

graph TD
  3322567370["hooks.HookMatcher"]
  3879467795["main.BaseModel"]
  2751680898["builtins.object"]
  3879467795 --> 3322567370
  2751680898 --> 3879467795

🛈 DocStrings

Bases: BaseModel

Hook matcher configuration.

Source code in src/clawd_code_sdk/models/hooks.py
class HookMatcher(BaseModel):
    """Hook matcher configuration."""

    # See https://docs.anthropic.com/en/docs/claude-code/hooks#structure for the
    # expected string value. For example, for PreToolUse, the matcher can be
    # a tool name like "Bash" or a combination of tool names like
    # "Write|MultiEdit|Edit".
    matcher: str | None = None
    # A list of Python functions with function signature HookCallback
    hooks: Sequence[HookCallback] = field(default_factory=list)
    # Timeout in seconds for all hooks in this matcher (default: 60)
    timeout: float | None = None
    on_failure: Literal["continue", "block"] | None = None
    """What to do when a hook callback fails (raises, times out).

    ``"continue"`` ignores the failure, ``"block"`` fails closed and blocks the action.
    Requires a CLI that reports ``hook_on_failure_supported``.
    """

on_failure class-attribute instance-attribute

on_failure: Literal['continue', 'block'] | None = None

What to do when a hook callback fails (raises, times out).

"continue" ignores the failure, "block" fails closed and blocks the action. Requires a CLI that reports hook_on_failure_supported.

:fa-brands-github: Show source on GitHub