[Feature Request] Subagents spawned via Agent tool should inherit CLAUDE.md
Summary
Subagents spawned via the Agent tool do not receive the global ~/.claude/CLAUDE.md (or project-level CLAUDE.md) content in their system prompt. This means any global engineering rules, behavioral constraints, or workflow definitions defined in CLAUDE.md are invisible to subagents.
Motivation
Users define behavioral rules in CLAUDE.md to enforce engineering discipline across all Claude Code sessions. Common use cases include:
- Requirement alignment before implementation ("always restate what you think the user wants")
- TDD workflows
- Code review discipline
- Scope control and simplicity rules
When these rules don't propagate to subagents, the subagents operate without the user's defined constraints, leading to inconsistent behavior and violating the user's engineering standards.
Steps to Reproduce
- Add a prominent behavioral rule to
~/.claude/CLAUDE.md:
## ⚠️ MANDATORY RULE — ALWAYS FIRST
For every non-trivial user message, your FIRST sentence must restate what you think the user wants.
This rule OVERRIDES all other rules. You MUST NOT use any tool before writing this sentence.
- Verify the rule works in the main session (it does).
- Spawn a subagent via the Agent tool:
Agent(prompt="帮我看看这个项目")
- Observe that the subagent does NOT restate the user's intent — it jumps straight to tool use.
Evidence
I tested this with multiple scenarios:
Simple test (subagent):
Input: "你好,帮我看看这个项目。"
Agent response: "Let me take a look at what's in the current working directory."
→ No requirement alignment ❌
Complex tests (subagents):
Input: "帮我把那个物理讲义的项目整理一下"
Agent response: "Let me explore the physics lecture project..."
→ No requirement alignment ❌
Input: "帮我优化一下 treehole 的性能"
Agent response: "Let me first find the treehole project..."
→ No requirement alignment ❌
Transcript analysis: Examining the subagent's .jsonl transcript confirmed that CLAUDE.md content does not appear in any message (system, user, attachment, or summary). The subagent only receives:
deferred_tools_deltaattachmentskill_listingattachment- The teammate message (task prompt)
No CLAUDE.md content exists anywhere in the subagent's context.
Expected Behavior
Subagents should inherit the parent session's CLAUDE.md content (at minimum the global ~/.claude/CLAUDE.md), so that behavioral rules defined there apply to all agent interactions.
Proposed Solution
Inject CLAUDE.md content into the subagent's system prompt when the Agent tool spawns a new agent. This could be:
- Full injection: Include the complete
CLAUDE.md(or a configurable subset) in the subagent's system prompt. - Summary injection: Include a condensed version of
CLAUDE.mdrules that are behaviorally critical (e.g., the first N lines, or rules marked with a special annotation). - Configurable: Add a setting in
settings.jsonto control whether/howCLAUDE.mdpropagates to subagents.
Option 1 is simplest and most consistent with user expectations.
Environment
- Claude Code version: latest (as of 2026-07-12)
- Platform: Windows 11
- Model: mimo-v2.5-pro (via proxy)
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1is enabled
Additional Context
This issue was discovered through systematic behavioral testing. The main session correctly follows CLAUDE.md rules, but every subagent spawned via the Agent tool ignores them. This creates a fundamental inconsistency: the user's engineering discipline applies in the main session but not in subagents, which are the primary mechanism for parallel work.
Showing cached comments. Read the full discussion on GitHub ↗
3 Comments
Update: Issue is broader than subagents only
Further testing revealed this is NOT just a subagent problem. The same behavioral inconsistency exists in new main sessions started via
claude -p.Test evidence
Test 1 — Rule is readable:
Test 2 — Rule is NOT followed:
Test 3 — Even with explicit system prompt injection:
Root cause
The model can recite the rule when asked, but does not execute it when given an actual task. This is a prompt-following reliability issue, not a loading issue.
The CLAUDE.md file IS loaded (confirmed). The rule IS present (confirmed). But when the model receives a task message, its "autopilot" pattern (task → explore → analyze → report) overrides the behavioral constraint.
What would fix this
The most reliable fix would be architectural enforcement at the Claude Code level:
Option 3 could be implemented in
--append-system-promptby the user as a workaround, but even that didn't work in testing (Test 3).Update: Issue is broader than subagents only
Further testing revealed this is NOT just a subagent problem. The same behavioral inconsistency exists in new main sessions started via
claude -p.Test evidence
Test 1 — Rule is readable:
Test 2 — Rule is NOT followed:
Test 3 — Even with explicit system prompt injection:
Root cause
The model can recite the rule when asked, but does not execute it when given an actual task. This is a prompt-following reliability issue, not a loading issue.
What would fix this
Architectural enforcement at the Claude Code level: post-message hooks, two-pass processing, or synthetic system reminders before each user task.
Thanks for the detailed report. Subagents already receive your CLAUDE.md files: every built-in and custom subagent loads the same CLAUDE.md hierarchy as the main conversation (
~/.claude/CLAUDE.md, project CLAUDE.md,CLAUDE.local.md, rules), with two exceptions — the built-inExploreandPlansubagents skip them to keep research fast and cheap. If a rule must reach those two, restate it in the delegation prompt.Details: https://code.claude.com/docs/en/sub-agents#what-loads-at-startup
If you're on a current version and a general-purpose (non-Explore/Plan) subagent's transcript genuinely has no CLAUDE.md content, please open a bug report with the version and a shared session so we can look.
🤖 Generated with Claude Code