You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PreToolUse hooks support JSON output format for Claude Code integration. Actions can return structured output with 3-stage permission control:
398
+
PreToolUse hooks support JSON output format for Claude Code integration. Actions can return structured output with 3-stage permission control.
399
+
400
+
**Input Fields** (in addition to BaseInput and tool_name/tool_input):
401
+
- `tool_use_id` (string): Unique identifier for this tool call, used to correlate PreToolUse and PostToolUse events
402
+
- `agent_id` (string, optional): Subagent identifier, only present when called from within a subagent
403
+
- `agent_type` (string, optional): Subagent type name (e.g., "Explore", "Bash", "Plan") or `--agent` flag value
395
404
396
405
**Output Action** (type: `output`):
397
406
```yaml
@@ -480,7 +489,10 @@ PreToolUse:
480
489
481
490
### Stop JSON Output
482
491
483
-
Stop hooks support JSON output format for Claude Code integration. Actions can return structured output with decision control to block or allow Claude's stopping:
492
+
Stop hooks support JSON output format for Claude Code integration. Actions can return structured output with decision control to block or allow Claude's stopping.
493
+
494
+
**Input Fields** (in addition to BaseInput and stop_hook_active):
495
+
- `last_assistant_message` (string): The full text of Claude's final response before stopping. Useful for validating task completion.
484
496
485
497
**Output Action** (type: `output`):
486
498
```yaml
@@ -549,7 +561,20 @@ Stop:
549
561
550
562
### SubagentStop JSON Output
551
563
552
-
SubagentStop hooks support JSON output format for Claude Code integration. Actions can return structured output with decision control to block or allow subagent stopping:
564
+
SubagentStop hooks support JSON output format for Claude Code integration. Actions can return structured output with decision control to block or allow subagent stopping.
565
+
566
+
**Input Fields**:
567
+
- `agent_id` (string): Unique identifier of the stopping subagent.
568
+
- `agent_type` (string): Type name of the subagent (e.g., `"Explore"`, `"Bash"`, `"Plan"`).
569
+
- `agent_transcript_path` (string): Path to the subagent's own transcript file (separate from the main session's `transcript_path`).
570
+
- `last_assistant_message` (string): The final response text from the subagent.
571
+
572
+
**Matcher Support**:
573
+
SubagentStop hooks support a `matcher` field to filter by agent type:
574
+
- Matches against the `agent_type` field from SubagentStop input
- Supports pipe-separated OR logic (e.g., `"Explore|Plan|Bash"`)
577
+
- Empty/omitted: Matches all agent types
553
578
554
579
**Output Action** (type: `output`):
555
580
```yaml
@@ -608,7 +633,12 @@ SubagentStop:
608
633
609
634
### PostToolUse JSON Output
610
635
611
-
PostToolUse hooks support JSON output format for Claude Code integration. Actions can return structured output with decision control and additional context:
636
+
PostToolUse hooks support JSON output format for Claude Code integration. Actions can return structured output with decision control and additional context.
637
+
638
+
**Input Fields** (in addition to BaseInput, tool_name/tool_input/tool_response):
639
+
- `tool_use_id` (string): Unique identifier for this tool call (same as PreToolUse)
- `agent_type` (string, optional): Subagent type name
612
642
613
643
**Output Action** (type: `output`):
614
644
```yaml
@@ -869,7 +899,13 @@ PreCompact:
869
899
870
900
### SessionEnd JSON Output
871
901
872
-
SessionEnd hooks support JSON output format for Claude Code integration. Actions can return structured output for session cleanup:
902
+
SessionEnd hooks support JSON output format for Claude Code integration. Actions can return structured output for session cleanup.
903
+
904
+
**Matcher Support**:
905
+
SessionEnd hooks support a `matcher` field to filter by session end reason (exact match):
906
+
- Matches against the `reason` field from SessionEnd input
907
+
- Supports pipe-separated OR logic (e.g., `"clear|logout"`)
908
+
- Empty/omitted: Matches all reasons
873
909
874
910
**Output Action** (type: `output`):
875
911
```yaml
@@ -1065,6 +1101,47 @@ Available reason values:
1065
1101
- `bypass_permissions_disabled`: Session ended because bypass permissions were disabled
1066
1102
- `other`: Other reasons
1067
1103
1104
+
### PermissionRequest Extensions
1105
+
1106
+
PermissionRequest hooks receive additional input fields and support output extensions:
1107
+
1108
+
**Input Fields:**
1109
+
- **`tool_use_id`** (string): Unique identifier for the tool call triggering the permission dialog.
1110
+
- **`permission_suggestions`** (array, optional): Permission rule suggestions provided by Claude Code's safety checks. Available as a template variable for advanced use cases.
1111
+
1112
+
**`updatedPermissions` Output:**
1113
+
PermissionRequest hooks can return `updatedPermissions` to dynamically modify Claude Code's permission configuration when allowing a request:
1114
+
1115
+
**Command Action JSON:**
1116
+
```json
1117
+
{
1118
+
"continue": true,
1119
+
"hookSpecificOutput": {
1120
+
"hookEventName": "PermissionRequest",
1121
+
"decision": {
1122
+
"behavior": "allow",
1123
+
"updatedPermissions": [
1124
+
{
1125
+
"type": "addRules",
1126
+
"behavior": "allow",
1127
+
"destination": "session"
1128
+
}
1129
+
]
1130
+
}
1131
+
}
1132
+
}
1133
+
```
1134
+
1135
+
Available `updatedPermissions` entry types:
1136
+
- `addRules`: Add permission rules
1137
+
- `replaceRules`: Replace all rules of given behavior
0 commit comments