[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

Status Open
Reported on v2.1.293
Maintainer reply None cached
Activity 3 comments · opened Oct 8, 2026

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:

  1. At startup, omitClaudeMd: true (in frontmatter or in --agents JSON) 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's CLAUDE.md and a paths:-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 with omitClaudeMd or Explore, so a reader can take omitClaudeMd as a guarantee that no CLAUDE.md content reaches the subagent.
  1. A session started with claude -p --agent <name> had no git status snapshot in its requests, while plain claude -p in the same repository did. CLAUDE.md files loaded and omitClaudeMd was ignored, both as documented. The page does not say whether the git status snapshot goes away with the replaced system prompt. (Only --agent was tested, not the agent setting or --system-prompt alone.)

Suggested Improvement

  • In the omitClaudeMd row and "What loads at startup", say that the omission applies to startup, and that a nested CLAUDE.md or 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:

  1. In a git repo, create sub/CLAUDE.md containing a unique string, and sub/file.txt.
  2. 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.
``

  1. Start a session and ask: "Use the omit-probe agent to read sub/file.txt."
  2. Inspect the subagent's request after the Read (for example with ANTHROPIC_BASE_URL pointed at a logging proxy): the sub/CLAUDE.md string 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.

View original on GitHub ↗

3 Comments

willmcginnis · 6 days ago

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, the sub/CLAUDE.md string and the paths: 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.

cmhils · 6 days ago

A related case: when the session runs in the home directory, ~/.claude/ is a subdirectory of the working directory, so an omitClaudeMd: true subagent gets the user-level ~/.claude/CLAUDE.md itself attached as a nested file on its first read of anything under ~/.claude/.

Repro (Claude Code 2.1.295):

  1. Put a unique string in ~/.claude/CLAUDE.md.
  2. Define a custom subagent with omitClaudeMd: true.
  3. Start claude in ~ and have the subagent run grep -n x ~/.claude/skills/<any skill>/<any file>.md.
  4. The subagent's next turn contains the ~/.claude/CLAUDE.md string.

Notes:

  • The Read tool triggers it too (seen from 2.1.287 on). Bash triggers it from 2.1.293 onward, but only when every segment of the command is a single-file read (no pipe, no other command).
  • Reading the subagent's own saved large tool output (stored under ~/.claude/projects/) triggers it too, so it can happen without the subagent ever choosing a ~/.claude/ path.

Suggestion: have omitClaudeMd also cover on-demand loads, or at least never re-attach the user-level ~/.claude/CLAUDE.md as a nested file.

yishait-tailor · 1 day ago

Measured on Claude Code 2.1.296, macOS. Each action ran in a fresh claude -p session. An InstructionsLoaded hook was the ground truth, and every transcript was checked for exactly one tool call.

What loads path rules and nested CLAUDE.md now:

  • Loads: Read, Write (including a new file), and a plain single-file cat/head/tail/nl/bat/sed -n, or grep/rg with a match. These also count inside a ; or && list.
  • Loads nothing: pipes, ||, 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:true confirmed 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 |

Context loading (known Claude Code gap). Path rules and nested CLAUDE.md load only on a Read/Write/Edit, or a plain single-file Bash read (cat, head, tail, sed -n, grep/rg with a match), with no pipes and no cd &&. Bash writes, pipes and multi-file commands load nothing. Before working in a folder, do one plain read of a file there; after that, use whatever is most efficient, Bash included. Repeat for each new folder, and again after /compact.

Small sample, and it's a workaround, not a fix, but it's been holding up for us.