Skip to content

Hooks Configuration

Hooks run commands or prompts in response to Claude Code events. Each key is a hook event name (PascalCase), mapping to an array of matchers.

Fields

Top-level hooks object (standalone hooks.json):

FieldTypeRequiredDescription
descriptionstringnoHuman-readable description
hooksobjectyesEvent-keyed hooks configuration

Hook Matcher

Each event maps to an array of matcher objects:

FieldTypeRequiredDescription
matcherstringnoPattern to match against (e.g., tool name for PreToolUse)
hooksobject[]yesArray of hook handlers

Hook Handler

FieldTypeRequiredDescription
typestringyescommand, prompt, or agent (valid values)
commandstringnoShell command (when type is command)
promptstringnoPrompt text (when type is prompt)
agentstringnoAgent name (when type is agent)
timeoutnumbernoTimeout in milliseconds
statusMessagestringnoStatus message shown during execution
oncebooleannoRun only once per session
modelstringnoModel override for this hook
asyncbooleannoRun hook asynchronously (non-blocking)

Example

json
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "echo 'Bash tool invoked'",
            "timeout": 5000
          }
        ]
      }
    ],
    "SessionStart": [
      {
        "hooks": [
          {
            "type": "prompt",
            "prompt": "Review the project README before starting work."
          }
        ]
      }
    ]
  }
}