fix: hooks.json schema validation fails with "Expected array, but received undefined"#288
Merged
tirth8205 merged 2 commits intotirth8205:mainfrom Apr 18, 2026
Merged
Conversation
Two issues caused Claude Code to reject the hooks config:
1. Events were nested inside {"hooks": {...}} wrapper — Claude Code
expects hook events at the top level of hooks.json
2. SessionStart entry was missing the required "matcher" field
Matches the schema documented at https://docs.anthropic.com/en/docs/claude-code/hooks
and the fix pattern from anthropics/claude-code#31278.
Fixes tirth8205#283
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Owner
|
This PR now conflicts with main after #257 was merged (both touch hooks.json). Could you rebase on main? Thanks! |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Open
7 tasks
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.
Fixes #283. The hooks.json had two schema violations that caused Claude Code to reject the config at startup:
What changed
Removed
{"hooks": {...}}wrapper — Claude Code expects hook events (SessionStart,PostToolUse, etc.) at the top level of hooks.json, not nested inside a"hooks"property. The extra nesting caused Claude Code to find the event keys but then fail to resolve the innerhooksarray (hence "Expected array, but received undefined").Added missing
"matcher"field toSessionStart— every hook entry requires a"matcher"(tool name, pipe-separated list, or""to match all). The SessionStart entry was missing it entirely.This matches the schema documented at https://docs.anthropic.com/en/docs/claude-code/hooks and the fix pattern from anthropics/claude-code#31278 (identical root cause in the ralph-loop plugin).
Before / After
I maintain PRISM, a post-session diagnostics tool for Claude Code — CLAUDE.md adherence analysis and session health scoring. Both tools do deeper analysis beyond surface-level code review.