Hooks don't propagate to Task subagents
Resolved 💬 2 comments Opened Feb 10, 2026 by jonathanbird Closed Feb 10, 2026
Summary
PreToolUse hooks defined in .claude/settings.json do not apply to Task subagents (child agents spawned via the Task tool). This means subagents can bypass project-level safety hooks.
Reproduction
- Create
.claude/settings.jsonwith a PreToolUse hook that blocks background Bash:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": ".claude/hooks/block-background-bash.sh"
}
]
}
]
}
}
- The hook script denies
run_in_background=true:
#!/bin/bash
INPUT=$(cat)
RUN_IN_BG=$(echo "$INPUT" | jq -r '.tool_input.run_in_background // false')
if [ "$RUN_IN_BG" = "true" ]; then
jq -n '{
hookSpecificOutput: {
hookEventName: "PreToolUse",
permissionDecision: "deny",
permissionDecisionReason: "Background Bash execution is not allowed."
}
}'
fi
- In the main conversation, background Bash calls are correctly blocked by the hook.
- Launch a Task subagent and ask it to run a background Bash command — it succeeds without being blocked.
- Also tested adding
hooks:to skill YAML frontmatter in SKILL.md — same result, Task subagents spawned from that skill are not affected.
Expected Behavior
Project-level hooks (especially PreToolUse deny hooks) should propagate to Task subagents, or there should be a documented mechanism to enforce hooks on child agents. Without this, any safety/policy hooks can be bypassed by subagents.
Environment
- macOS 15.3
- Claude Code (latest)
- Model: claude-opus-4-6
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗