Skip to content

Conversation

@kp222x
Copy link

@kp222x kp222x commented Dec 14, 2025

Summary

  • Fixes the validate-hook-schema.sh script to correctly handle both hook configuration formats
  • Previously, the script would fail with jq errors when validating plugin hooks/hooks.json files using the wrapper format that the skill itself recommends

Changes

  • Detect wrapper format by checking for .hooks key
  • Add helper function build_path() for constructing format-aware jq queries
  • Validate optional description field in wrapper format
  • Update all jq queries to use format-aware paths

Formats Now Supported

Plugin wrapper format (now works):

{
  "description": "Brief explanation",
  "hooks": {
    "PreToolUse": [...]
  }
}

Direct/settings format (still works):

{
  "PreToolUse": [...]
}

Test Plan

  • Tested plugin wrapper format - passes validation
  • Tested direct/settings format - passes validation (no regression)
  • Tested error detection - still catches invalid hooks

Test Evidence

Wrapper format (the bug case):

🔍 Validating hooks configuration: /tmp/test-wrapper-hooks.json

Checking JSON syntax...
✅ Valid JSON

Detecting hook format...
✅ Detected plugin wrapper format

Checking root structure...
✅ Root structure valid

Validating individual hooks...

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ All checks passed!

Direct format (regression check):

🔍 Validating hooks configuration: /tmp/test-direct-hooks.json

Checking JSON syntax...
✅ Valid JSON

Detecting hook format...
✅ Detected direct/settings format

Checking root structure...
✅ Root structure valid

Validating individual hooks...

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ All checks passed!

Fixes #13292

🤖 Generated with Claude Code

…a.sh

The validation script now correctly handles both hook configuration formats:
- Plugin wrapper format: {"description": "...", "hooks": {...}}
- Direct/settings format: {"PreToolUse": [...], ...}

Previously, the script would fail with jq errors when validating plugin
hooks.json files using the wrapper format that the skill itself recommends.

Changes:
- Detect wrapper format by checking for .hooks key
- Add helper function build_path() for constructing jq queries
- Validate optional description field in wrapper format
- Update all jq queries to use format-aware paths

Fixes anthropics#13292

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <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] plugin-dev:hook-development validate-hook-schema.sh doesn't support plugin wrapper format

1 participant