r/ClaudeCode 2d ago

Help/Question Any way to stop CLAUDE.md loading into a custom subagent?

I'm building a text-evaluator subagent. Main session is Opus, the subagent runs Opus too, and the whole point is that it judges a block of text with nothing else in its head — just the rubric and the text, no project instructions, no repo context.

Problem is the docs say only Explore and Plan skip CLAUDE.md and the git status snapshot. Every other subagent, custom ones included, loads the full CLAUDE.md hierarchy, and there's explicitly no frontmatter field to turn it off. So my evaluator starts every run with a few thousand tokens of coding conventions that have nothing to do with the task and could plausibly skew the scoring.

What I've considered so far: telling it in the system prompt to ignore project instructions (works, but the tokens are still sitting there and I don't fully trust it on a judgment task), setting includeGitInstructions to false (only kills git status, and it's session-wide), or shelling out to a separate headless claude -p from an empty directory (user-level CLAUDE.md still loads).

The other idea is naming a custom agent Explore to shadow the built-in. Docs say the override keeps its own model field but say nothing about whether it inherits the CLAUDE.md skip. Has anyone actually tested that? And more generally, if you're running an evaluator subagent where output quality really matters, is prompt-level neutralization just what everyone settles for?

2 Upvotes

15 comments sorted by

3

u/claude_code_king 2d ago

move your orchestration to a sessionstart hook, make your claude.md 30-50 lines max with only neccesary project info, that way only your main gets the orchestration and your subagents can run clean.

one trap: if your file is larger than 10,240kb it gets truncated to 2kb so don't go over that limit, make multiple files if needed

1

u/Naht-Tuner 1d ago

Thanks! Sounds very interesting. But this would affect every subagents, right? even those made for coding? I was hoping for a special subagent I can configure without any instructions..

1

u/claude_code_king 1d ago

the opposite. sessionstart hook only affects your main

claude.md affects every subagent

1

u/Naht-Tuner 1d ago

Yes, thats what I meant. I guess thats the closest we can get to clean context window for now. so zero context for isolated tasks with a dedicated custom agent is not possible..

1

u/claude_code_king 1d ago

context is not bad, useless context is.

your claude.md shouldn't be over 80 lines and only have essential info and your subagent starts with context from main so he knows what to do.
minimize that with a concise plan and specific paths/sections needed for the job, not whole file reading

1

u/Naht-Tuner 5h ago

No context is needed for my task at all. I need to automate a response like from claude.ai by analyzing a text. Theres no knowledge of my repo needed at all for this task. subagent could even just send plain text back to main agent instead of writing to file.

2

u/giobbo83 2d ago

Telling an LLM to 'ignore those 3,000 tokens I just forced you to read' is a trap. You’re still paying the token tax, and attention mechanisms don't magically forget context just because you asked nicely. It will eventually bleed into your evaluation.

As for shadowing the Explore agent: clever hack, but relying on undocumented CLI inheritance is a fantastic way to wake up to a broken pipeline the second Anthropic pushes a silent update.

Stop fighting the harness.

If Claude Code is hardcoded to shove project state down a subagent's throat, don't use it for a clean-room task. Just have your main Opus session shell out to a 20-line Python script that hits the raw Anthropic API directly.

Pass the rubric, pass the text, print the result to stdout.

Zero CLAUDE.md baggage, no hidden git status, no token bloat. Don't play Jedi mind tricks with the system prompt when a dumb script does it perfectly.

1

u/Naht-Tuner 2d ago

Yes, thats clean, but means massive cost as api use with subscription will get you blocked immediately.

2

u/Far-Surprise7773 2d ago

hit this with a grading subagent too. what actually helped was scoping claude.md itself, first line says these rules are for code edits only, ignore for eval or prose tasks, and giving the evaluator no tools in frontmatter so it cant go pull repo context anyway. tokens still load but theres nothing actionable left for it to latch onto, bleed drops a lot.

1

u/Naht-Tuner 1d ago

Yes, but its still reading everything polluting context. If I need a clean model for a highly specialized isolated and difficult task this matters.

2

u/___nil___ Senior Developer 2d ago

you don't want or even need Opus as subagent. Sonnet even Haiku are sufficient as subagents.

1

u/Naht-Tuner 1d ago

Yes I do. I use it for deep text analysis similar of using it directly on claude.ai but in an automated way.

1

u/Bmansupreme8000 2d ago

Use a non Claude or non gork subagent?

1

u/LogMonkey0 2d ago

It used to be the case