Skip to content

fix: correct Claude Code hook schema and add git pre-commit hook#208

Merged
tirth8205 merged 1 commit intotirth8205:mainfrom
aroragarvit:fix/claude-code-hooks-schema
Apr 11, 2026
Merged

fix: correct Claude Code hook schema and add git pre-commit hook#208
tirth8205 merged 1 commit intotirth8205:mainfrom
aroragarvit:fix/claude-code-hooks-schema

Conversation

@aroragarvit
Copy link
Copy Markdown
Contributor

Problem

Running code-review-graph install --platform claude-code writes a
.claude/settings.json with an invalid hook schema. Claude Code throws
a Settings Error on startup and skips the entire file, so none of the
automation (PostToolUse, SessionStart) ever runs.

Fixes #201 #188

Root cause

Three bugs in generate_hooks_config() in skills.py:

  1. Hook entries had a bare "command" key — Claude Code v1.x+ requires
    a nested "hooks": [{"type": "command", ...}] array
  2. "PreCommit" is not a valid Claude Code hook event type. Its presence
    caused the "Invalid key in record" error that made Claude Code skip
    the entire file
  3. Timeout values of 5000/3000 were interpreted as seconds (per docs),
    meaning 83 and 50 minutes

Fix

  • Correct the hook schema to match the Claude Code v1.x+ spec
  • Remove PreCommit (never valid in any Claude Code release)
  • Fix timeouts to sensible values (30s, 10s)
  • Replace the lost pre-commit intent with a real git pre-commit hook
    via install_git_hook(), which appends to existing hooks safely

Testing

  • unit tests updated and passing
  • Manually verified: install --platform claude-code now produces a
    valid settings file and a working .git/hooks/pre-commit

@tirth8205 tirth8205 merged commit 0b79169 into tirth8205:main Apr 11, 2026
1 check passed
tirth8205 added a commit that referenced this pull request Apr 11, 2026
Unreleased fixes since v2.2.2 that users are complaining about:
- #208 Claude Code hook schema (fixes #97, #138, #163, #168, #172, #182,
  #188, #191, #201) — v2.2.2 generates an invalid hooks schema and
  timeouts in ms instead of seconds; PreCommit is also not a real event.
- #205 SQLite transaction nesting (fixes #110, #135, #181) — implicit
  transactions from the legacy sqlite3 default caused "cannot start a
  transaction within a transaction" on update.
- #166 Go method receivers resolved from field_identifier.
- #170 UTF-8 decode errors in detect_changes (fixes #169).
- #142 --platform target filters (fixes #133).
- #213 / #183 large-repo community detection hangs.
- #220 CI lint + tomllib on Python 3.10.
- #159 missing pytest-cov dev dep.
- #154 JSX component CALLS edges.

Plus features: #177 Codex, #165 Luau (#153), #217 REFERENCES edge,
#215 recurse_submodules, #185 gitignore default (#175), #171 gitignore
docs (#157).

Verified locally on Python 3.11: ruff clean, mypy clean, bandit clean,
691 tests pass, coverage 73.72%.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tirth8205 tirth8205 mentioned this pull request Apr 11, 2026
5 tasks
tirth8205 added a commit that referenced this pull request Apr 11, 2026
Unreleased fixes since v2.2.2 that users are complaining about:
- #208 Claude Code hook schema (fixes #97, #138, #163, #168, #172, #182,
  #188, #191, #201) — v2.2.2 generates an invalid hooks schema and
  timeouts in ms instead of seconds; PreCommit is also not a real event.
- #205 SQLite transaction nesting (fixes #110, #135, #181) — implicit
  transactions from the legacy sqlite3 default caused "cannot start a
  transaction within a transaction" on update.
- #166 Go method receivers resolved from field_identifier.
- #170 UTF-8 decode errors in detect_changes (fixes #169).
- #142 --platform target filters (fixes #133).
- #213 / #183 large-repo community detection hangs.
- #220 CI lint + tomllib on Python 3.10.
- #159 missing pytest-cov dev dep.
- #154 JSX component CALLS edges.

Plus features: #177 Codex, #165 Luau (#153), #217 REFERENCES edge,
#215 recurse_submodules, #185 gitignore default (#175), #171 gitignore
docs (#157).

Verified locally on Python 3.11: ruff clean, mypy clean, bandit clean,
691 tests pass, coverage 73.72%.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

Bug: Claude Code fails to start — invalid hooks schema in .claude/settings.json

2 participants