Skip to content

Commit 94aa984

Browse files
sjnimsclaude
andauthored
docs(hook-development): add PermissionRequest hook event documentation (#69)
## Summary - Added documentation for the PermissionRequest hook event - Updated validate-hook-schema.sh to recognize PermissionRequest as a valid event - PermissionRequest allows automatic allow/deny of permission dialogs ## Problem Fixes #67 The hook-development skill was missing documentation for PermissionRequest, which is a valid hook event in the official Claude Code documentation. This caused: 1. Users not knowing about this capability 2. The validation script incorrectly warning about PermissionRequest being unknown ## Solution Added comprehensive documentation for PermissionRequest: - New section in Hook Events with example configuration and output format - Added to skill description trigger list - Added to Quick Reference table - Added to event-specific input fields - Added to VALID_EVENTS in validate-hook-schema.sh ### Alternatives Considered - **Document as "not supported for plugins"**: Rejected because official docs show it's available - **Minimal one-line addition**: Rejected because consistent documentation requires the same treatment as other events ## Changes - `plugins/plugin-dev/skills/hook-development/SKILL.md`: Added PermissionRequest documentation (+50 lines) - `plugins/plugin-dev/skills/hook-development/scripts/validate-hook-schema.sh`: Added PermissionRequest to VALID_EVENTS ## Testing - [x] Markdownlint passes - [x] Shellcheck shows only pre-existing warnings (not related to this change) - [x] Documentation follows existing patterns --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent 87a7c20 commit 94aa984

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)