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
Copy file name to clipboardExpand all lines: CLAUDE.md
+60Lines changed: 60 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -521,6 +521,66 @@ Stop:
521
521
decision: "block"
522
522
reason: "Stopping Claude in this directory may lose work context"
523
523
```
524
+
525
+
### SubagentStop JSON Output
526
+
527
+
SubagentStop hooks support JSON output format for Claude Code integration. Actions can return structured output with decision control to block or allow subagent stopping:
528
+
529
+
**Output Action** (type: `output`):
530
+
```yaml
531
+
SubagentStop:
532
+
- actions:
533
+
- type: output
534
+
message: "SubagentStop reason message"
535
+
decision: "block" # optional: "block" only; omit to allow stop
536
+
reason: "Detailed reason for blocking" # required when decision is "block"
537
+
```
538
+
539
+
**Command Action** (type: `command`):
540
+
Commands must output JSON with the following structure:
541
+
```json
542
+
{
543
+
"continue": true,
544
+
"decision": "block",
545
+
"reason": "Detailed reason for blocking",
546
+
"stopReason": "Optional stop reason",
547
+
"suppressOutput": false,
548
+
"systemMessage": "Optional system message"
549
+
}
550
+
```
551
+
552
+
Note: To allow the subagent stop, omit the `decision` field entirely.
553
+
554
+
**Important**: SubagentStop uses the same decision control format as Stop hooks. It does NOT use `hookSpecificOutput`. All fields are at the top level.
555
+
556
+
**Field Merging**:
557
+
When multiple actions execute:
558
+
- `continue`: Always `true` (cannot be changed for SubagentStop)
559
+
- `decision`: Last value wins (early return on `"block"`)
560
+
- `reason`: Reset when decision changes; concatenated with newline within same decision
561
+
- `systemMessage`: Concatenated with newline separator
562
+
- `stopReason` and `suppressOutput`: Last value wins
563
+
564
+
**Exit Code Behavior**:
565
+
SubagentStop hooks **always exit with code 0**. The `decision` field controls whether the subagent stopping is blocked:
566
+
- `decision` field omitted: SubagentStop proceeds normally
567
+
- `"block"`: SubagentStop is blocked (early return)
568
+
569
+
Errors are logged to stderr as warnings, but cchook continues to output JSON and exits successfully. On errors, `decision` defaults to `"block"` for safety (fail-safe).
570
+
571
+
**Example**:
572
+
```yaml
573
+
SubagentStop:
574
+
- conditions:
575
+
- type: cwd_contains
576
+
value: "/important-project"
577
+
actions:
578
+
- type: output
579
+
message: "Cannot stop subagent in important project directory"
580
+
decision: "block"
581
+
reason: "Stopping subagent in this directory may lose work context"
582
+
```
583
+
524
584
### PostToolUse JSON Output
525
585
526
586
PostToolUse hooks support JSON output format for Claude Code integration. Actions can return structured output with decision control and additional context:
0 commit comments