fix: wrap hooks.json in top-level "hooks" object for Claude Code schema#3
Open
zxh wants to merge 1 commit into
Open
fix: wrap hooks.json in top-level "hooks" object for Claude Code schema#3zxh wants to merge 1 commit into
zxh wants to merge 1 commit into
Conversation
Claude Code (tested on v2.1.112) validates plugin hooks.json against a schema
that requires a top-level "hooks" record whose keys are hook types. The
current file exposes "SessionStart" directly, which fails validation with:
Hook load failed: path ["hooks"] - Invalid input: expected record,
received undefined
As a result, gstack installs successfully but shows as "failed to load" and
the SessionStart hook never runs.
Also changes the matcher from "" to ".*" which is the documented pattern for
"match all" and is consistent with the format used by other published
plugins (e.g. superpowers).
Verified locally: after this change, gstack loads successfully ("✔ enabled")
on Claude Code 2.1.112.
There was a problem hiding this comment.
Pull request overview
Fixes Claude Code 2.1.x plugin hook schema validation by updating hooks/hooks.json to match the expected top-level structure so the SessionStart hook loads and runs reliably.
Changes:
- Wrap hook definitions under a top-level
"hooks"object (required by Claude Code schema validator). - Change the hook matcher from
""to".*"to use the documented “match all” pattern.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Problem
On Claude Code
v2.1.112(and at least recent 2.1.x versions), installinggstack@gstacksucceeds but the plugin shows as failed to load:The schema validator expects a top-level
hooksrecord whose keys are hook types (SessionStart,PreToolUse, etc.). The currenthooks/hooks.jsonexposesSessionStartat the root, so thehookskey is undefined and validation fails. Net effect: theensure-setup.shSessionStart hook never runs, so gstack does nothing on fresh sessions.Fix
Wrap the content in
{ "hooks": { ... } }, matching the format used by other published plugins (for example,obra/superpowersships its hooks.json this way, and the same format is used by user-level~/.claude/settings.jsonunderhooks).Also change the matcher from
""to".*"— the documented "match all" pattern, again consistent with superpowers and what Claude Code accepts without warnings.Diff
{ - "SessionStart": [ - { - "matcher": "", - "hooks": [ - { - "type": "command", - "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/ensure-setup.sh", - "timeout": 120 - } - ] - } - ] + "hooks": { + "SessionStart": [ + { + "matcher": ".*", + "hooks": [ + { + "type": "command", + "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/ensure-setup.sh", + "timeout": 120 + } + ] + } + ] + } }Verification
Tested locally on macOS (Apple Silicon) with
claude --version=2.1.112 (Claude Code):Before:
Status: ✘ failed to loadwith the error above.After applying this patch to the cached plugin copy (
~/.claude/plugins/cache/gstack/gstack/0.1.0/hooks/hooks.json) and re-listing:No other changes in behavior — the same
ensure-setup.shruns onSessionStartas before; it just actually runs now.Environment
claude plugins install gstack@gstackafterclaude plugins marketplace addScope
One-file, behavior-preserving schema fix. No skills or scripts touched.