[DOCS] Fix incorrect JSON schema example for `hooks` in settings.md documentation
Documentation Type
Unclear/confusing documentation
Documentation Location
https://code.claude.com/docs/en/settings
Section/Topic
The "Available settings" table, specifically the Example column for the hooks key.
Current Documentation
In the table row for the hooks setting, the example provided is:
{"PreToolUse": {"Bash": "echo 'Running command...'"}}
What's Wrong or Missing?
The JSON structure provided in the settings.md example contradicts the actual schema defined in the Hooks reference documentation.
The settings.md example implies a simplified key-value map structure:{ "Event": { "Tool": "Command" } }
However, hooks.md explicitly defines the structure as an array of matcher objects containing an array of hook definitions:
{
"hooks": {
"EventName": [
{
"matcher": "ToolPattern",
"hooks": [
{
"type": "command",
"command": "your-command-here"
}
]
}
]
}
}
Users following the example in settings.md will likely encounter validation errors or the hooks will fail to load because the structure is invalid according to the schema.
Suggested Improvement
Update the example in the settings.md table to match the valid schema defined in hooks.md.
Proposed Change:
Replace:
{"PreToolUse": {"Bash": "echo 'Running command...'"}}
With:
{"PreToolUse": [{"matcher": "Bash", "hooks": [{"type": "command", "command": "echo 'Running command...'"}]}]}
Impact
High - Prevents users from using a feature
Additional Context
This discrepancy creates confusion for users trying to configure hooks via settings.json. The hooks.md documentation appears to be the source of truth regarding the schema, as it details the matcher and hooks array requirements.
Reference:
- Incorrect Example: https://code.claude.com/docs/en/settings#available-settings
- Correct Schema: https://code.claude.com/docs/en/hooks#structure
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗