[DOCS] Sub-agents page: omitClaudeMd and Explore do not stop a nested CLAUDE.md or path-scoped rule loaded after a Read; --agent session has no git status
Documentation Type
Unclear/confusing documentation
Documentation Location
https://code.claude.com/docs/en/sub-agents
Section/Topic
"Frontmatter reference" (omitClaudeMd row), "What loads at startup", and "Invoke subagents explicitly" > "Run the whole session as a subagent"
Current Documentation
The omitClaudeMd row says: "Set to true to launch this subagent without the user, project, and local CLAUDE.md files; managed policy files still load, except for managed subagents."
"What loads at startup" says a subagent whose definition sets omitClaudeMd "loads only the managed policy files", and that Explore and Plan skip CLAUDE.md files and the git status snapshot.
"Run the whole session as a subagent" says that, unless the agent's prompt is empty, a custom subagent's system prompt "replaces the default Claude Code system prompt entirely, the same way --system-prompt does", and that CLAUDE.md files still load.
What's Wrong or Missing?
Measured on Claude Code 2.1.293 with a request-capturing local API server and a unique marker string in each instruction file:
- At startup,
omitClaudeMd: true(in frontmatter or in--agentsJSON) works as documented: none of the user, project, local or.claude/rules/content reached the subagent, while the same agent without the field received all of it. But after the subagent Reads a file in a subdirectory, that subdirectory'sCLAUDE.mdand apaths:-scoped rule matching the file arrive as system-reminders in its next request. The built-in Explore agent behaves the same way (Plan skipped CLAUDE.md at startup as documented; its read-triggered behaviour was not tested). Several sentences state the omission without a startup qualifier: the frontmatter row ("launch this subagent without the user, project, and local CLAUDE.md files"), "Explore and Plan skip your CLAUDE.md files", and "To launch one of your own subagents without the user, project, and local CLAUDE.md files". Nested CLAUDE.md loading on read is documented on the memory page, but not how it interacts withomitClaudeMdor Explore, so a reader can takeomitClaudeMdas a guarantee that no CLAUDE.md content reaches the subagent.
- A session started with
claude -p --agent <name>had no git status snapshot in its requests, while plainclaude -pin the same repository did. CLAUDE.md files loaded andomitClaudeMdwas ignored, both as documented. The page does not say whether the git status snapshot goes away with the replaced system prompt. (Only--agentwas tested, not theagentsetting or--system-promptalone.)
Suggested Improvement
- In the
omitClaudeMdrow and "What loads at startup", say that the omission applies to startup, and that a nestedCLAUDE.mdor a path-scoped rule can still be attached when the subagent reads a file they apply to, if that is intended. Add the same note for Explore, and confirm whether Plan behaves the same. - In "Run the whole session as a subagent", say whether the git status snapshot is kept or dropped.
Impact
Medium - Makes feature difficult to understand
Additional Context
Method: a throwaway git repo with a different marker string in each of CLAUDE.md, CLAUDE.local.md, .claude/rules/*.md, a parent repo's rules, a paths: sub/** rule and sub/CLAUDE.md. Each case ran claude -p against a local server that recorded every request. Positive control: the main loop's first request carried all the startup markers in every run except the --bare and --safe-mode cases, where their absence was the expected result. The startup omitClaudeMd case was repeated in the interactive TUI with the same result.
Steps to reproduce item 1:
- In a git repo, create
sub/CLAUDE.mdcontaining a unique string, andsub/file.txt. - Create
.claude/agents/omit-probe.md:
````
---
name: omit-probe
description: Reads one file and reports its first line
omitClaudeMd: true
---
Read the file you are given and reply with its first line.
- Start a session and ask: "Use the omit-probe agent to read sub/file.txt."
- Inspect the subagent's request after the Read (for example with
ANTHROPIC_BASE_URLpointed at a logging proxy): thesub/CLAUDE.mdstring is present as a system-reminder. Its first request does not contain it.
Related: #92750 (another item in the same "What loads at startup" list).
Environment: Claude Code 2.1.293, macOS.
3 Comments
Follow-up: I have now tested the built-in Plan agent's read-triggered behaviour, which the issue says was not tested. On the same build (Claude Code 2.1.293), with the same setup, it matches Explore. It skipped CLAUDE.md at startup, as documented, but after it read
sub/file.txt, thesub/CLAUDE.mdstring and thepaths: sub/**rule arrived as system-reminders in its next request.So the first suggestion covers Plan too: the read-triggered note should apply to Explore, Plan, and any subagent with
omitClaudeMd: true.A related case: when the session runs in the home directory,
~/.claude/is a subdirectory of the working directory, so anomitClaudeMd: truesubagent gets the user-level~/.claude/CLAUDE.mditself attached as a nested file on its first read of anything under~/.claude/.Repro (Claude Code 2.1.295):
~/.claude/CLAUDE.md.omitClaudeMd: true.claudein~and have the subagent rungrep -n x ~/.claude/skills/<any skill>/<any file>.md.~/.claude/CLAUDE.mdstring.Notes:
~/.claude/projects/) triggers it too, so it can happen without the subagent ever choosing a~/.claude/path.Suggestion: have
omitClaudeMdalso cover on-demand loads, or at least never re-attach the user-level~/.claude/CLAUDE.mdas a nested file.Measured on Claude Code 2.1.296, macOS. Each action ran in a fresh
claude -psession. AnInstructionsLoadedhook was the ground truth, and every transcript was checked for exactly one tool call.What loads path rules and nested CLAUDE.md now:
cat/head/tail/nl/bat/sed -n, orgrep/rgwith a match. These also count inside a;or&&list.||, redirects (2>/dev/null), extra flags (cat -A),cd dir && cat file,grep -r, a grep with no match, and every Bash write (sed -i,>,>>, heredoc,python -c,cp).A fix that keeps Bash: a root CLAUDE.md brief that explains the gap and asks for one plain read per folder before working there. Tested on Opus in auto mode with
bashFirst:trueconfirmed in every session: 5 edit tasks × 3 runs per arm.| | No brief | Strict "Edit/Write only" brief | Read-first brief (below) |
|---|---|---|---|
| Rule loaded | 5/15 | 15/15 | 15/15 |
| Bash writes | 12/15 | 2/15 | 2/15 (after a Read) |
| Avg tool calls | 2.4 | 2.5 | 2.3 |
Small sample, and it's a workaround, not a fix, but it's been holding up for us.