Skip to content

Commit 46c8c3a

Browse files
sjnimsclaude
andcommitted
docs(hook-development): add PermissionRequest hook event documentation
Add documentation for the PermissionRequest hook event which was missing from the skill despite being in the official Claude Code documentation. PermissionRequest runs when a permission dialog is shown and allows hooks to automatically allow or deny permission requests. Changes: - Add PermissionRequest to skill description event list - Add PermissionRequest section in Hook Events with example and output format - Add PermissionRequest to Quick Reference table - Add PermissionRequest to event-specific fields documentation - Add PermissionRequest to validate-hook-schema.sh VALID_EVENTS array Fixes #67 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 87a7c20 commit 46c8c3a

2 files changed

Lines changed: 52 additions & 3 deletions

File tree

plugins/plugin-dev/skills/hook-development/SKILL.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
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.
44
---
55

66
# Hook Development for Claude Code Plugins
@@ -159,6 +159,54 @@ Execute before any tool runs. Use to approve, deny, or modify tool calls.
159159
}
160160
```
161161

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+
162210
### PostToolUse
163211

164212
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:
327375

328376
**Event-specific fields:**
329377

330-
- **PreToolUse/PostToolUse:** `tool_name`, `tool_input`, `tool_result`
378+
- **PreToolUse/PermissionRequest/PostToolUse:** `tool_name`, `tool_input`, `tool_result`
331379
- **UserPromptSubmit:** `user_prompt`
332380
- **Stop/SubagentStop:** `reason`
333381

@@ -596,6 +644,7 @@ echo "$output" | jq .
596644
| Event | When | Use For |
597645
|-------|------|---------|
598646
| PreToolUse | Before tool | Validation, modification |
647+
| PermissionRequest | Permission dialog | Auto-allow/deny |
599648
| PostToolUse | After tool | Feedback, logging |
600649
| UserPromptSubmit | User input | Context, validation |
601650
| Stop | Agent stopping | Completeness check |

plugins/plugin-dev/skills/hook-development/scripts/validate-hook-schema.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ echo "✅ Valid JSON"
3838
# Check 2: Root structure
3939
echo ""
4040
echo "Checking root structure..."
41-
VALID_EVENTS=("PreToolUse" "PostToolUse" "UserPromptSubmit" "Stop" "SubagentStop" "SessionStart" "SessionEnd" "PreCompact" "Notification")
41+
VALID_EVENTS=("PreToolUse" "PermissionRequest" "PostToolUse" "UserPromptSubmit" "Stop" "SubagentStop" "SessionStart" "SessionEnd" "PreCompact" "Notification")
4242

4343
for event in $(jq -r 'keys[]' "$HOOKS_FILE"); do
4444
found=false

0 commit comments

Comments
 (0)