Hooks validation error message contradicts its own example

Status Closed — duplicate
Maintainer reply None cached
Activity 3 comments · opened Mar 5, 2026 · closed Mar 9, 2026

Description

When configuring hooks in settings.json, the validation error message contradicts its own example format.

Steps to Reproduce

  1. Configure a hook with the old string-based matcher format:
"hooks": {
  "PostToolUse": [
    {
      "matcher": "Edit|Write",
      "command": "ruff check --fix $CLAUDE_FILE_PATH && ruff format $CLAUDE_FILE_PATH"
    }
  ]
}
  1. The error says:
hooks → PostToolUse → 0 → hooks: Expected array, but received undefined
  1. Update to use hooks array as suggested:
"hooks": {
  "PostToolUse": [
    {
      "matcher": "Edit|Write",
      "hooks": [
        {
          "type": "command",
          "command": "ruff check --fix $CLAUDE_FILE_PATH && ruff format $CLAUDE_FILE_PATH"
        }
      ]
    }
  ]
}
  1. Now the error says:
hooks → PostToolUse → 0 → matcher: Expected string, but received object

But the example in the very same error message shows matcher as an object:

Hooks use a new format with matchers. Example: {"PostToolUse": [{"matcher": {"tools": ["BashTool"]}, "hooks": [{"type": "command", "command": "echo Done"}]}]}

Expected Behavior

The validation error should not contradict its own example. Either:

  • The validator should accept matcher as an object (matching the provided example), or
  • The example in the error message should show the correct string-based format

Environment

  • Claude Code CLI
  • OS: Linux (RHEL 9)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗