docs: clarify that project CLAUDE.md / AGENTS.md are not inherited by subagents

Resolved 💬 2 comments Opened May 27, 2026 by amitgaur-zengineer Closed May 31, 2026

Summary

The behavior of project-level CLAUDE.md (and AGENTS.md) when subagents are dispatched via the Agent / Task tools is not documented. From testing, project CLAUDE.md is not automatically injected into a subagent's context the way it is for the parent agent, but most users I've talked to assume it is. The docs should state this explicitly and point to the supported workarounds.

Reproduction

  1. In a clean repo, create CLAUDE.md at the root with a distinctive, easy-to-spot rule, e.g.:

``
# CLAUDE.md
For any "explain this file" request, respond with the literal string
"RULE-ACKNOWLEDGED" and nothing else.
``

  1. Start a Claude Code session in that repo. Confirm the parent agent honors the rule when asked to explain a file (e.g. README.md).
  2. From the parent, dispatch a subagent:

``
Agent({
subagent_type: "general-purpose",
prompt: "Explain what README.md does."
})
``

  1. Observe the subagent's response.

Expected

Either:

  • The subagent honors the rule (CLAUDE.md is inherited), or
  • The docs make clear that subagents do not inherit project CLAUDE.md and that authors must use custom subagent definitions or hooks for cross-agent policy.

Actual

  • The subagent ignores the rule and produces its default "explain the file" response.
  • The subagents docs page does not mention CLAUDE.md inheritance behavior one way or the other.
  • The CLAUDE.md / memory docs page does not mention that the file's scope is the parent agent only.

Related observation: subagent self-introspection is unreliable

When the same subagent is asked "do you have the project CLAUDE.md loaded in your context?", it confidently answers yes and even paraphrases plausible-sounding content — even though its subsequent behavior makes clear the file is not actually in context. The model appears to confabulate from the filename. Worth calling out as a known limitation; users testing inheritance behavior shouldn't trust the agent's self-report.

Out-of-scope follow-up

There's a separate, deeper question about model compliance with explicit in-prompt rules even when CLAUDE.md content is pasted directly into the subagent prompt — that's a product / model-behavior topic and probably belongs as a separate enhancement issue rather than a docs issue. Mentioning here only so it isn't conflated with the doc gap above.

Suggested fix

Add a short section to the subagents documentation page (and a cross-link from the CLAUDE.md / memory page) stating:

  • Project CLAUDE.md and AGENTS.md are loaded into the parent agent only; subagents dispatched via Agent / Task do not inherit them.
  • To apply project rules to subagents, define a custom subagent in .claude/subagents/<name>.md with the rules embedded in its system prompt, or use a PreToolUse hook to enforce policy at runtime.

Environment

  • Claude Code: 2.1.152
  • OS: macOS (Darwin 25.4.0)
  • Model: Opus 4.7 (1M context); also reproduces on Sonnet 4.6

View original on GitHub ↗

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