Skip to content

Comments

Add SubagentStop hook support to system#93

Merged
nhorton merged 11 commits intomainfrom
claude/add-subagent-stop-hook-ho4cv
Jan 21, 2026
Merged

Add SubagentStop hook support to system#93
nhorton merged 11 commits intomainfrom
claude/add-subagent-stop-hook-ho4cv

Conversation

@nhorton
Copy link
Contributor

@nhorton nhorton commented Jan 21, 2026

Claude Code now has separate Stop and SubagentStop events. Previously, Stop would trigger for both the main agent and subagents. This change ensures that when a Stop hook is defined, it is also registered for SubagentStop so the same validation logic triggers for both events.

Changes:

  • generator.py: Duplicate Stop hooks to SubagentStop in skill templates
  • hooks_syncer.py: Duplicate Stop hooks to SubagentStop in global hooks
  • Add tests verifying SubagentStop hook registration

claude and others added 11 commits January 21, 2026 02:55
Claude Code now has separate Stop and SubagentStop events. Previously,
Stop would trigger for both the main agent and subagents. This change
ensures that when a Stop hook is defined, it is also registered for
SubagentStop so the same validation logic triggers for both events.

Changes:
- generator.py: Duplicate Stop hooks to SubagentStop in skill templates
- hooks_syncer.py: Duplicate Stop hooks to SubagentStop in global hooks
- Add tests verifying SubagentStop hook registration
Move SubagentStop hook generation from generator.py to the Jinja
template, ensuring consistent rendering for both quality_criteria
and custom hooks.

Template changes:
- For quality_criteria: generate both Stop and SubagentStop hooks
- For custom Stop hooks: generate both Stop and SubagentStop blocks

New tests:
- TestGeneratorTemplateOutput verifies template generates both events
- TestSubagentStopEvent verifies rules trigger on SubagentStop events
Run deepwork install to regenerate all Claude Code skills with the new
SubagentStop hook support. Skills now register hooks for both Stop and
SubagentStop events so they trigger for both main agents and subagents.

Also includes lint fixes for unused loop variables in tests.
The manual tests were failing because the rules queue (used to prevent
infinite loops) was not being cleared between tests. Once a rule fires
and is added to the queue with status=QUEUED, it won't fire again until
the queue is cleared. This caused "should fire" tests to pass silently
without actually verifying the hook behavior.

Changes:
- Updated run_not_fire_tests.md to clear queue after tests
- Updated run_fire_tests.md to clear queue between each test
- Updated job.yml quality criteria to include queue clearing
- Bumped manual_tests version to 1.1.0
When a "should fire" test doesn't show visible blocking, the agent should
now check the rules queue to determine if:
- Hook fired but blocking wasn't visible (queue entry exists)
- Hook did NOT fire at all (queue is empty)

This helps diagnose platform limitations like Task tool sub-agents not
triggering SubagentStop hooks.
@nhorton nhorton merged commit 606ffaf into main Jan 21, 2026
4 checks passed
@nhorton nhorton deleted the claude/add-subagent-stop-hook-ho4cv branch January 21, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants