PreToolUse hooks in settings.json don't fire for teammates spawned via Agent tool

Resolved 💬 3 comments Opened Apr 2, 2026 by leonjang88 Closed Apr 2, 2026

Description

PreToolUse hooks defined in project-level .claude/settings.json and user-level ~/.claude/settings.json fire correctly for the main session but do not fire for teammates spawned via the Agent tool with team_name.

Steps to Reproduce

  1. Create .claude/settings.json with a PreToolUse hook:
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "/path/to/hook.sh"
          }
        ]
      }
    ]
  }
}
  1. The hook script logs every invocation:
#!/bin/bash
INPUT=$(cat)
AGENT_TYPE=$(echo "$INPUT" | jq -r '.agent_type // empty')
TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name // empty')
echo "$(date) agent=$AGENT_TYPE tool=$TOOL_NAME" >> /tmp/hook_debug.log
exit 0
  1. Run a Bash command in the main session → hook fires, log entry appears
  2. Spawn a teammate: Agent(subagent_type="my-agent", name="rudy", team_name="test-team", prompt="Run Bash: ls /tmp")
  3. Teammate executes ls /tmp successfully → no log entry, hook never fired

Environment

  • Claude Code version: 2.1.90
  • Teammate is in the correct project directory (pwd confirms)
  • Tested with hooks in both project .claude/settings.json and user ~/.claude/settings.json
  • Also tested hooks in agent frontmatter (hooks: field in .claude/agents/*.md) — also don't fire

Expected Behavior

PreToolUse hooks should fire for teammates spawned via Agent tool, same as they do for the main session.

Related Issues

  • #17688 (hooks in subagent frontmatter)
  • #18392 (closed as dup of #17688)
  • #26923 (exit code 2 doesn't block Task tool)

Impact

We're building an agent team system where role enforcement (file path restrictions, dangerous git command blocking) depends on PreToolUse hooks. Without hook propagation to teammates, we can't enforce tool restrictions — only rely on prompt-based guidance.

View original on GitHub ↗

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