Skip to content

HookConfigCommand

Base classes

Name Children Inherits
ClaudeCodeBaseModel
clawd_code_sdk.models.base
Base model for all Claude Code Pydantic models.

⋔ Inheritance diagram

graph TD
  1496997270["settings.HookConfigCommand"]
  2604142835["base.ClaudeCodeBaseModel"]
  3879467795["main.BaseModel"]
  2751680898["builtins.object"]
  2604142835 --> 1496997270
  3879467795 --> 2604142835
  2751680898 --> 3879467795

🛈 DocStrings

Bases: ClaudeCodeBaseModel

Bash command hook.

Source code in src/clawd_code_sdk/models/settings.py
class HookConfigCommand(ClaudeCodeBaseModel):
    """Bash command hook."""

    model_config = ConfigDict(
        extra="forbid",
    )
    type: Literal["command"] = "command"
    """
    Hook type
    """
    command: str = Field(..., min_length=1)
    """
    Shell command to execute
    """
    timeout: float | None = Field(None, gt=0.0)
    """
    Optional timeout in seconds (default: 600; lowered to 30 on UserPromptSubmit and 10 on MessageDisplay)
    """
    on_failure: Literal["continue", "block"] | None = Field(None, alias="onFailure")
    """
    Whether the action that triggered the hook goes ahead when the hook fails: it can't start, exits with a code other than 0 or 2, times out, or prints invalid JSON. "block" does what exit code 2 does on that event, and denies the request on PermissionRequest. Leaving it unset isn't always the same as "continue". No effect on Stop, SubagentStop, TaskCompleted, and TeammateIdle hooks, or when async or asyncRewake is set. Requires Claude Code v2.1.295 or later. See https://code.claude.com/docs/en/hooks#block-the-action-when-a-hook-fails
    """
    async_: bool | None = Field(None, alias="async")
    """
    Run this hook asynchronously without blocking Claude Code
    """
    async_rewake: bool | None = Field(None, alias="asyncRewake")
    """
    When true, the hook runs in the background and wakes the model when it exits with code 2. Implies async.
    """
    shell: Literal["bash", "powershell"] | None = None
    """
    Shell interpreter for the command. "bash" uses the login shell (bash/zsh/sh); "powershell" uses pwsh. Defaults to bash.
    """
    if_: str | None = Field(None, alias="if")
    """
    Optional permission-rule-syntax filter (e.g., "Bash(git *)"). Evaluated only on tool-related events (PreToolUse, PostToolUse, PostToolUseFailure, PermissionRequest, PermissionDenied); on other events a hook with `if` set never runs. See https://code.claude.com/docs/en/hooks-guide#filter-hooks-with-matchers
    """
    status_message: str | None = Field(None, alias="statusMessage")
    """
    Custom spinner message displayed while the hook runs
    """
    args: list[str] | None = None
    """
    Argument list for exec form. When present, spawns the command directly without shell interpretation — each element is passed as-is, so path placeholders never need quoting. See https://code.claude.com/docs/en/hooks#command-hook-fields
    """

args class-attribute instance-attribute

args: list[str] | None = None

Argument list for exec form. When present, spawns the command directly without shell interpretation — each element is passed as-is, so path placeholders never need quoting. See https://code.claude.com/docs/en/hooks#command-hook-fields

async_ class-attribute instance-attribute

async_: bool | None = Field(None, alias='async')

Run this hook asynchronously without blocking Claude Code

async_rewake class-attribute instance-attribute

async_rewake: bool | None = Field(None, alias='asyncRewake')

When true, the hook runs in the background and wakes the model when it exits with code 2. Implies async.

command class-attribute instance-attribute

command: str = Field(..., min_length=1)

Shell command to execute

if_ class-attribute instance-attribute

if_: str | None = Field(None, alias='if')

Optional permission-rule-syntax filter (e.g., "Bash(git *)"). Evaluated only on tool-related events (PreToolUse, PostToolUse, PostToolUseFailure, PermissionRequest, PermissionDenied); on other events a hook with if set never runs. See https://code.claude.com/docs/en/hooks-guide#filter-hooks-with-matchers

on_failure class-attribute instance-attribute

on_failure: Literal['continue', 'block'] | None = Field(None, alias='onFailure')

Whether the action that triggered the hook goes ahead when the hook fails: it can't start, exits with a code other than 0 or 2, times out, or prints invalid JSON. "block" does what exit code 2 does on that event, and denies the request on PermissionRequest. Leaving it unset isn't always the same as "continue". No effect on Stop, SubagentStop, TaskCompleted, and TeammateIdle hooks, or when async or asyncRewake is set. Requires Claude Code v2.1.295 or later. See https://code.claude.com/docs/en/hooks#block-the-action-when-a-hook-fails

shell class-attribute instance-attribute

shell: Literal['bash', 'powershell'] | None = None

Shell interpreter for the command. "bash" uses the login shell (bash/zsh/sh); "powershell" uses pwsh. Defaults to bash.

status_message class-attribute instance-attribute

status_message: str | None = Field(None, alias='statusMessage')

Custom spinner message displayed while the hook runs

timeout class-attribute instance-attribute

timeout: float | None = Field(None, gt=0.0)

Optional timeout in seconds (default: 600; lowered to 30 on UserPromptSubmit and 10 on MessageDisplay)

type class-attribute instance-attribute

type: Literal['command'] = 'command'

Hook type

:fa-brands-github: Show source on GitHub