Skip to content

Fix hook validator to support plugin wrapper format and optional matchers#27204

Open
christian-schlichtherle wants to merge 1 commit intoanthropics:mainfrom
christian-schlichtherle:fix/plugin-hook-validator-and-docs
Open

Fix hook validator to support plugin wrapper format and optional matchers#27204
christian-schlichtherle wants to merge 1 commit intoanthropics:mainfrom
christian-schlichtherle:fix/plugin-hook-validator-and-docs

Conversation

@christian-schlichtherle

Summary

  • Fix validate-hook-schema.sh: Auto-detect plugin wrapper format ({"hooks": {...}}) vs direct settings format, so the validator correctly processes all existing plugin hooks.json files instead of failing to find events at the root level
  • Fix validate-hook-schema.sh: Make matcher field optional for all events (it defaults to matching everything when omitted). Previously the validator required it, but all real plugins (hookify, ralph-wiggum, learning-output-style, etc.) omit it. A warning is now shown only for PreToolUse/PostToolUse where an explicit matcher is typically desirable.
  • Fix SKILL.md docs: The "Plugin Hook Configuration" section incorrectly showed the direct format instead of the wrapper format that all plugins actually use
  • Fix component-patterns.md docs: The hooks.json example incorrectly showed the direct format

Relates to #24529, #27145

Test plan

  • Ran validate-hook-schema.sh against all 5 plugin hooks.json files — all pass
  • Verify the validator still catches actual errors (missing hooks array, invalid types, etc.)
  • Review documentation changes match actual plugin conventions

🤖 Generated with Claude Code

…hers

The validate-hook-schema.sh script failed to validate plugin hooks.json files
because it expected event names at the root level, but all plugins use the
wrapper format ({"hooks": {...}}). The validator also incorrectly required a
"matcher" field for all events, but matcher is optional (defaults to matching
everything when omitted) and most real plugins omit it.

Changes:
- Auto-detect plugin wrapper format vs direct settings format
- Make matcher optional for all events (warn only for PreToolUse/PostToolUse)
- Fix SKILL.md "Plugin Hook Configuration" section to show wrapper format
- Fix component-patterns.md hooks.json example to show wrapper format

Relates to anthropics#24529, anthropics#27145

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Christian Schlichtherle <christian@schlichtherle.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant