Skip to content

Subagents should inherit parent session hooks and permission rules #27661

Description

@thomascburns

Problem

When using the Task tool to launch subagents (Explore, Plan, general-purpose, Bash), the subagents do not inherit:

  1. PreToolUse hooks defined in .claude/settings.json
  2. Permission allow/deny rules from .claude/settings.json
  3. CLAUDE.md instructions
  4. Project memory files

This means project-level safety enforcement (e.g., a hook that blocks cd to the project root, or deny rules for destructive commands) silently stops working when subagents are involved.

Current Behavior

  • Parent session has a PreToolUse hook on Bash that blocks cd to the project root
  • Parent session has permission rules allowing read-only commands without prompting
  • Subagents launched via Task(subagent_type="Explore") ignore both — they cd into the project root freely and prompt for permission on commands the parent auto-allows

Expected Behavior

Subagents should inherit all hooks and permission rules from the parent session's .claude/settings.json by default, ensuring consistent enforcement across the entire agent tree.

Current Workaround

Creating custom agent definitions in .claude/agents/ that manually replicate each hook:

---
name: explore
hooks:
  PreToolUse:
    - matcher: "Bash"
      hooks:
        - type: command
          command: "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/no-cd-project-root.sh"
---

This is fragile because:

  • Every new hook in settings.json must be manually duplicated into every agent file
  • The agent definitions can drift out of sync with the actual settings
  • New subagent types require new override files
  • It embeds project rules in prose that the AI may not follow, whereas hooks are deterministic

Proposed Solution

Add a configuration option (or make it the default) to propagate parent session hooks and permission rules to all subagents:

{
  "permissions": {
    "propagateToSubagents": true
  },
  "hooks": {
    "propagateToSubagents": true
  }
}

Or simply make inheritance the default behavior, since hooks and permissions represent project-level safety constraints that should apply everywhere.

Environment

  • Claude Code CLI
  • macOS (Darwin 25.3.0)
  • Using .claude/settings.json with PreToolUse hooks and permission allow/deny rules

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions