Skip to content
gentic.news — AI News Intelligence Platform
Connecting to the Living Graph…

Listen to today's AI briefing

Daily podcast — 5 min, AI-narrated summary of top stories

Developer checking a CLAUDE.md rules file while a terminal shows a context window debug command, illustrating rule…
Products & LaunchesBreakthroughScore: 94

Stop Rewriting CLAUDE.md: Use /context and InstructionsLoaded to Debug Why

Use /context and the InstructionsLoaded hook to verify CLAUDE.md files actually load. Fix lazy-loading issues (nested files, @imports) before editing rule wording. Only rewrite rules after confirming they're in context.

·6h ago·5 min read··16 views·AI-Generated·Report error
Share:
Source: dev.tovia devto_claudecodeCorroborated
How do I debug why Claude Code is ignoring my CLAUDE.md rules?

Run /context and check the Memory files list. If your rule isn't there, it's a loading problem. Fix it by moving nested CLAUDE.md files to the root, checking @import syntax (max 4 hops, no backticks), or using the InstructionsLoaded hook to log every load.

TL;DR

Most 'Claude ignored my rules' issues are loading problems, not wording problems. Debug with /context and the InstructionsLoaded hook before rewriting anything.

You wrote the rule. The agent ignored it. Before you rewrite the wording — check whether the rule was ever in the context window at all. In my experience most "Claude ignored my CLAUDE.md" reports are actually loading problems, and loading problems are checkable in seconds.

Here are the three checks I run, in order.

Key Takeaways

CLAUDE.md Best Practices: 9 Rules for 2026 | TECHSY

  • Use /context and the InstructionsLoaded hook to verify CLAUDE.md files actually load.
  • Fix lazy-loading issues (nested files, @imports) before editing rule wording.
  • Only rewrite rules after confirming they're in context.

1. /context — the ground truth for the current session

Run /context in your session and look at the Memory files list. That list is what actually loaded — not what exists on disk, not what should have loaded. If your file isn't there, no amount of prompt-wording work will help.

Don't confuse it with /memory. The /memory command lists memory file locations across user and project scopes — including entries for files that don't exist yet, so you can create them. It answers "where could instructions live?" /context answers "what is Claude actually reading right now?" When you're debugging, only the second question matters.

2. Know the two lazy-loading behaviors

Two loading rules produce almost all of the "my rule vanished" confusion:

Nested CLAUDE.md files load on demand. CLAUDE.md files in the directory hierarchy above your working directory load in full at launch. But a CLAUDE.md sitting in a subdirectory below it does not load until Claude actually reads a file in that subtree. Early in a session, that rule effectively does not exist — and /context will honestly show it missing until the first file access triggers it. If a rule must always apply, keep it in the root file (or a .claude/rules/ file without a path scope), not in a nested CLAUDE.md.

Imports have sharp edges. @path/to/file imports load at launch alongside the file that references them, and they can chain — but only to a maximum depth of four hops. Two details bite people:

  • Import parsing skips code spans and fenced code blocks. `@README` in backticks is literal text; @README outside backticks is an import. If you documented an import inside a code fence while "cleaning up", you silently disabled it.
  • Relative paths resolve relative to the file containing the import, not your working directory. A fragment that imports ./shared.md breaks when you move it.

In practice I've never needed more than two hops on a real project (root importing AGENTS.md, which sometimes imports a shared fragment). If you're approaching four, the chain itself is usually the thing to fix.

3. InstructionsLoaded — log every load as it happens

Since you can't sit in a session running /context after every file access, Claude Code has a hook event for exactly this: InstructionsLoaded fires every time a CLAUDE.md or .claude/rules/*.md file enters context — at session start for eagerly-loaded files, and again mid-session when a nested file or path-scoped rule lazily loads.

The hook input tells you three things: file_path (which file), memory_type (User / Project / Local / Managed), and load_reason. The load_reason values are the interesting part:

  • session_start — loaded eagerly at launch
  • nested_traversal — a subdirectory CLAUDE.md just lazy-loaded
  • path_glob_match — a path-scoped rule matched a file Claude touched
  • include — pulled in via an @path import
  • compact — reloaded after context compaction

A minimal logger in .claude/settings.json:

{
  "hooks": {
    "InstructionsLoaded": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "jq -r '\"\(.load_reason)\t\(.file_path)\"' >> ~/.claude/instructions-loaded.log"
          }
        ]
      }
    ]
  }
}

Now tail -f ~/.claude/instructions-loaded.log shows you the exact moment that nested CLAUDE.md finally entered context — instead of you inferring it from a behavior change three prompts later. The hook is observability-only (it runs async, exit codes are ignored), so it can't break anything.

You can also filter with a matcher on the load reason, e.g. "matcher": "nested_traversal|path_glob_match" to log only lazy loads.

The 30-second debugging flow

  1. Rule ignored? Run /context. File not under Memory files → loading problem, stop editing the wording.
  2. File is nested in a subdirectory → expected: it loads only after Claude reads that subtree. Move it to the root if it must always apply.
  3. File is imported → check the import isn't inside backticks or a code fence, check the relative path from the importing file, and count your hops (max four).
  4. File loaded but behavior is still wrong → now it's an instruction-quality problem. Rewrite for specificity, check for contradicting rules, and keep the file under ~200 lines.

Only step 4 is a prompt-engineering problem. Steps 1–3 are mechanical, and the InstructionsLoaded log turns them from guesswork into a grep.

For the full resolution order (which files load, in what order, and what wins), I walked through it in Which CLAUDE.md Files Claude Code Actually Loads (and in What Order).


Source: dev.to

Sources cited in this article

  1. You
Source: gentic.news · · author= · citation.json

AI-assisted reporting. Generated by gentic.news from 1 verified source, fact-checked against the Living Graph of 4,300+ entities. Edited by Ala SMITH.

Following this story?

Get a weekly digest with AI predictions, trends, and analysis — free.

AI Analysis

Claude Code users should stop treating every ignored rule as a prompt-engineering failure. The debugging flow is now mechanical: run `/context` first, and if the file isn't in Memory files, you're dealing with a loading problem. This changes your workflow because you'll spend your time fixing file placement and import syntax instead of endlessly rewriting CLAUDE.md wording that was never loaded in the first place. Set up the `InstructionsLoaded` hook logging today. It's a one-time config change in `.claude/settings.json` that gives you a persistent audit trail. When you add a new rule or restructure your CLAUDE.md hierarchy, run a quick session and `tail -f` the log to verify everything loads as expected. This is especially valuable after context compaction — the `compact` load reason tells you whether your rules survived the squeeze. Finally, adopt a convention: keep universal rules in the root CLAUDE.md or `.claude/rules/` without path scope, and reserve nested CLAUDE.md files for truly directory-specific instructions. This aligns with the recent Claude Code skills feature (introduced July 2026) — skills in `~/.claude/skills/` are a more structured alternative to nested rule files when you need reusable instruction packs.

Mentioned in this article

Enjoyed this article?
Share:

AI Toolslive

Five one-click lenses on this article. Cached for 24h.

Pick a tool above to generate an instant lens on this article.

Related Articles

From the lab

The framework underneath this story

Every article on this site sits on top of one engine and one framework — both built by the lab.

More in Products & Launches

View all