Fix hook validator to support plugin wrapper format and optional matchers#27204
Open
christian-schlichtherle wants to merge 1 commit intoanthropics:mainfrom
Open
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
validate-hook-schema.sh: Auto-detect plugin wrapper format ({"hooks": {...}}) vs direct settings format, so the validator correctly processes all existing pluginhooks.jsonfiles instead of failing to find events at the root levelvalidate-hook-schema.sh: Makematcherfield 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.Relates to #24529, #27145
Test plan
validate-hook-schema.shagainst all 5 plugin hooks.json files — all passhooksarray, invalid types, etc.)🤖 Generated with Claude Code