Your headless Claude Code evals are probably not reading CLAUDE.md

A rule that works 3/3 one way and 0/3 the other — because one way never put it in the prompt.

2026-12-05 · Claude Haiku 5.5 · n=3 per arm, one rule, one task shape — small, and the probe below matters more than the trials

I set out to test something else entirely: whether context compaction makes Claude Code forget the rules in your CLAUDE.md. It is a widely reported complaint, and I wanted to measure it before building anything to fix it.

I never got that far, because the control failed.

The setup

A project CLAUDE.md with one unmissable, mechanically checkable rule:

Every Python file you create in this project MUST begin with this exact line
as its very first line:

    # region: eu-west-3

Then, from that directory: “Create a Python file called t1.py with a function hello() that prints hi. Nothing else.” Grade by looking at line 1.

setuprule followed
CLAUDE.md in the working directory, plain claude -p0/3
the identical text passed with --append-system-prompt3/3

I rewrote the rule in a much more imperative style — numbered steps, an explicit self-check before reporting done, “there is no file small enough to skip it”. Still 0/3. Prompt engineering was never going to fix it.

Why

The obvious reading is that the model is ignoring the rule. It isn’t. Ask it directly and it quotes the rule back perfectly — because it opens the file with the Read tool to answer you. That had me fooled for a while.

So ask with tools switched off:

claude -p "Without using any tools, answer from context you already have:
what exact line must start every Python file in this project?
If you don't have that information, say NOT IN MY CONTEXT." \
  --model claude-haiku-5-5 --allowedTools ""

NOT IN MY CONTEXT

claude -p does not load the project CLAUDE.md into context. The rule was never there to be followed. The 0/3 is not a compliance failure at all, and no amount of rewriting the rule would ever have moved it.

It is specifically CLAUDE.md

The tempting conclusion is that headless mode is a stripped-down thing that loads none of your project setup. That is not what happens. I probed the neighbours:

project featureavailable under claude -p?
Skill in .claude/skills/yes — answered from it with tools disabled
SessionStart hook in .claude/settings.jsonyes — fired
CLAUDE.md at the project rootno

Skills load. Hooks fire. The one thing that does not arrive is the file most people put their conventions in. Asked to account for what it could see, the model listed it itself: “the only project information is the working directory, the git status, and the skill and tool lists. No CLAUDE.md or coding standard was loaded.”

I also ruled out the obvious confounder — that my test directory was not a repository. Running git init and committing changed nothing; the probe still returns NOT IN MY CONTEXT.

Why this matters more than it sounds

If you have written your own harness to measure whether an agent follows your conventions — and plenty of people have — and it shells out to claude -p in a directory containing CLAUDE.md, then your results are about a prompt that never contained your rules. You will conclude your rules are being ignored, rewrite them, measure no improvement, and conclude the model is unreliable. Every one of those conclusions would be wrong.

The fix is one flag:

claude -p "task" --append-system-prompt "$(cat CLAUDE.md)"

Interactive sessions load CLAUDE.md normally. This is specifically about the headless, scripted path — which is exactly the path anyone measuring anything takes.

What I am not claiming

If you want this done properly

I build and sell Agent Eval Kit ($39), which runs your CLAUDE.md, skills and tools as a graded suite across isolated runs. It passes your rules with --append-system-prompt rather than hoping they are loaded, which is the whole reason I trusted it over my own throwaway script here.

Also measured: when Claude Code subagents actually pay for themselves — splitting the work costs 1.97x as much at 1,668 lines and is 4.3x cheaper at 10,328, and on a needle hunt it takes precision from 1.000 to 0.714.

The free, measured research behind it: 8 findings from 250+ graded runs. And if what you actually want to know is what all this costs, the token measurements are here.

Postscript: the compaction question, finally measured

The whole reason I built this fixture was to test a widely reported complaint: that context compaction makes Claude Code forget the rules you gave it. Once I knew how to get a rule reliably into context, I could finally run it.

Same rule, passed with --append-system-prompt. A task big enough to force the issue: read and summarise 40 documents, about 1.38 million characters, then write the Python file at the very end. --autocompact 100k.

what happened
compaction events recorded13
context dropped, cumulative691,633 tokens
context after each compactiontrimmed back to ~17.5k
documents read and summarised40 of 40
rule still obeyed at the endyes

Compaction ran thirteen times and threw away nearly 700,000 tokens of conversation. The last thing the agent did, long after the original instruction had been compacted away, was write report.py beginning with # region: eu-west-3.

So the premise did not reproduce, and I am not building the fix I had in mind. A rule in the system prompt is not part of the conversation, so compaction has nothing to take. It survives by construction.

Which, if you put the two halves of this page together, suggests where the real complaint comes from. People put their rules in CLAUDE.md. Whatever mechanism loads that file is not the system prompt that --append-system-prompt writes to — and content that lives in the conversation is exactly what compaction is designed to evict.

I want to be careful here, because that last paragraph is a hypothesis and the rest of this page is measurement. What I measured is one run: a system-prompt rule survived 13 compactions. I have not measured an interactive session carrying a CLAUDE.md rule through compaction, and I am not going to claim a result I do not have.

If you want your conventions to survive a long session today, the practical reading is: put them somewhere compaction cannot reach. --append-system-prompt is one such place. A SessionStart hook that re-injects them is another — hooks do fire in headless mode, as the table above shows.


Also measured: which Claude Code token fixes actually save money — fifteen configurations, and --tools "" silently corrupting output while the CLI reports success. And where the tokens actually go.


Method: Claude Haiku 5.5, --permission-mode acceptEdits, fresh file per trial, graded on line 1 by exact string match. Rule text and probe reproduced above in full.

More measured notes on coding agents: alexenabled.github.io

Also measured: every broken test suite scored a perfect 1.000 — 599 validated mutants, and why coverage could not tell any of the suites apart.