Guides

.claude/rules not loading

A file in .claude/rules/ either loads at launch, like CLAUDE.md, or waits for Claude to touch a file that matches its paths. Most "my rule is ignored" reports are a rule stuck in the wrong one of those two states: a pattern that matches nothing, frontmatter that didn't parse, or a read that never happened. I built a rules folder with each mistake in it, ran Claude Code 2.1.328 headless, and checked which rules it could see before and after a read. Here's what loaded, and why.

Quick check. Does the rule have a paths field? Then it is not supposed to be in context at launch. Ask Claude to Read a file that matches, then run /context all and look for the rule under Memory files. No paths field and still missing at launch: check the YAML parses and that the file ends in .md.

How rules load

From the memory docs: "Place markdown files in your project's .claude/rules/ directory." All .md files there "are discovered recursively". "Rules without paths frontmatter are loaded at launch with the same priority as .claude/CLAUDE.md." A rule with paths "loads when Claude uses the Read, Write, or Edit tool on a matching file", or views one "with a Bash command that counts as a read, such as cat or head on a single file". Patterns are relative to "the directory that contains the rule's .claude folder" for project rules, and to the session's primary working directory for rules in ~/.claude/rules/.

And the one line that explains half the reports: "paths is the only field Claude Code reads from a rule; any other field is ignored without an error."

1. The pattern matches nothing

A rule with paths: ["app/web/**"] in a repo whose code lives under packages/ will never load, and Claude Code never tells you. It usually happens after a folder is renamed. Globs are relative to the folder that holds .claude, and the docs' table has the details that trip people: *.md matches .md files anywhere, /*.md only in the base folder, and src/components/*.tsx doesn't recurse. A [ that isn't a bracket expression makes the pattern invalid (it matches nothing while the rule's other patterns keep working). Brace groups multiply: {a,b}/{c,d}/*.{ts,tsx} is eight patterns, against a budget of 1,000 per rule.

The linter's path-rule-matches-nothing warning is the check for this, and it's the one in the output below. It stays quiet for extension-only patterns like **/*.py, since a language rule with nothing to match is harmless.

2. It loads on a read, not at launch

This is the cause that generates the most issues, because it isn't a bug. A path-scoped rule joins the context when Claude Reads, Writes or Edits a matching file, or cats one. Three situations where that never happens:

  • Claude creates the file. The docs now list Write among the triggers, but #93248 (September, open) reported that creating a matching file didn't load the rule. If a rule covers files that don't exist yet, check it on your version before relying on it.
  • Claude works through Bash. A sed or a grep over the folder isn't a read of a single file. #90450, with 25 comments, is a mode that steers the model toward Bash and so never trips the rule.
  • After /compact. Rules with paths "load again on demand", so they're out of context until the next matching read.

In my test, the rule with a valid paths list wasn't visible before a read and was visible after one Read of src/api/users.ts. If a rule has to hold every time, the docs' advice applies: put it in the root CLAUDE.md or a rule without paths, and use a hook for anything that must never happen. A pointer line in the root file also works, at the cost of one tool call:

# Working in api/
Before changing anything under src/api/, Read src/api/README.md first.

3. The frontmatter didn't parse

Here's the one that looks like the opposite bug. "If the YAML between the markers doesn't parse, Claude Code ignores the frontmatter and loads the rule as if it had no paths." So a broken path rule doesn't vanish; it loads every session, for every file, frontmatter and all. My fixture's api.md had paths: "src/api/**/*.ts", "lib/**/*.ts", which reads naturally and isn't YAML (two scalars on one line). It was in context before any read, with its heading intact. A rule with a stray [ in the frontmatter did the same.

The docs say to run claude --debug to see the parse error. The two shapes that do parse:

---
paths:
  - "src/api/**/*.ts"
  - "lib/**/*.ts"
---
# API rules
Validate every request body before it reaches a handler.
---
paths: "src/api/**/*.ts, lib/**/*.ts"
---

4. A key that isn't paths

A rule copied from Cursor arrives with globs and alwaysApply. Claude Code reads neither, "ignored without an error", so the rule has no paths and loads every session. frontend/globs.md in the fixture, scoped to src/** in Cursor's terms, was in context at launch. Rename globs to paths, and drop alwaysApply, description and anything else; they cost tokens and do nothing. The linter reports each one as unknown-key. Cursor rules has the mapping the other way.

5. User-level rules with paths

Rules in ~/.claude/rules/ apply to every project. With a paths field, the patterns are matched against "the session's primary working directory", so src/**/*.ts in a user rule means src/ of whatever project you started in. #87217 reported user rules with paths loading at neither launch nor on a match; it's closed, and the current docs describe the matching base, so if you're on an older build, update before debugging further. Also from the docs: user rules load before project rules, and "neither set overrides the other", so a conflict between the two is settled by the model.

You can symlink a shared rules folder into .claude/rules/, with two catches. A symlink whose target is outside the working folder is treated "like an external import": "The linked rules don't load until you approve external imports for the project, and after that only the ones without a paths field load." The approval dialog appears once per project at the start of an interactive session, so a headless run never approves it. And a link to a network path (\\server\share, /net, /Network) is never followed. For shared rules without the dialog, the docs point at ~/.claude/rules/.

7. Turned off by a setting

Four switches can keep a rule out, none of them in the rule itself. --setting-sources without project skips project rules (before v2.1.211, on-demand rules loaded anyway). A claudeMdExcludes pattern can match a rules folder, including one reached through a symlink. The Project instructions setting managed-only leaves .claude/rules/ out at launch. And a Read deny rule that covers the file produces the one notice Claude Code does print: Instruction file not loaded (a Read deny rule covers it), documented on the errors page. If you see that line, the fix is in /permissions, not in the rule.

8. Over the per-file limit

Since v2.1.309, files that load on demand have a size cap: path-scoped rules, a subfolder's .claude/rules/, and subfolder CLAUDE.md files with their imports. On a 200K context window it's 40,000 characters. Over it, "Claude receives only the start of it", ending in a note to read the rest with the Read tool, which it may or may not do. wc -m on the file tells you. The docs' advice is to split into more rules files, since each counts on its own. CLAUDE.md in a monorepo covers the other limits.

The test, and what loaded

The fixture, one rule per mistake:

.claude/rules/
  always.md           no frontmatter
  api.md              paths: "a", "b" (not valid YAML)
  frontend.md         paths: ["app/web/**"] (no such folder)
  frontend/globs.md   globs and alwaysApply (Cursor keys)
src/api/users.ts
lib/util.ts

Lint catches three of the four before a session starts:

$ npx -y asitis@0.4.8 lint

.claude/rules/api.md:2:1 error frontmatter-yaml Frontmatter YAML does not parse (Unexpected scalar at node end). Claude Code may not read this rule's paths, so fix the YAML

.claude/rules/frontend.md:2:1 warning path-rule-matches-nothing No file in this project matches paths "app/web/**". Claude Code loads this rule only when it reads a matching file, so it never loads. Fix the pattern or delete the file

.claude/rules/frontend/globs.md:2:1 note unknown-key Frontmatter key "globs" is not read by Claude Code rules (paths is the only field they read), so it does nothing; delete it, or keep it only if your own tooling reads it
.claude/rules/frontend/globs.md:3:1 note unknown-key Frontmatter key "alwaysApply" is not read by Claude Code rules (paths is the only field they read), so it does nothing; delete it, or keep it only if your own tooling reads it

Linted 5 files: 1 error, 1 warning, 2 notes.

The load view sorts them into launch-time and later, and is where the parse failure becomes obvious: the broken rule is listed as "rule without paths, so it loads every session":

$ npx -y asitis@0.4.8 loads . --tool claude-code

Claude Code: about 48 tokens at launch from 4 files; 1 more file can load later (up to about 18 tokens)
  At launch
    1. CLAUDE.md, about 2 tokens, project instructions
    2. .claude/rules/always.md, about 10 tokens, rule without paths, so it loads every session
    3. .claude/rules/api.md, about 19 tokens, rule without paths, so it loads every session
    4. .claude/rules/frontend/globs.md, about 17 tokens, rule without paths, so it loads every session
  Later, when the agent works in a folder or on matching files
    5. .claude/rules/frontend.md, about 18 tokens, when Claude reads or edits a file matching app/web/** (no file matches now)

Then Claude Code 2.1.328, headless, tools disabled, asked for every marker word in its instructions. Before any read it listed the markers from always.md, the broken-YAML rule and the Cursor-keys rule. After one Read of src/api/users.ts and lib/util.ts it added the rule with a valid list and the one with a comma-separated string. The app/web/** rule never appeared. A rule in a nested folder, .claude/rules/backend/db.md with no frontmatter, loaded at launch. All of that matches the docs and the load view.

Confirm what loaded

  1. /context all. The debug guide says to run it first. Rules without paths are under Memory files from the start; path-scoped ones appear after a matching read.
  2. An InstructionsLoaded hook. The docs recommend it for "debugging path-specific rules or lazy-loaded files". This logs every event to one file:
    {
      "hooks": {
        "InstructionsLoaded": [
          {
            "hooks": [
              { "type": "command", "command": "cat >> ~/.claude/loaded.log" }
            ]
          }
        ]
      }
    }
  3. claude --debug. Shows the YAML parse error for cause 3 and names files refused for cause 7.
  4. Lint and loads. npx -y asitis@0.4.8 lint flags a pattern that matches nothing, frontmatter that doesn't parse and keys Claude Code doesn't read. asitis loads <folder> prints which rules load at launch and which wait for a read. It's a static model of the documented rules, so it can't see a deny rule or a dismissed approval dialog.

Check your file

Paste a rules file into the steering file checker and it tells you whether the paths pattern parses, what it matches and which keys Claude Code ignores. The plugin's /asitis:md-loads prints every rule in a folder sorted into launch-time and on-read.

Open the steering file checker

To check every steering file in a project from inside Claude Code, including links, @imports and what loads every session, install the free AsItIs plugin. It is read-only and makes no network calls.

claude plugin marketplace add Katta041/asitis-agent-tools
claude plugin install asitis@asitis

About the pluginSource on GitHub

MIT licensed. A star on GitHub helps other people find it.

Questions

Do rules in subfolders of .claude/rules load?

Yes. The docs say all .md files are "discovered recursively, so you can organize rules into subdirectories like frontend/ or backend/". A rule in .claude/rules/backend/db.md with no paths field loaded at launch in my test. A subfolder's own .claude/rules/ (for example packages/api/.claude/rules/) is a different thing: those load on demand, when Claude works in that folder, and are subject to the per-file size limit.

Can I give paths as a comma-separated string instead of a list?

Yes, as one quoted string: paths: "src/api/**/*.ts, lib/**/*.ts". The docs say the field "accepts a YAML list or a comma-separated string", and the string form loaded after a read in my test. Two quoted strings separated by a comma is not valid YAML, and that mistake turns the rule into an unconditional one.

Why doesn't my path-scoped rule show in /context all?

Because it hasn't matched yet. /context lists what is in the context window now, and a rule with paths joins only after Claude reads, writes or edits a matching file. The debug guide notes the same for subdirectory CLAUDE.md files: they "load on demand rather than at session start, so they don't appear in that breakdown". Read a matching file, then run /context all again.

Do rules survive /compact?

Rules with paths load again on demand after compaction, which means they are not in context until Claude touches a matching file again. The docs: "Nested CLAUDE.md files in subdirectories and rules with paths: frontmatter load again on demand." A rule without paths behaves like the project CLAUDE.md and is re-read from disk.

Do rules count toward the 200-line recommendation?

Each rules file counts as its own file. The docs say that when one instruction file is over the recommended length you get a warning at startup, and "each CLAUDE.md, rules file, and @path import counts as a separate file". Rules that load on demand also have a hard per-file limit: 40,000 characters on a 200K context window, after which Claude receives only the start of the file.

See what an agent changed in your CLAUDE.md. Keep or revert each change.

The linter is free and needs no signup. I'm also building a desktop editor for the markdown your agents write and read. It shows what an agent changed since you last looked, lets you keep or revert each change, and never touches a line you didn't edit. No release date yet. One email to confirm, one when the paid beta opens, one when 1.0 ships. $29 once for a founding licence, with 24 months of updates.

Or add the linter to CI, no email needed.

Your address is stored with Cloudflare, which hosts this site. No IP address is kept. See the privacy policy.

Related: CLAUDE.md in a monorepo, Claude Code ignores my CLAUDE.md, CLAUDE.md @import not working, Cursor rules.

Sources, read on 23 November 2026: Claude Code docs, Organize rules with .claude/rules/, Path-specific rules, Rule frontmatter reference, Share rules across projects with symlinks and Troubleshoot memory issues in How Claude remembers your project, Debug your configuration and Instruction file not loaded; GitHub issues #90450, #93248 and #87217 on anthropics/claude-code. Quotes are exact. Test runs: Claude Code 2.1.328 in headless mode with tools disabled except Read, on macOS, 23 November 2026; command output from asitis 0.4.8 on the same fixture, trimmed for width.