|
1 | 1 | --- |
2 | 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", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API. |
| 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", or mentions hook events (PreToolUse, PermissionRequest, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API. |
4 | 4 | --- |
5 | 5 |
|
6 | 6 | # Hook Development for Claude Code Plugins |
@@ -159,6 +159,54 @@ Execute before any tool runs. Use to approve, deny, or modify tool calls. |
159 | 159 | } |
160 | 160 | ``` |
161 | 161 |
|
| 162 | +### PermissionRequest |
| 163 | + |
| 164 | +Execute when user is shown a permission dialog. Use to automatically allow or deny permissions. |
| 165 | + |
| 166 | +**Example:** |
| 167 | + |
| 168 | +```json |
| 169 | +{ |
| 170 | + "PermissionRequest": [ |
| 171 | + { |
| 172 | + "matcher": "Bash", |
| 173 | + "hooks": [ |
| 174 | + { |
| 175 | + "type": "command", |
| 176 | + "command": "bash ${CLAUDE_PLUGIN_ROOT}/scripts/check-permission.sh" |
| 177 | + } |
| 178 | + ] |
| 179 | + } |
| 180 | + ] |
| 181 | +} |
| 182 | +``` |
| 183 | + |
| 184 | +**Output for PermissionRequest:** |
| 185 | + |
| 186 | +```json |
| 187 | +{ |
| 188 | + "hookSpecificOutput": { |
| 189 | + "decision": { |
| 190 | + "behavior": "allow|deny", |
| 191 | + "updatedInput": {"command": "modified command"}, |
| 192 | + "message": "Reason for denial", |
| 193 | + "interrupt": false |
| 194 | + } |
| 195 | + } |
| 196 | +} |
| 197 | +``` |
| 198 | + |
| 199 | +- `behavior`: "allow" to approve, "deny" to reject |
| 200 | +- `updatedInput`: Optional modified tool parameters (only with "allow") |
| 201 | +- `message`: Explanation shown to user (only with "deny") |
| 202 | +- `interrupt`: If true with "deny", stops the current operation |
| 203 | + |
| 204 | +**Use cases:** |
| 205 | + |
| 206 | +- Auto-approve safe commands matching patterns |
| 207 | +- Block dangerous operations with explanations |
| 208 | +- Modify tool inputs before execution |
| 209 | + |
162 | 210 | ### PostToolUse |
163 | 211 |
|
164 | 212 | Execute after tool completes. Use to react to results, provide feedback, or log. |
@@ -327,7 +375,7 @@ All hooks receive JSON via stdin with common fields: |
327 | 375 |
|
328 | 376 | **Event-specific fields:** |
329 | 377 |
|
330 | | -- **PreToolUse/PostToolUse:** `tool_name`, `tool_input`, `tool_result` |
| 378 | +- **PreToolUse/PermissionRequest/PostToolUse:** `tool_name`, `tool_input`, `tool_result` |
331 | 379 | - **UserPromptSubmit:** `user_prompt` |
332 | 380 | - **Stop/SubagentStop:** `reason` |
333 | 381 |
|
@@ -596,6 +644,7 @@ echo "$output" | jq . |
596 | 644 | | Event | When | Use For | |
597 | 645 | |-------|------|---------| |
598 | 646 | | PreToolUse | Before tool | Validation, modification | |
| 647 | +| PermissionRequest | Permission dialog | Auto-allow/deny | |
599 | 648 | | PostToolUse | After tool | Feedback, logging | |
600 | 649 | | UserPromptSubmit | User input | Context, validation | |
601 | 650 | | Stop | Agent stopping | Completeness check | |
|
0 commit comments