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

  1. Create .claude/settings.json with a PreToolUse hook that blocks background Bash:
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": ".claude/hooks/block-background-bash.sh"
          }
        ]
      }
    ]
  }
}
  1. 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
  1. In the main conversation, background Bash calls are correctly blocked by the hook.
  1. Launch a Task subagent and ask it to run a background Bash command — it succeeds without being blocked.
  1. 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

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗