Skip to content

Commit 29f2607

Browse files
sjnimsclaude
andauthored
docs(plugin-structure): fix hooks.json format with required wrapper (#92)
## Summary Fixes incorrect hooks.json examples in the plugin-structure skill that were missing the required `"hooks"` wrapper object. ## Problem Fixes #90 All hooks.json examples in the plugin-structure skill showed an incorrect format that would cause plugins created from these examples to have broken hooks. The examples were missing the required `"hooks"` wrapper: **Before (incorrect):** ```json { "PreToolUse": [...] } ``` **After (correct):** ```json { "hooks": { "PreToolUse": [...] } } ``` ## Solution Updated all 4 affected files to use the correct wrapper format, consistent with the hook-development skill and official documentation: - `plugins/plugin-dev/skills/plugin-structure/SKILL.md` - `plugins/plugin-dev/skills/plugin-structure/examples/standard-plugin.md` - `plugins/plugin-dev/skills/plugin-structure/examples/advanced-plugin.md` - `plugins/plugin-dev/skills/plugin-structure/references/component-patterns.md` ### Alternatives Considered None - this is a documentation correctness fix with a single correct answer. ## Changes - Added `"hooks"` wrapper object to all hooks.json code examples - No functional changes, documentation only ## Testing - [x] All tests passing (N/A - documentation only) - [x] Linting passes --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent 885107d commit 29f2607

4 files changed

Lines changed: 106 additions & 98 deletions

File tree

plugins/plugin-dev/skills/plugin-structure/SKILL.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,16 @@ hooks/
224224

225225
```json
226226
{
227-
"PreToolUse": [{
228-
"matcher": "Write|Edit",
229-
"hooks": [{
230-
"type": "command",
231-
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/validate.sh",
232-
"timeout": 30
227+
"hooks": {
228+
"PreToolUse": [{
229+
"matcher": "Write|Edit",
230+
"hooks": [{
231+
"type": "command",
232+
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/validate.sh",
233+
"timeout": 30
234+
}]
233235
}]
234-
}]
236+
}
235237
}
236238
```
237239

plugins/plugin-dev/skills/plugin-structure/examples/advanced-plugin.md

Lines changed: 65 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -629,69 +629,71 @@ bash ${CLAUDE_PLUGIN_ROOT}/skills/kubernetes-ops/scripts/validate-manifest.sh de
629629

630630
```json
631631
{
632-
"PreToolUse": [
633-
{
634-
"matcher": "Write|Edit",
635-
"hooks": [
636-
{
637-
"type": "command",
638-
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/security/scan-secrets.sh",
639-
"timeout": 30
640-
}
641-
]
642-
},
643-
{
644-
"matcher": "Bash",
645-
"hooks": [
646-
{
647-
"type": "prompt",
648-
"prompt": "Evaluate if this bash command is safe for production environment. Check for destructive operations, missing safeguards, and potential security issues. Commands should be idempotent and reversible.",
649-
"timeout": 20
650-
}
651-
]
652-
}
653-
],
654-
"PostToolUse": [
655-
{
656-
"matcher": "Bash",
657-
"hooks": [
658-
{
659-
"type": "command",
660-
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/workflow/update-status.sh",
661-
"timeout": 15
662-
}
663-
]
664-
}
665-
],
666-
"Stop": [
667-
{
668-
"matcher": ".*",
669-
"hooks": [
670-
{
671-
"type": "command",
672-
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/quality/check-config.sh",
673-
"timeout": 45
674-
},
675-
{
676-
"type": "command",
677-
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/workflow/notify-team.sh",
678-
"timeout": 30
679-
}
680-
]
681-
}
682-
],
683-
"SessionStart": [
684-
{
685-
"matcher": ".*",
686-
"hooks": [
687-
{
688-
"type": "command",
689-
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/security/validate-permissions.sh",
690-
"timeout": 20
691-
}
692-
]
693-
}
694-
]
632+
"hooks": {
633+
"PreToolUse": [
634+
{
635+
"matcher": "Write|Edit",
636+
"hooks": [
637+
{
638+
"type": "command",
639+
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/security/scan-secrets.sh",
640+
"timeout": 30
641+
}
642+
]
643+
},
644+
{
645+
"matcher": "Bash",
646+
"hooks": [
647+
{
648+
"type": "prompt",
649+
"prompt": "Evaluate if this bash command is safe for production environment. Check for destructive operations, missing safeguards, and potential security issues. Commands should be idempotent and reversible.",
650+
"timeout": 20
651+
}
652+
]
653+
}
654+
],
655+
"PostToolUse": [
656+
{
657+
"matcher": "Bash",
658+
"hooks": [
659+
{
660+
"type": "command",
661+
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/workflow/update-status.sh",
662+
"timeout": 15
663+
}
664+
]
665+
}
666+
],
667+
"Stop": [
668+
{
669+
"matcher": ".*",
670+
"hooks": [
671+
{
672+
"type": "command",
673+
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/quality/check-config.sh",
674+
"timeout": 45
675+
},
676+
{
677+
"type": "command",
678+
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/workflow/notify-team.sh",
679+
"timeout": 30
680+
}
681+
]
682+
}
683+
],
684+
"SessionStart": [
685+
{
686+
"matcher": ".*",
687+
"hooks": [
688+
{
689+
"type": "command",
690+
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/security/validate-permissions.sh",
691+
"timeout": 20
692+
}
693+
]
694+
}
695+
]
696+
}
695697
}
696698
```
697699

plugins/plugin-dev/skills/plugin-structure/examples/standard-plugin.md

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -426,30 +426,32 @@ See language-specific guides for:
426426

427427
```json
428428
{
429-
"PreToolUse": [
430-
{
431-
"matcher": "Write|Edit",
432-
"hooks": [
433-
{
434-
"type": "prompt",
435-
"prompt": "Before modifying code, verify it meets our coding standards from the code-standards skill. Check formatting, naming conventions, and documentation. If standards aren't met, suggest improvements.",
436-
"timeout": 30
437-
}
438-
]
439-
}
440-
],
441-
"Stop": [
442-
{
443-
"matcher": ".*",
444-
"hooks": [
445-
{
446-
"type": "command",
447-
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/validate-commit.sh",
448-
"timeout": 45
449-
}
450-
]
451-
}
452-
]
429+
"hooks": {
430+
"PreToolUse": [
431+
{
432+
"matcher": "Write|Edit",
433+
"hooks": [
434+
{
435+
"type": "prompt",
436+
"prompt": "Before modifying code, verify it meets our coding standards from the code-standards skill. Check formatting, naming conventions, and documentation. If standards aren't met, suggest improvements.",
437+
"timeout": 30
438+
}
439+
]
440+
}
441+
],
442+
"Stop": [
443+
{
444+
"matcher": ".*",
445+
"hooks": [
446+
{
447+
"type": "command",
448+
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/validate-commit.sh",
449+
"timeout": 45
450+
}
451+
]
452+
}
453+
]
454+
}
453455
}
454456
```
455457

plugins/plugin-dev/skills/plugin-structure/references/component-patterns.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,12 @@ hooks/
306306
**hooks.json**:
307307
```json
308308
{
309-
"PreToolUse": [...],
310-
"PostToolUse": [...],
311-
"Stop": [...],
312-
"SessionStart": [...]
309+
"hooks": {
310+
"PreToolUse": [...],
311+
"PostToolUse": [...],
312+
"Stop": [...],
313+
"SessionStart": [...]
314+
}
313315
}
314316
```
315317

0 commit comments

Comments
 (0)