Skip to content

fix: correct hooks schema and prevent clobbering existing hooks on install#257

Open
rahuldodwe wants to merge 1 commit intotirth8205:mainfrom
rahuldodwe:fix/hooks-schema-and-merge-clobber
Open

fix: correct hooks schema and prevent clobbering existing hooks on install#257
rahuldodwe wants to merge 1 commit intotirth8205:mainfrom
rahuldodwe:fix/hooks-schema-and-merge-clobber

Conversation

@rahuldodwe
Copy link
Copy Markdown

What this fixes

1. hooks/hooks.json — malformed and stale static template

  • SessionStart entry was missing the required "matcher" field
  • ${CLAUDE_PLUGIN_ROOT} is not a real Claude Code env var — silently expands to empty string at runtime, making the command fail
  • Commands and timeouts were diverged from what generate_hooks_config() actually writes (--skip-flows and timeout values were missing)

2. skills.py — shallow merge clobbers existing hooks

existing.update(hooks_config) replaced the entire hooks key on reinstall,
wiping any hooks from other tools already in .claude/settings.json.
Fixed with a deep merge: existing.setdefault("hooks", {}).update(hooks_config["hooks"])

3. tests/test_skills.py — merge test had a gap

test_merges_with_existing never asserted that OtherHook survived the merge,
so the clobber went undetected. Assertion added.

4. docs/TROUBLESHOOTING.md — stale reference

Pointed users at hooks/hooks.json as authoritative, but the installed config
comes from generate_hooks_config() in skills.py. Updated to point at
.claude/settings.json with the correct fix command.

…stall

- hooks/hooks.json: add missing matcher field to SessionStart entry,
  replace undefined \${CLAUDE_PLUGIN_ROOT} variable with the actual
  code-review-graph status command, and align commands/timeouts with
  what generate_hooks_config() writes (--skip-flows, timeout values)
- skills.py: deep-merge the hooks key instead of shallow-replacing it
  so pre-existing hooks from other tools are preserved on reinstall
- tests/test_skills.py: assert that OtherHook survives the merge;
  the previous test passed silently while the clobber went undetected
- docs/TROUBLESHOOTING.md: point users at .claude/settings.json
  instead of the stale hooks/hooks.json reference
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