Hooks validation error message contradicts its own example
Resolved 💬 3 comments Opened Mar 5, 2026 by rickyltwong Closed Mar 9, 2026
Description
When configuring hooks in settings.json, the validation error message contradicts its own example format.
Steps to Reproduce
- Configure a hook with the old string-based
matcherformat:
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"command": "ruff check --fix $CLAUDE_FILE_PATH && ruff format $CLAUDE_FILE_PATH"
}
]
}
- The error says:
hooks → PostToolUse → 0 → hooks: Expected array, but received undefined
- Update to use
hooksarray as suggested:
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "ruff check --fix $CLAUDE_FILE_PATH && ruff format $CLAUDE_FILE_PATH"
}
]
}
]
}
- 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
matcheras 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)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗