Dev.to AI 🤖 Ai 👁 0 📖 4 min read

Claude Code Ignoring CLAUDE.md? See What's in Its Context

When Claude Code ignores a rule, the usual move is to reword it. Start with the verb, use backticks for literals, bold segments that you want to maintain elevated focus over the surrounding prose, and so on. Before doing

Claude Code Ignoring CLAUDE.md? See What's in Its Context

When Claude Code ignores a rule, the usual move is to reword it. Start with the verb, use backticks for literals, bold segments that you want to maintain elevated focus over the surrounding prose, and so on. Before doing any of that, there is a cheaper, and apparently a widespread, question to answer: was the rule in the agent's context at all?

Those are two different failures. A rule that loaded and was still not followed is a wording or enforcement problem. A rule that never loaded is a plumbing problem, and no amount of rewording fixes it. Often it is the first kind: the file loads, the agent can quote it back, and it still drifts. Telling the two apart decides which fix you need.

So I opened an old project in Claude Code and looked at what actually reached the agent.

The project: SageCompass

SageCompass is my LangGraph project from last winter. I wrote its instruction files by hand, before Reporails existed, and the last commit is from January 21, 2026. Nobody tuned it for this.

Here is what it carries, outside the Drupal core folder:

What Count How it reaches the agent
CLAUDE.md files 25 The ones in and above the start folder load at launch; a nested one loads when the agent works in its folder
AGENTS.md files 11 Read by Codex, Copilot and Cursor; Claude Code skips all 11 because a CLAUDE.md sits at the root (ails expected-loads)
Rule files in langgraph/.shared/rules/ 17, plus INDEX.md Nothing loads them automatically; CLAUDE.md lines point at them

Every folder under langgraph/app/ has its own CLAUDE.md. The one in app/graphs/ opens like this:

# Local scope: app/graphs

This file is the **primary** instruction surface when editing `app/graphs/**`.

The session

Yesterday I opened Claude Code 2.1.311 in sagecompass/langgraph for the first time in ten months and asked it to look around: "let's take a look around in the project, we haven't opened it for 10 months". It read the system map, walked the graph code, ran the quality gates and the tests, and reported that everything still passes. Then I asked about an error I kept seeing at the end of each turn, and it fixed that too.

18 shell commands over two prompts. Then I opened the session:

npx @reporails/cli xray

ails xray serves a page on 127.0.0.1 and reads the session transcript Claude Code already keeps under ~/.claude/projects/. The Graph tab puts the agent on a timeline, with every instruction file, rule, skill, memory file and MCP server on the left at the moment it first loaded.

ails xray Graph tab for the SageCompass session: two CLAUDE.md files and one MCP server loaded at 0:00, peak context 65k

Two instruction files loaded, both at launch: the root CLAUDE.md and langgraph/CLAUDE.md. No other instruction file entered the agent's context for the rest of the session. Peak context was 65k tokens. The two files were about 2.3k of it (~771 for the root file, ~1.5k for langgraph/CLAUDE.md); tool calls and results were ~22k, tool definitions ~14k.

Loaded, or never loaded

The Sources list shows what the session could have loaded and what happened to each item: loaded, listed but never loaded, on disk but never loaded, or not recorded in this session.

For this session the Sources list counts 11 instruction files a session in langgraph/ can load. Two loaded. The other nine, one for each folder under app/ plus tests/, read not loaded.

ails xray Sources list: Instructions 2/11, with nine nested CLAUDE.md files marked not loaded

One of the nine is app/graphs/CLAUDE.md, the self-declared primary instructions for the folder whose code the agent read. At 0:13 it ran sed -n 1,200p app/graphs/graph.py. Every read in the session went through the shell, and app/graphs/CLAUDE.md never loaded.

Had the agent gone on to edit graph.py the same way, it would have worked without the file that says how graph modules should be written. That file needed a loading fix before any wording fix.

Click that call in the Tool calls tab and the page shows what the agent had at that moment: 40k tokens of context, and two instruction files, the root CLAUDE.md and langgraph/CLAUDE.md.

ails xray Tool calls tab: the graph.py read at 0:13, with the two instruction files in context at that call

CLAUDE.md best practices this session points to

  • Check the session before rewriting the rule. If the x-ray shows the file loaded, look at the wording or the enforcement next. If it never loaded, fix the loading first.
  • Don't count on a nested file for a must-follow rule. A folder's CLAUDE.md depends on how the agent reaches that folder; in this session it never loaded. A rule that has to hold on every change belongs in a file that loads at launch, or behind a hook that checks it.
  • Point at files that exist. langgraph/CLAUDE.md line 128 says See .shared/rules/testing.md. That file was split into five testing-*.md files months ago, and the pointer kept the old name. A broken pointer fails quietly; the agent's only signal is a failed read.

What the x-ray covers

The x-ray reads Claude Code sessions. SageCompass's 11 AGENTS.md files are read by Codex, Copilot and Cursor; the x-ray does not show those agents' sessions. On a Team or Enterprise machine it reads the settings your organization sets in the claude.ai admin console, so it shows the context that policy produced.

It runs locally. The page serves on 127.0.0.1 and reads session files already on your machine. The Check and Fix buttons are the only part that reaches the Reporails server.

Try it on your own session

Run it in the folder you started Claude Code in:

npx @reporails/cli xray

With the Reporails plugin installed, ask the agent for /reporails:ails xray and it opens the session you are in. The Reporails CLI shows what your agent actually had in context, and ails check scores the instruction files that put it there.

📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.