fix: valid Claude Code hook schema + merge existing hooks on install#203
Open
lngyeen wants to merge 1 commit intotirth8205:mainfrom
Open
fix: valid Claude Code hook schema + merge existing hooks on install#203lngyeen wants to merge 1 commit intotirth8205:mainfrom
lngyeen wants to merge 1 commit intotirth8205:mainfrom
Conversation
Two fixes for Claude Code hooks integration: 1. Hook schema: use proper Claude Code format with nested hooks array and remove unsupported PreCommit event. Narrow PostToolUse matcher from Edit|Write|Bash to Edit|Write since Bash commands do not directly modify source files. (cherry-picked from PR tirth8205#180) 2. Merge logic: install_hooks now merges new entries into existing hooks instead of overwriting them. Creates a backup of settings.json before modification. (based on PR tirth8205#145) Closes tirth8205#97, tirth8205#114, tirth8205#172.
This was referenced Apr 11, 2026
Owner
|
This PR addresses the hooks schema bug (#97, #114, #172, #188, #191, #201) which is still not fixed in main. The current skills.py:generate_hooks_config() still generates the invalid schema. This PR provides exactly what's needed: proper nested hooks arrays, removal of PreCommit/SessionStart (invalid events), narrowed PostToolUse matcher, and merge-based installation with backup. Worth reviving — this is the #1 most-reported bug in the issue tracker. |
This was referenced Apr 11, 2026
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
hooks: [{type, command}]arrays instead of flatcommand:fields. Remove unsupportedPreCommitevent. Narrow PostToolUse matcher fromEdit|Write|BashtoEdit|Writesince Bash commands don't directly modify source files.install_hooks()now merges new entries into existing hooks instead of overwriting them viaexisting.update(). Creates asettings.json.bakbackup before modification.Motivation
code-review-graph installgenerates invalidsettings.jsonthat causes Claude Code to fail on startup with:Additionally, the
existing.update(hooks_config)call replaces the entirehookskey, silently destroying user-defined hooks (e.g., linters, formatters, safety checks).Closes #97, #114, #172
Changes
skills.py:generate_hooks_config()skills.py:install_hooks()tests/test_skills.pyTest plan