@amsterdamdatalabs/enact-extensions 0.1.0 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/README.md +96 -21
  2. package/dist/index.d.ts +5 -3
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +3 -2
  5. package/dist/index.js.map +1 -1
  6. package/dist/install.d.ts +171 -1
  7. package/dist/install.d.ts.map +1 -1
  8. package/dist/install.js +402 -49
  9. package/dist/install.js.map +1 -1
  10. package/dist/internal/codex.d.ts.map +1 -1
  11. package/dist/internal/codex.js +7 -1
  12. package/dist/internal/codex.js.map +1 -1
  13. package/dist/internal/platform.d.ts +8 -0
  14. package/dist/internal/platform.d.ts.map +1 -1
  15. package/dist/internal/platform.js +46 -2
  16. package/dist/internal/platform.js.map +1 -1
  17. package/dist/provision.d.ts +30 -0
  18. package/dist/provision.d.ts.map +1 -0
  19. package/dist/provision.js +202 -0
  20. package/dist/provision.js.map +1 -0
  21. package/dist/validate/index.d.ts +44 -0
  22. package/dist/validate/index.d.ts.map +1 -1
  23. package/dist/validate/index.js +157 -0
  24. package/dist/validate/index.js.map +1 -1
  25. package/extensions/cmux/.agents/plugin.json +37 -0
  26. package/extensions/cmux/skills/cmux/SKILL.md +82 -0
  27. package/extensions/cmux/skills/cmux/agents/openai.yaml +4 -0
  28. package/extensions/cmux/skills/cmux/references/handles-and-identify.md +35 -0
  29. package/extensions/cmux/skills/cmux/references/panes-surfaces.md +37 -0
  30. package/extensions/cmux/skills/cmux/references/trigger-flash-and-health.md +23 -0
  31. package/extensions/cmux/skills/cmux/references/windows-workspaces.md +31 -0
  32. package/extensions/cmux/skills/cmux-vm-monitor/SKILL.md +122 -0
  33. package/extensions/cmux/skills/cmux-vm-monitor/agents/openai.yaml +4 -0
  34. package/extensions/cmux/skills/cmux-vm-monitor/references/cmux-commands.md +66 -0
  35. package/extensions/cmux/skills/cmux-vm-monitor/scripts/codex_vm_monitor.sh +45 -0
  36. package/extensions/cmux/skills/cmux-workspace/SKILL.md +93 -0
  37. package/extensions/dev-state/.agents/plugin.json +35 -0
  38. package/extensions/dev-state/skills/dev-state-plan-graduation/SKILL.md +194 -0
  39. package/extensions/dev-state/skills/dev-state-plan-graduation/agents/openai.yaml +4 -0
  40. package/extensions/dev-state/skills/dev-state-plan-graduation/references/reference.md +130 -0
  41. package/extensions/devops/.agents/plugin.json +36 -0
  42. package/extensions/devops/skills/azure-devops-cli/SKILL.md +431 -0
  43. package/extensions/devops/skills/azure-devops-cli/agents/openai.yaml +4 -0
  44. package/extensions/devops/skills/ci-pipeline-strategy/SKILL.md +217 -0
  45. package/extensions/devops/skills/ci-pipeline-strategy/agents/openai.yaml +4 -0
  46. package/extensions/enact-context/.agents/plugin.json +40 -0
  47. package/extensions/enact-context/.mcp.json +8 -0
  48. package/extensions/enact-context/README.md +25 -0
  49. package/extensions/enact-context/assets/icon.png +0 -0
  50. package/extensions/enact-context/assets/logo.png +0 -0
  51. package/extensions/enact-context/hooks/hooks.json +115 -0
  52. package/extensions/enact-context/skills/enact-context/SKILL.md +149 -0
  53. package/extensions/enact-context/skills/enact-context/scripts/install.sh +69 -0
  54. package/extensions/enact-factory/.agents/plugin.json +42 -0
  55. package/extensions/enact-factory/.mcp.json +8 -0
  56. package/extensions/enact-factory/assets/icon.png +0 -0
  57. package/extensions/enact-factory/assets/logo.png +0 -0
  58. package/extensions/enact-factory/hooks/user-prompt-submit.mjs +67 -0
  59. package/extensions/enact-factory/skills/testing-strategy/SKILL.md +167 -0
  60. package/extensions/enact-factory/skills/workitem-triage/SKILL.md +22 -0
  61. package/extensions/enact-operator/.agents/plugin.json +57 -0
  62. package/extensions/enact-operator/.app.json +3 -0
  63. package/extensions/enact-operator/.mcp.json +10 -0
  64. package/extensions/enact-operator/_taxonomy.md +86 -0
  65. package/extensions/enact-operator/agents/README.md +5 -0
  66. package/extensions/enact-operator/agents/architect.toml +25 -0
  67. package/extensions/enact-operator/agents/code-reviewer.toml +24 -0
  68. package/extensions/enact-operator/agents/critic.toml +30 -0
  69. package/extensions/enact-operator/agents/executor.toml +24 -0
  70. package/extensions/enact-operator/agents/explore.toml +23 -0
  71. package/extensions/enact-operator/agents/planner.toml +24 -0
  72. package/extensions/enact-operator/agents/verifier.toml +24 -0
  73. package/extensions/enact-operator/assets/icon.png +0 -0
  74. package/extensions/enact-operator/assets/logo.png +0 -0
  75. package/extensions/enact-operator/commands/doctor.md +39 -0
  76. package/extensions/enact-operator/commands/setup.md +51 -0
  77. package/extensions/enact-operator/hooks/hooks.json +146 -0
  78. package/extensions/enact-operator/skills/_variants.md +44 -0
  79. package/extensions/enact-operator/skills/ai-slop-cleaner/SKILL.md +50 -0
  80. package/extensions/enact-operator/skills/analyze/SKILL.md +91 -0
  81. package/extensions/enact-operator/skills/ask/SKILL.md +47 -0
  82. package/extensions/enact-operator/skills/autopilot/SKILL.md +170 -0
  83. package/extensions/enact-operator/skills/autoresearch-goal/SKILL.md +79 -0
  84. package/extensions/enact-operator/skills/cancel/SKILL.md +99 -0
  85. package/extensions/enact-operator/skills/configure-notifications/SKILL.md +77 -0
  86. package/extensions/enact-operator/skills/deep-interview/SKILL.md +80 -0
  87. package/extensions/enact-operator/skills/doctor/SKILL.md +48 -0
  88. package/extensions/enact-operator/skills/hud/SKILL.md +49 -0
  89. package/extensions/enact-operator/skills/hyperplan/SKILL.md +47 -0
  90. package/extensions/enact-operator/skills/plan/SKILL.md +78 -0
  91. package/extensions/enact-operator/skills/ralph/SKILL.md +201 -0
  92. package/extensions/enact-operator/skills/ralph/gemini.md +18 -0
  93. package/extensions/enact-operator/skills/ralplan/SKILL.md +151 -0
  94. package/extensions/enact-operator/skills/remove-deadcode/SKILL.md +45 -0
  95. package/extensions/enact-operator/skills/research/SKILL.md +74 -0
  96. package/extensions/enact-operator/skills/review/SKILL.md +58 -0
  97. package/extensions/enact-operator/skills/security-research/SKILL.md +54 -0
  98. package/extensions/enact-operator/skills/setup/SKILL.md +91 -0
  99. package/extensions/enact-operator/skills/setup/scripts/install.sh +50 -0
  100. package/extensions/enact-operator/skills/skill/SKILL.md +82 -0
  101. package/extensions/enact-operator/skills/tdd/SKILL.md +59 -0
  102. package/extensions/enact-operator/skills/team/SKILL.md +199 -0
  103. package/extensions/enact-operator/skills/trace/SKILL.md +41 -0
  104. package/extensions/enact-operator/skills/ultragoal/SKILL.md +99 -0
  105. package/extensions/enact-operator/skills/ultraqa/SKILL.md +113 -0
  106. package/extensions/enact-operator/skills/ultrawork/SKILL.md +145 -0
  107. package/extensions/enact-operator/skills/ultrawork/planner.md +28 -0
  108. package/extensions/enact-operator/skills/wiki/SKILL.md +41 -0
  109. package/extensions/enact-operator/skills/work-with-workitem/SKILL.md +51 -0
  110. package/extensions/enact-wiki/.agents/plugin.json +42 -0
  111. package/extensions/enact-wiki/.mcp.json +15 -0
  112. package/extensions/enact-wiki/README.md +44 -0
  113. package/extensions/enact-wiki/assets/icon.png +0 -0
  114. package/extensions/enact-wiki/assets/logo.png +0 -0
  115. package/extensions/enact-wiki/skills/document-parser/SKILL.md +17 -0
  116. package/extensions/enact-wiki/skills/document-parser/scripts/parse.sh +60 -0
  117. package/extensions/enact-wiki/skills/document-parser/skill.json +9 -0
  118. package/extensions/enact-wiki/skills/enact-wiki/SKILL.md +30 -0
  119. package/extensions/enact-wiki/skills/enact-wiki/references/ingest.md +62 -0
  120. package/extensions/enact-wiki/skills/enact-wiki/references/manage.md +34 -0
  121. package/extensions/enact-wiki/skills/enact-wiki/references/query.md +59 -0
  122. package/extensions/enact-wiki/skills/search-lab/SKILL.md +57 -0
  123. package/extensions/enact-wiki/skills/search-lab/scripts/analyze.ts +23 -0
  124. package/{plugins/net-revenue-management/.codex-plugin → extensions/net-revenue-management/.agents}/plugin.json +10 -6
  125. package/extensions/plugin-dev/.agents/plugin.json +42 -0
  126. package/extensions/plugin-dev/.mcp.json +3 -0
  127. package/extensions/plugin-dev/agents/agent-creator.md +199 -0
  128. package/extensions/plugin-dev/agents/plugin-validator.md +91 -0
  129. package/extensions/plugin-dev/agents/skill-reviewer.md +212 -0
  130. package/extensions/plugin-dev/commands/_archive/create-marketplace.md +427 -0
  131. package/extensions/plugin-dev/commands/_archive/plugin-dev-guide.md +12 -0
  132. package/extensions/plugin-dev/commands/create-plugin.md +498 -0
  133. package/extensions/plugin-dev/commands/start.md +81 -0
  134. package/extensions/plugin-dev/hooks/hooks.json +3 -0
  135. package/extensions/plugin-dev/skills/agent-development/SKILL.md +641 -0
  136. package/extensions/plugin-dev/skills/agent-development/examples/agent-creation-prompt.md +250 -0
  137. package/extensions/plugin-dev/skills/agent-development/examples/complete-agent-examples.md +461 -0
  138. package/extensions/plugin-dev/skills/agent-development/references/advanced-agent-fields.md +246 -0
  139. package/extensions/plugin-dev/skills/agent-development/references/agent-creation-system-prompt.md +216 -0
  140. package/extensions/plugin-dev/skills/agent-development/references/permission-modes-rules.md +226 -0
  141. package/extensions/plugin-dev/skills/agent-development/references/system-prompt-design.md +464 -0
  142. package/extensions/plugin-dev/skills/agent-development/references/triggering-examples.md +474 -0
  143. package/extensions/plugin-dev/skills/agent-development/scripts/create-agent-skeleton.sh +176 -0
  144. package/extensions/plugin-dev/skills/agent-development/scripts/test-agent-trigger.sh +227 -0
  145. package/extensions/plugin-dev/skills/agent-development/scripts/validate-agent.sh +227 -0
  146. package/extensions/plugin-dev/skills/command-development/SKILL.md +763 -0
  147. package/extensions/plugin-dev/skills/command-development/examples/plugin-commands.md +612 -0
  148. package/extensions/plugin-dev/skills/command-development/examples/simple-commands.md +527 -0
  149. package/extensions/plugin-dev/skills/command-development/references/advanced-workflows.md +762 -0
  150. package/extensions/plugin-dev/skills/command-development/references/documentation-patterns.md +769 -0
  151. package/extensions/plugin-dev/skills/command-development/references/frontmatter-reference.md +508 -0
  152. package/extensions/plugin-dev/skills/command-development/references/interactive-commands.md +966 -0
  153. package/extensions/plugin-dev/skills/command-development/references/marketplace-considerations.md +943 -0
  154. package/extensions/plugin-dev/skills/command-development/references/plugin-features-reference.md +637 -0
  155. package/extensions/plugin-dev/skills/command-development/references/plugin-integration.md +191 -0
  156. package/extensions/plugin-dev/skills/command-development/references/skill-tool.md +447 -0
  157. package/extensions/plugin-dev/skills/command-development/references/testing-strategies.md +723 -0
  158. package/extensions/plugin-dev/skills/command-development/scripts/check-frontmatter.sh +234 -0
  159. package/extensions/plugin-dev/skills/command-development/scripts/validate-command.sh +160 -0
  160. package/extensions/plugin-dev/skills/hook-development/SKILL.md +861 -0
  161. package/extensions/plugin-dev/skills/hook-development/examples/load-context.sh +55 -0
  162. package/extensions/plugin-dev/skills/hook-development/examples/validate-bash.sh +57 -0
  163. package/extensions/plugin-dev/skills/hook-development/examples/validate-write.sh +48 -0
  164. package/extensions/plugin-dev/skills/hook-development/references/advanced.md +871 -0
  165. package/extensions/plugin-dev/skills/hook-development/references/hook-input-schemas.md +145 -0
  166. package/extensions/plugin-dev/skills/hook-development/references/migration.md +392 -0
  167. package/extensions/plugin-dev/skills/hook-development/references/patterns.md +430 -0
  168. package/extensions/plugin-dev/skills/hook-development/scripts/README.md +181 -0
  169. package/extensions/plugin-dev/skills/hook-development/scripts/hook-linter.sh +153 -0
  170. package/extensions/plugin-dev/skills/hook-development/scripts/test-hook.sh +276 -0
  171. package/extensions/plugin-dev/skills/hook-development/scripts/validate-hook-schema.sh +159 -0
  172. package/extensions/plugin-dev/skills/mcp-integration/SKILL.md +775 -0
  173. package/extensions/plugin-dev/skills/mcp-integration/examples/http-server.json +20 -0
  174. package/extensions/plugin-dev/skills/mcp-integration/examples/sse-server.json +19 -0
  175. package/extensions/plugin-dev/skills/mcp-integration/examples/stdio-server.json +38 -0
  176. package/extensions/plugin-dev/skills/mcp-integration/examples/ws-server.json +26 -0
  177. package/extensions/plugin-dev/skills/mcp-integration/references/authentication.md +601 -0
  178. package/extensions/plugin-dev/skills/mcp-integration/references/server-discovery.md +190 -0
  179. package/extensions/plugin-dev/skills/mcp-integration/references/server-types.md +572 -0
  180. package/extensions/plugin-dev/skills/mcp-integration/references/tool-usage.md +623 -0
  181. package/extensions/plugin-dev/skills/plugin-dev-guide/SKILL.md +222 -0
  182. package/extensions/plugin-dev/skills/plugin-structure/SKILL.md +705 -0
  183. package/extensions/plugin-dev/skills/plugin-structure/examples/advanced-plugin.md +774 -0
  184. package/extensions/plugin-dev/skills/plugin-structure/examples/minimal-plugin.md +83 -0
  185. package/extensions/plugin-dev/skills/plugin-structure/examples/standard-plugin.md +611 -0
  186. package/extensions/plugin-dev/skills/plugin-structure/references/advanced-topics.md +289 -0
  187. package/extensions/plugin-dev/skills/plugin-structure/references/component-patterns.md +592 -0
  188. package/extensions/plugin-dev/skills/plugin-structure/references/github-actions.md +233 -0
  189. package/extensions/plugin-dev/skills/plugin-structure/references/headless-ci-mode.md +193 -0
  190. package/extensions/plugin-dev/skills/plugin-structure/references/manifest-reference.md +625 -0
  191. package/extensions/plugin-dev/skills/plugin-structure/references/output-styles.md +116 -0
  192. package/extensions/plugin-dev/skills/skill-development/SKILL.md +564 -0
  193. package/extensions/plugin-dev/skills/skill-development/examples/complete-skill.md +465 -0
  194. package/extensions/plugin-dev/skills/skill-development/examples/frontmatter-templates.md +167 -0
  195. package/extensions/plugin-dev/skills/skill-development/examples/minimal-skill.md +111 -0
  196. package/extensions/plugin-dev/skills/skill-development/references/advanced-frontmatter.md +225 -0
  197. package/extensions/plugin-dev/skills/skill-development/references/commands-vs-skills.md +39 -0
  198. package/extensions/plugin-dev/skills/skill-development/references/skill-creation-workflow.md +379 -0
  199. package/extensions/plugin-dev/skills/skill-development/references/skill-creator-original.md +210 -0
  200. package/package.json +8 -11
  201. package/scripts/enact-extensions.mjs +823 -21
  202. package/scripts/hooks/session-start-drift-check.mjs +58 -0
  203. package/scripts/lib/build-index.mjs +50 -0
  204. package/scripts/lib/bundle-hash.mjs +137 -0
  205. package/scripts/lib/hooks.mjs +741 -0
  206. package/scripts/lib/ledger.mjs +163 -0
  207. package/scripts/lib/list-bundles.mjs +70 -0
  208. package/scripts/lib/outdated.mjs +144 -0
  209. package/scripts/lib/provision-mcp.mjs +16 -0
  210. package/scripts/lib/resolve-bundle.mjs +121 -0
  211. package/scripts/lib/run-install.mjs +402 -38
  212. package/scripts/lib/run-prune.mjs +73 -0
  213. package/scripts/lib/run-sync.mjs +9 -1
  214. package/scripts/lib/run-uninstall.mjs +244 -0
  215. package/scripts/lib/run-update.mjs +152 -0
  216. package/scripts/lib/run-validate.mjs +21 -18
  217. package/scripts/lib/serve.mjs +472 -0
  218. package/scripts/postinstall.mjs +63 -0
  219. package/scripts/setup-enact-context.sh +2 -2
  220. package/scripts/version-bump.sh +463 -0
  221. package/spec/codex.json +1 -11
  222. package/spec/index.json +59 -0
  223. package/web/assets/README.md +111 -0
  224. package/web/assets/logo-full.png +0 -0
  225. package/web/assets/logo-slim.png +0 -0
  226. package/web/assets/tokens/base.css +45 -0
  227. package/web/assets/tokens/colors.css +248 -0
  228. package/web/assets/tokens/effects.css +24 -0
  229. package/web/assets/tokens/fonts.css +8 -0
  230. package/web/assets/tokens/index.css +18 -0
  231. package/web/assets/tokens/spacing.css +50 -0
  232. package/web/index.html +1188 -0
  233. package/.agents/plugins/marketplace.json +0 -20
  234. package/catalog/enact-context.json +0 -9
  235. package/catalog/enact-factory.json +0 -7
  236. package/catalog/enact-operator.json +0 -7
  237. package/catalog/enact-wiki.json +0 -7
  238. package/catalog/net-revenue-management.json +0 -8
  239. package/scripts/rename-supervisor-to-operator.pl +0 -66
  240. package/scripts/sync-manifests.mjs +0 -23
  241. package/scripts/validate-catalog.mjs +0 -37
  242. package/scripts/validate-plugin.mjs +0 -10
  243. /package/{plugins → extensions}/net-revenue-management/.mcp.json +0 -0
  244. /package/{plugins → extensions}/net-revenue-management/skills/net-revenue-risks/SKILL.md +0 -0
  245. /package/{plugins → extensions}/net-revenue-management/skills/net-revenue-scenario/SKILL.md +0 -0
@@ -0,0 +1,861 @@
1
+ ---
2
+ name: hook-development
3
+ description: This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", "scoped hooks", "frontmatter hooks", "hook in skill", "hook in agent", "agent hook type", "async hooks", "once handler", "statusMessage", "hook decision control", "TeammateIdle hook", "TaskCompleted hook", or mentions hook events (PreToolUse, PermissionRequest, PostToolUse, PostToolUseFailure, Stop, SubagentStop, SubagentStart, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification, TeammateIdle, TaskCompleted). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.
4
+ ---
5
+
6
+ # Hook Development for Claude Code Plugins
7
+
8
+ ## Overview
9
+
10
+ Hooks are event-driven automation scripts that execute in response to Claude Code events. Use hooks to validate operations, enforce policies, add context, and integrate external tools into workflows.
11
+
12
+ **Key capabilities:**
13
+
14
+ - Validate tool calls before execution (PreToolUse)
15
+ - React to tool results (PostToolUse)
16
+ - Enforce completion standards (Stop, SubagentStop)
17
+ - Load project context (SessionStart)
18
+ - Automate workflows across the development lifecycle
19
+
20
+ ## Hook Types
21
+
22
+ ### Prompt-Based Hooks (Recommended)
23
+
24
+ Use LLM-driven decision making for context-aware validation:
25
+
26
+ ```json
27
+ {
28
+ "type": "prompt",
29
+ "prompt": "Evaluate if this tool use is appropriate: $TOOL_INPUT",
30
+ "timeout": 30
31
+ }
32
+ ```
33
+
34
+ **Supported events:** Stop, SubagentStop, UserPromptSubmit, PreToolUse
35
+
36
+ **Response format:**
37
+
38
+ Prompt hooks must return:
39
+
40
+ ```json
41
+ { "ok": true, "reason": "Explanation of decision" }
42
+ ```
43
+
44
+ - `ok: true` -- approve/allow the action
45
+ - `ok: false` -- block/deny the action
46
+ - `reason` -- required when `ok: false`, fed back to Claude
47
+ - Default model: Haiku
48
+
49
+ **Benefits:**
50
+
51
+ - Context-aware decisions based on natural language reasoning
52
+ - Flexible evaluation logic without bash scripting
53
+ - Better edge case handling
54
+ - Easier to maintain and extend
55
+
56
+ ### Command Hooks
57
+
58
+ Execute bash commands for deterministic checks:
59
+
60
+ ```json
61
+ {
62
+ "type": "command",
63
+ "command": "bash ${CLAUDE_PLUGIN_ROOT}/scripts/validate.sh",
64
+ "timeout": 60
65
+ }
66
+ ```
67
+
68
+ **Use for:**
69
+
70
+ - Fast deterministic validations
71
+ - File system operations
72
+ - External tool integrations
73
+ - Performance-critical checks
74
+
75
+ ### Agent Hooks
76
+
77
+ Use an LLM agent for complex, multi-step verification that requires tool access:
78
+
79
+ ```json
80
+ {
81
+ "type": "agent",
82
+ "prompt": "Verify all generated code has tests and passes linting",
83
+ "timeout": 120
84
+ }
85
+ ```
86
+
87
+ **Supported events:** Stop, SubagentStop
88
+
89
+ Agent hooks spawn a subagent that can use tools (Read, Bash, etc.) for thorough verification — useful when prompt hooks lack sufficient context or tool access. See `references/advanced.md` for patterns.
90
+
91
+ ## Hook Configuration Formats
92
+
93
+ ### Plugin hooks.json Format
94
+
95
+ **For plugin hooks** in `hooks/hooks.json`, use wrapper format:
96
+
97
+ ```json
98
+ {
99
+ "description": "Brief explanation of hooks (optional)",
100
+ "hooks": {
101
+ "PreToolUse": [...],
102
+ "Stop": [...],
103
+ "SessionStart": [...]
104
+ }
105
+ }
106
+ ```
107
+
108
+ **Key points:**
109
+
110
+ - `description` field is optional
111
+ - `hooks` field is required wrapper containing actual hook events
112
+ - This is the **plugin-specific format**
113
+
114
+ **Example:**
115
+
116
+ ```json
117
+ {
118
+ "description": "Validation hooks for code quality",
119
+ "hooks": {
120
+ "PreToolUse": [
121
+ {
122
+ "matcher": "Write",
123
+ "hooks": [
124
+ {
125
+ "type": "command",
126
+ "command": "${CLAUDE_PLUGIN_ROOT}/hooks/validate.sh"
127
+ }
128
+ ]
129
+ }
130
+ ]
131
+ }
132
+ }
133
+ ```
134
+
135
+ ### Settings Format (Direct)
136
+
137
+ **For user settings** in `.claude/settings.json`, use direct format:
138
+
139
+ ```json
140
+ {
141
+ "PreToolUse": [...],
142
+ "Stop": [...],
143
+ "SessionStart": [...]
144
+ }
145
+ ```
146
+
147
+ **Key points:**
148
+
149
+ - No wrapper - events directly at top level
150
+ - No description field
151
+ - This is the **settings format**
152
+
153
+ **Important:** The examples below show the hook event structure that goes inside either format. For plugin hooks.json, wrap these in `{"hooks": {...}}`.
154
+
155
+ ## Hook Events
156
+
157
+ ### PreToolUse
158
+
159
+ Execute before any tool runs. Use to approve, deny, or modify tool calls.
160
+
161
+ **Example (prompt-based):**
162
+
163
+ ```json
164
+ {
165
+ "PreToolUse": [
166
+ {
167
+ "matcher": "Write|Edit",
168
+ "hooks": [
169
+ {
170
+ "type": "prompt",
171
+ "prompt": "Validate file write safety. Check: system paths, credentials, path traversal, sensitive content. Return 'approve' or 'deny'."
172
+ }
173
+ ]
174
+ }
175
+ ]
176
+ }
177
+ ```
178
+
179
+ **Output for PreToolUse:**
180
+
181
+ ```json
182
+ {
183
+ "hookSpecificOutput": {
184
+ "permissionDecision": "allow|deny|ask",
185
+ "updatedInput": { "field": "modified_value" }
186
+ },
187
+ "systemMessage": "Explanation for Claude"
188
+ }
189
+ ```
190
+
191
+ ### PermissionRequest
192
+
193
+ Execute when user is shown a permission dialog. Use to automatically allow or deny permissions.
194
+
195
+ **Example:**
196
+
197
+ ```json
198
+ {
199
+ "PermissionRequest": [
200
+ {
201
+ "matcher": "Bash",
202
+ "hooks": [
203
+ {
204
+ "type": "command",
205
+ "command": "bash ${CLAUDE_PLUGIN_ROOT}/scripts/check-permission.sh"
206
+ }
207
+ ]
208
+ }
209
+ ]
210
+ }
211
+ ```
212
+
213
+ **Output for PermissionRequest:**
214
+
215
+ ```json
216
+ {
217
+ "hookSpecificOutput": {
218
+ "decision": {
219
+ "behavior": "allow|deny",
220
+ "updatedInput": { "command": "modified command" },
221
+ "message": "Reason for denial",
222
+ "interrupt": false
223
+ }
224
+ }
225
+ }
226
+ ```
227
+
228
+ - `behavior`: "allow" to approve, "deny" to reject
229
+ - `updatedInput`: Optional modified tool parameters (only with "allow")
230
+ - `message`: Explanation shown to user (only with "deny")
231
+ - `interrupt`: If true with "deny", stops the current operation
232
+
233
+ **Use cases:**
234
+
235
+ - Auto-approve safe commands matching patterns
236
+ - Block dangerous operations with explanations
237
+ - Modify tool inputs before execution
238
+
239
+ ### PostToolUse
240
+
241
+ Execute after tool completes. Use to react to results, provide feedback, or log.
242
+
243
+ **Example:**
244
+
245
+ ```json
246
+ {
247
+ "PostToolUse": [
248
+ {
249
+ "matcher": "Edit",
250
+ "hooks": [
251
+ {
252
+ "type": "prompt",
253
+ "prompt": "Analyze edit result for potential issues: syntax errors, security vulnerabilities, breaking changes. Provide feedback."
254
+ }
255
+ ]
256
+ }
257
+ ]
258
+ }
259
+ ```
260
+
261
+ **Output behavior:**
262
+
263
+ - Exit 0: stdout shown in transcript
264
+ - Exit 2: stderr fed back to Claude
265
+ - systemMessage included in context
266
+
267
+ ### PostToolUseFailure
268
+
269
+ Execute when a tool fails after PostToolUse hooks have run. Use to handle errors or provide fallback actions.
270
+
271
+ **Example:**
272
+
273
+ ```json
274
+ {
275
+ "PostToolUseFailure": [
276
+ {
277
+ "matcher": "Edit",
278
+ "hooks": [
279
+ {
280
+ "type": "prompt",
281
+ "prompt": "Error occurred during edit. Provide fallback action or ask for user input."
282
+ }
283
+ ]
284
+ }
285
+ ]
286
+ }
287
+ ```
288
+
289
+ **Output behavior:**
290
+
291
+ - Exit 2: stderr fed back to Claude
292
+ - systemMessage included in context
293
+
294
+ ### Stop
295
+
296
+ Execute when main agent considers stopping. Use to validate completeness.
297
+
298
+ **Example:**
299
+
300
+ ```json
301
+ {
302
+ "Stop": [
303
+ {
304
+ "matcher": "*",
305
+ "hooks": [
306
+ {
307
+ "type": "prompt",
308
+ "prompt": "Verify task completion: tests run, build succeeded, questions answered. Return 'approve' to stop or 'block' with reason to continue."
309
+ }
310
+ ]
311
+ }
312
+ ]
313
+ }
314
+ ```
315
+
316
+ **Decision output:**
317
+
318
+ ```json
319
+ {
320
+ "decision": "approve|block",
321
+ "reason": "Explanation",
322
+ "systemMessage": "Additional context"
323
+ }
324
+ ```
325
+
326
+ ### SubagentStop
327
+
328
+ Execute when subagent considers stopping. Use to ensure subagent completed its task.
329
+
330
+ Similar to Stop hook, but for subagents.
331
+
332
+ ### SubagentStart
333
+
334
+ Execute when a subagent is started. Use to initialize subagent state or perform setup.
335
+
336
+ **Example:**
337
+
338
+ ```json
339
+ {
340
+ "SubagentStart": [
341
+ {
342
+ "matcher": "mcp__subagent_name",
343
+ "hooks": [
344
+ {
345
+ "type": "command",
346
+ "command": "bash ${CLAUDE_PLUGIN_ROOT}/scripts/subagent-init.sh"
347
+ }
348
+ ]
349
+ }
350
+ ]
351
+ }
352
+ ```
353
+
354
+ ### UserPromptSubmit
355
+
356
+ Execute when user submits a prompt. Use to add context, validate, or block prompts.
357
+
358
+ **Example:**
359
+
360
+ ```json
361
+ {
362
+ "UserPromptSubmit": [
363
+ {
364
+ "matcher": "*",
365
+ "hooks": [
366
+ {
367
+ "type": "prompt",
368
+ "prompt": "Check if prompt requires security guidance. If discussing auth, permissions, or API security, return relevant warnings."
369
+ }
370
+ ]
371
+ }
372
+ ]
373
+ }
374
+ ```
375
+
376
+ ### SessionStart
377
+
378
+ Execute when Claude Code session begins. Use to load context and set environment.
379
+
380
+ **Supported matchers:** `startup` (first launch), `resume` (resuming session), `clear` (after /clear), `compact` (after context compaction).
381
+
382
+ **Example:**
383
+
384
+ ```json
385
+ {
386
+ "SessionStart": [
387
+ {
388
+ "matcher": "*",
389
+ "hooks": [
390
+ {
391
+ "type": "command",
392
+ "command": "bash ${CLAUDE_PLUGIN_ROOT}/scripts/load-context.sh"
393
+ }
394
+ ]
395
+ }
396
+ ]
397
+ }
398
+ ```
399
+
400
+ **Special capability:** Persist environment variables using `$CLAUDE_ENV_FILE`:
401
+
402
+ ```bash
403
+ echo "export PROJECT_TYPE=nodejs" >> "$CLAUDE_ENV_FILE"
404
+ ```
405
+
406
+ See `examples/load-context.sh` for complete example.
407
+
408
+ ### SessionEnd
409
+
410
+ Execute when session ends. Use for cleanup, logging, and state preservation.
411
+
412
+ ### PreCompact
413
+
414
+ Execute before context compaction. Use to add critical information to preserve.
415
+
416
+ ### Notification
417
+
418
+ Execute when Claude sends notifications. Use to react to user notifications.
419
+
420
+ ## Hook Output Format
421
+
422
+ ### Standard Output (All Hooks)
423
+
424
+ ```json
425
+ {
426
+ "continue": true,
427
+ "suppressOutput": false,
428
+ "systemMessage": "Message for Claude"
429
+ }
430
+ ```
431
+
432
+ - `continue`: If false, halt processing (default true)
433
+ - `suppressOutput`: Hide output from transcript (default false)
434
+ - `systemMessage`: Message shown to Claude
435
+
436
+ ### Exit Codes
437
+
438
+ - `0` - Success (stdout shown in transcript)
439
+ - `2` - Blocking error (stderr fed back to Claude)
440
+ - Other - Non-blocking error
441
+
442
+ ## Hook Input Format
443
+
444
+ All hooks receive JSON via stdin with common fields:
445
+
446
+ ```json
447
+ {
448
+ "session_id": "abc123",
449
+ "transcript_path": "/path/to/transcript.txt",
450
+ "cwd": "/current/working/dir",
451
+ "permission_mode": "ask|allow",
452
+ "hook_event_name": "PreToolUse"
453
+ }
454
+ ```
455
+
456
+ **Event-specific fields:**
457
+
458
+ - **PreToolUse/PermissionRequest/PostToolUse:** `tool_name`, `tool_input`, `tool_result`
459
+ - **UserPromptSubmit:** `user_prompt`
460
+ - **Stop/SubagentStop:** `reason`
461
+
462
+ Access fields in prompts using `$TOOL_INPUT`, `$TOOL_RESULT`, `$USER_PROMPT`, etc.
463
+
464
+ For comprehensive per-tool and per-event input schemas, see [Hook Input Schemas](references/hook-input-schemas.md).
465
+
466
+ ## Environment Variables
467
+
468
+ Available in all command hooks:
469
+
470
+ - `$CLAUDE_PROJECT_DIR` - Project root path
471
+ - `$CLAUDE_PLUGIN_ROOT` - Plugin directory (use for portable paths)
472
+ - `$CLAUDE_ENV_FILE` - SessionStart only: persist env vars here
473
+ - `$CLAUDE_CODE_REMOTE` - Set if running in remote context
474
+
475
+ **Always use ${CLAUDE_PLUGIN_ROOT} in hook commands for portability:**
476
+
477
+ ```json
478
+ {
479
+ "type": "command",
480
+ "command": "bash ${CLAUDE_PLUGIN_ROOT}/scripts/validate.sh"
481
+ }
482
+ ```
483
+
484
+ ## Plugin Hook Configuration
485
+
486
+ In plugins, define hooks in `hooks/hooks.json` using the **plugin wrapper format** described in [Hook Configuration Formats](#hook-configuration-formats):
487
+
488
+ ```json
489
+ {
490
+ "hooks": {
491
+ "PreToolUse": [
492
+ {
493
+ "matcher": "Write|Edit",
494
+ "hooks": [{ "type": "prompt", "prompt": "Validate file write safety" }]
495
+ }
496
+ ],
497
+ "Stop": [
498
+ {
499
+ "matcher": "*",
500
+ "hooks": [{ "type": "prompt", "prompt": "Verify task completion" }]
501
+ }
502
+ ],
503
+ "SessionStart": [
504
+ {
505
+ "matcher": "*",
506
+ "hooks": [
507
+ {
508
+ "type": "command",
509
+ "command": "bash ${CLAUDE_PLUGIN_ROOT}/scripts/load-context.sh",
510
+ "timeout": 10
511
+ }
512
+ ]
513
+ }
514
+ ]
515
+ }
516
+ }
517
+ ```
518
+
519
+ **Note:** Plugin hooks use the `{"hooks": {...}}` wrapper format, not the direct settings format. Plugin hooks merge with user's hooks and run in parallel.
520
+
521
+ ## Scoped Hooks in Skill/Agent Frontmatter
522
+
523
+ Beyond `hooks.json` (global) and settings (user-level), hooks can be defined directly in skill or agent YAML frontmatter. Scoped hooks activate only when that component is in use:
524
+
525
+ ```yaml
526
+ ---
527
+ name: validated-writer
528
+ description: Write files with safety checks...
529
+ hooks:
530
+ PreToolUse:
531
+ - matcher: Write
532
+ hooks:
533
+ - type: command
534
+ command: "${CLAUDE_PLUGIN_ROOT}/scripts/validate-write.sh"
535
+ ---
536
+ ```
537
+
538
+ **Supported events in frontmatter:** `PreToolUse`, `PostToolUse`, `Stop`
539
+
540
+ Scoped hooks use the same event/matcher/hook structure but are lifecycle-bound — they activate when the skill loads and deactivate when it completes. This is ideal for skill-specific validation without affecting other workflows.
541
+
542
+ See `references/advanced.md` for detailed syntax and comparison with `hooks.json`.
543
+
544
+ ## Matchers
545
+
546
+ ### Tool Name Matching
547
+
548
+ **Exact match:**
549
+
550
+ ```json
551
+ "matcher": "Write"
552
+ ```
553
+
554
+ **Multiple tools:**
555
+
556
+ ```json
557
+ "matcher": "Read|Write|Edit"
558
+ ```
559
+
560
+ **Wildcard (all tools):**
561
+
562
+ ```json
563
+ "matcher": "*"
564
+ ```
565
+
566
+ **Regex patterns:**
567
+
568
+ ```json
569
+ "matcher": "mcp__.*__delete.*" // All MCP delete tools
570
+ ```
571
+
572
+ **Note:** Matchers are case-sensitive.
573
+
574
+ ### Common Patterns
575
+
576
+ ```json
577
+ // All MCP tools
578
+ "matcher": "mcp__.*"
579
+
580
+ // Specific plugin's MCP tools
581
+ "matcher": "mcp__plugin_asana_.*"
582
+
583
+ // All file operations
584
+ "matcher": "Read|Write|Edit"
585
+
586
+ // Bash commands only
587
+ "matcher": "Bash"
588
+ ```
589
+
590
+ ## Security Best Practices
591
+
592
+ ### Input Validation
593
+
594
+ Always validate inputs in command hooks:
595
+
596
+ ```bash
597
+ #!/bin/bash
598
+ set -euo pipefail
599
+
600
+ input=$(cat)
601
+ tool_name=$(echo "$input" | jq -r '.tool_name')
602
+
603
+ # Validate tool name format
604
+ if [[ ! "$tool_name" =~ ^[a-zA-Z0-9_]+$ ]]; then
605
+ echo '{"decision": "deny", "reason": "Invalid tool name"}' >&2
606
+ exit 2
607
+ fi
608
+ ```
609
+
610
+ ### Path Safety
611
+
612
+ Check for path traversal and sensitive files:
613
+
614
+ ```bash
615
+ file_path=$(echo "$input" | jq -r '.tool_input.file_path')
616
+
617
+ # Deny path traversal
618
+ if [[ "$file_path" == *".."* ]]; then
619
+ echo '{"decision": "deny", "reason": "Path traversal detected"}' >&2
620
+ exit 2
621
+ fi
622
+
623
+ # Deny sensitive files
624
+ if [[ "$file_path" == *".env"* ]]; then
625
+ echo '{"decision": "deny", "reason": "Sensitive file"}' >&2
626
+ exit 2
627
+ fi
628
+ ```
629
+
630
+ See `examples/validate-write.sh` and `examples/validate-bash.sh` for complete examples.
631
+
632
+ ### Quote All Variables
633
+
634
+ ```bash
635
+ # GOOD: Quoted
636
+ echo "$file_path"
637
+ cd "$CLAUDE_PROJECT_DIR"
638
+
639
+ # BAD: Unquoted (injection risk)
640
+ echo $file_path
641
+ cd $CLAUDE_PROJECT_DIR
642
+ ```
643
+
644
+ ### Set Appropriate Timeouts
645
+
646
+ ```json
647
+ {
648
+ "type": "command",
649
+ "command": "bash script.sh",
650
+ "timeout": 10
651
+ }
652
+ ```
653
+
654
+ **Defaults:** Command hooks (60s), Prompt hooks (30s)
655
+
656
+ ## Performance Considerations
657
+
658
+ ### Parallel Execution
659
+
660
+ All matching hooks run **in parallel**:
661
+
662
+ ```json
663
+ {
664
+ "PreToolUse": [
665
+ {
666
+ "matcher": "Write",
667
+ "hooks": [
668
+ { "type": "command", "command": "check1.sh" }, // Parallel
669
+ { "type": "command", "command": "check2.sh" }, // Parallel
670
+ { "type": "prompt", "prompt": "Validate..." } // Parallel
671
+ ]
672
+ }
673
+ ]
674
+ }
675
+ ```
676
+
677
+ **Design implications:**
678
+
679
+ - Hooks don't see each other's output
680
+ - Non-deterministic ordering
681
+ - Design for independence
682
+
683
+ ### Optimization
684
+
685
+ 1. Use command hooks for quick deterministic checks
686
+ 2. Use prompt hooks for complex reasoning
687
+ 3. Cache validation results in temp files
688
+ 4. Minimize I/O in hot paths
689
+
690
+ ## Hook Lifecycle and Limitations
691
+
692
+ ### Hooks Load at Session Start
693
+
694
+ **Important:** Hooks are loaded when Claude Code session starts. Changes to hook configuration require restarting Claude Code.
695
+
696
+ **Cannot hot-swap hooks:**
697
+
698
+ - Editing `hooks/hooks.json` won't affect current session
699
+ - Adding new hook scripts won't be recognized
700
+ - Changing hook commands/prompts won't update
701
+ - Must restart Claude Code: exit and run `claude` again
702
+
703
+ **To test hook changes:**
704
+
705
+ 1. Edit hook configuration or scripts
706
+ 2. Exit Claude Code session
707
+ 3. Restart: `claude`
708
+ 4. New hook configuration loads
709
+ 5. Test hooks with `claude --debug`
710
+
711
+ ### Hook Validation at Startup
712
+
713
+ Hooks are validated when Claude Code starts:
714
+
715
+ - Invalid JSON in hooks.json causes loading failure
716
+ - Missing scripts cause warnings
717
+ - Syntax errors reported in debug mode
718
+
719
+ Use `/hooks` command to review loaded hooks in current session.
720
+
721
+ ## Debugging Hooks
722
+
723
+ ### Enable Debug Mode
724
+
725
+ ```bash
726
+ claude --debug
727
+ ```
728
+
729
+ Look for hook registration, execution logs, input/output JSON, and timing information.
730
+
731
+ For additional hook debugging output, use `--verbose`:
732
+
733
+ ```bash
734
+ claude --verbose
735
+ ```
736
+
737
+ This shows hook registration, event matching, and execution timing without the full debug output. Combine with `--debug` for maximum detail.
738
+
739
+ ### Test Hook Scripts
740
+
741
+ Test command hooks directly:
742
+
743
+ ```bash
744
+ echo '{"tool_name": "Write", "tool_input": {"file_path": "/test"}}' | \
745
+ bash ${CLAUDE_PLUGIN_ROOT}/scripts/validate.sh
746
+
747
+ echo "Exit code: $?"
748
+ ```
749
+
750
+ ### Validate JSON Output
751
+
752
+ Ensure hooks output valid JSON:
753
+
754
+ ```bash
755
+ output=$(./your-hook.sh < test-input.json)
756
+ echo "$output" | jq .
757
+ ```
758
+
759
+ ## Quick Reference
760
+
761
+ ### Hook Events Summary
762
+
763
+ | Event | When | Use For |
764
+ | ------------------ | ------------------ | ------------------------ |
765
+ | PreToolUse | Before tool | Validation, modification |
766
+ | PermissionRequest | Permission dialog | Auto-allow/deny |
767
+ | PostToolUse | After tool success | Feedback, logging |
768
+ | PostToolUseFailure | After tool fails | Error handling |
769
+ | UserPromptSubmit | User input | Context, validation |
770
+ | Stop | Agent stopping | Completeness check |
771
+ | SubagentStart | Subagent begins | Subagent setup |
772
+ | SubagentStop | Subagent done | Task validation |
773
+ | SessionStart | Session begins | Context loading |
774
+ | SessionEnd | Session ends | Cleanup, logging |
775
+ | PreCompact | Before compact | Preserve context |
776
+ | Notification | User notified | Logging, reactions |
777
+ | TeammateIdle | Teammate goes idle | Quality gates in teams |
778
+ | TaskCompleted | Task marked done | Completion verification |
779
+
780
+ ### Handler Configuration Fields
781
+
782
+ Beyond `type`, `timeout`, and `matcher`, hook handlers support:
783
+
784
+ - **`once`** (boolean): Run only once per session, then auto-removed. Useful for one-time initialization in scoped hooks.
785
+ - **`statusMessage`** (string): Display text shown in the UI while the hook runs.
786
+
787
+ See `references/advanced.md` for detailed decision control output schemas and event-specific matchers.
788
+
789
+ ### Best Practices
790
+
791
+ **DO:**
792
+
793
+ - ✅ Use prompt-based hooks for complex logic
794
+ - ✅ Use ${CLAUDE_PLUGIN_ROOT} for portability
795
+ - ✅ Validate all inputs in command hooks
796
+ - ✅ Quote all bash variables
797
+ - ✅ Set appropriate timeouts
798
+ - ✅ Return structured JSON output
799
+ - ✅ Test hooks thoroughly
800
+
801
+ **DON'T:**
802
+
803
+ - ❌ Use hardcoded paths
804
+ - ❌ Trust user input without validation
805
+ - ❌ Create long-running hooks
806
+ - ❌ Rely on hook execution order
807
+ - ❌ Modify global state unpredictably
808
+ - ❌ Log sensitive information
809
+
810
+ ## Additional Resources
811
+
812
+ ### Reference Files
813
+
814
+ For detailed patterns and advanced techniques, consult:
815
+
816
+ - **`references/patterns.md`** - 10 proven patterns including temporarily active and configuration-driven hooks
817
+ - **`references/migration.md`** - Migrating from basic to advanced hooks
818
+ - **`references/advanced.md`** - Advanced use cases and techniques
819
+
820
+ ### Example Hook Scripts
821
+
822
+ Working examples in `examples/`:
823
+
824
+ > **Note:** After copying example scripts, make them executable: `chmod +x script.sh`
825
+
826
+ - **`validate-write.sh`** - File write validation example
827
+ - **`validate-bash.sh`** - Bash command validation example
828
+ - **`load-context.sh`** - SessionStart context loading example
829
+
830
+ ### Utility Scripts
831
+
832
+ > **Prerequisites**: These scripts require `jq` for JSON validation. See the [main README](../../../../README.md#for-utility-scripts) for setup.
833
+
834
+ Development tools in `scripts/`:
835
+
836
+ - **`validate-hook-schema.sh`** - Validate hooks.json structure and syntax
837
+ - **`test-hook.sh`** - Test hooks with sample input before deployment
838
+ - **`hook-linter.sh`** - Check hook scripts for common issues and best practices
839
+
840
+ ### External Resources
841
+
842
+ - **Official Docs**: <https://docs.claude.com/en/docs/claude-code/hooks>
843
+ - **Examples**: See security-guidance plugin in marketplace
844
+ - **Testing**: Use `claude --debug` for detailed logs
845
+ - **Validation**: Use `jq` to validate hook JSON output
846
+
847
+ ## Implementation Workflow
848
+
849
+ To implement hooks in a plugin:
850
+
851
+ 1. Identify events to hook into (PreToolUse, Stop, SessionStart, etc.)
852
+ 2. Decide between prompt-based (flexible) or command (deterministic) hooks
853
+ 3. Write hook configuration in `hooks/hooks.json`
854
+ 4. For command hooks, create hook scripts
855
+ 5. Use ${CLAUDE_PLUGIN_ROOT} for all file references
856
+ 6. Validate configuration with `scripts/validate-hook-schema.sh hooks/hooks.json`
857
+ 7. Test hooks with `scripts/test-hook.sh` before deployment
858
+ 8. Test in Claude Code with `claude --debug`
859
+ 9. Document hooks in plugin README
860
+
861
+ Focus on prompt-based hooks for most use cases. Reserve command hooks for performance-critical or deterministic checks.