Omniscio

OmniscioGuidesClaude Code rules

Claude Code rules: .claude/rules and when they load

A project-root CLAUDE.md is loaded in full every session, up to 4 MiB, whether or not the work touches most of it. Rules are the way to keep the same guidance in the repository and still pay for only the parts a task needs.

If you came for something else: the CLAUDE.md guide covers what belongs in always-loaded instructions, the .claude directory guide maps the rest of the folder, and the not-following guide covers the case where a rule loaded and Claude ignored it.

Sources read November 25, 2026. By the Omniscio team. Updated .

What a rule is

The .claude/rules/ directory holds project instructions split into multiple files, which keeps them modular and easier for a team to maintain. A rule can also be scoped to specific file paths, so it loads into context only when Claude works with matching files.

Whether a rule loads is mostly a timing question. A rule without a paths field loads at launch with the same priority as .claude/CLAUDE.md; a rule with one loads later, when a matching file is opened. The one place permission enters is a symlinked rule whose target sits outside the working directory, which also waits on an approval.

Rules are instructions Claude reads, in the same sense as CLAUDE.md. Anthropic's own note puts the alternative beside them: for task-specific instructions that do not need to be in context all the time, use a skill instead, which loads when you invoke it or when Claude decides it is relevant.

Anthropic gives a rule without paths the same priority as .claude/CLAUDE.md. When two instruction files disagree, the CLAUDE.md guide covers which one Claude follows and why.

Setting one up

Put markdown files in the project's .claude/rules/ directory, one topic per file, with a descriptive filename such as testing.md or api-design.md. Subdirectories work too, because discovery is recursive.

your-project/
├── .claude/
│   ├── CLAUDE.md
│   └── rules/
│       ├── code-style.md
│       ├── testing.md
│       ├── api-design.md
│       └── backend/
│           └── database.md

Nothing else is required. A file with no paths field is a rule that always loads, which suits house style and test conventions that apply to every file in the repository.

Rules that wait for a matching file

Add a paths list in YAML frontmatter and the rule applies only when Claude works with files matching those patterns.

---
paths:
  - "src/api/**/*.ts"
---

# API Development Rules

- All API endpoints must include input validation
- Use the standard error response format
- Include OpenAPI documentation comments

A path-scoped rule loads when Claude uses the Read, Write or Edit tool on a matching file. It also loads when Claude views a matching file with a Bash command that counts as a read, such as cat or head on a single file, and matching still works when Claude reaches the file through a symlinked path to the project directory.

Which directory the patterns measure from

Each pattern is relative to the rule's base directory. For a project rule that is the directory containing the rule's .claude folder; for a user-level rule it is the session's primary working directory. A path-scoped rule for a sibling git worktree loads only when the session runs in that worktree.

The pattern forms that matter

  • **/*.ts matches .ts files anywhere under the base directory.
  • src/**/* matches everything under the base directory's src/.
  • *.md matches .md files anywhere under the base directory, while /*.md matches only those directly in it, not in subfolders.
  • src/components/*.tsx matches .tsx files in that one folder, not in its subfolders.

Brace expansion works, so src/**/*.{ts,tsx} covers two extensions in one pattern. Each brace group multiplies the expanded patterns, and a rule's whole list shares a budget of 1,000 expanded patterns and 4 MiB. A pattern that would exceed the budget is used unexpanded, and its literal braces then match nothing.

The frontmatter, and what it costs

paths is the only field Claude Code reads from a rule. Any other field is ignored without an error, and the whole frontmatter block is removed before the rule loads into context, so it costs nothing on the way in.

The field takes a YAML list or a comma-separated string. If the YAML between the markers does not parse, Claude Code ignores the frontmatter and loads the rule as if it had no paths, which means it loads everywhere; claude --debug prints the parse error.

Four common reasons a rule stays silent

Find the symptom you have, because each one has a different fix.

1. It is a symlink into a shared repository

Symlinks work, but a link whose target is outside the working directory is treated like an external import: those rules do not load until you approve external imports for the project, and after that only the ones without a paths field load. The approval is asked once per project, in a dialog at the start of an interactive session, and the dialog lists the linked rule files beside any external @path imports. To skip the dialog, keep shared rules in ~/.claude/rules/.

2. The link points at a network path

A link to a UNC share such as \\server\share, or to a path under /net or /Network, is never followed, because looking it up can contact the host it names. \\wsl$ paths do not count as network paths and load normally.

3. The session excluded project settings

Project rules are skipped when project is excluded from --setting-sources. Before v2.1.211 that exclusion did not stop rules which load on demand, such as path-scoped ones.

4. The pattern measures from the wrong directory, or matches nothing

A user-level rule with src/** measures from the session's working directory, not from your home folder, so the same pattern can match in one project and match nothing in the next. A path-scoped rule also only loads once Claude opens a matching file, so a rule for code nobody has touched this session has not loaded yet.

A pattern can also be invalid rather than mistimed: glob syntax reads [ as the start of a bracket expression, so a pattern like photos [2024/** matches nothing, while the rule's other patterns keep working. Escape the bracket inside single quotes to match it literally.

When a rule loaded and Claude still ignored it, the cause is no longer the file: the not-following guide covers that case. For a YAML error, claude --debug prints the parse error.

Rules for every project

Personal rules live in ~/.claude/rules/ and apply to every project on the machine, which suits preferences like code style or commit message format that are not project-specific.

Claude Code loads user-level rules before project rules, so a project rule appears later in context. Neither set overrides the other: if a user rule and a project rule conflict, Claude may follow either one, so the two need to agree.

Rules, CLAUDE.md or skills

Choose by when the text needs to be in context. A rule without paths and a CLAUDE.md line load every session; a path-scoped rule loads when matching files are opened; a skill loads when it is invoked or when Claude judges it relevant.

The practical split: house rules that apply to every line of code belong in CLAUDE.md or a rule without paths, conventions for one part of the tree belong in a path-scoped rule, and a procedure you run on demand belongs in a skill. The CLAUDE.md guide covers what belongs in the always-loaded layer.

Sources

Every line on this page rests on one of these. The date beside each one is the day we read it.

  • How Claude remembers your project, for the Organize rules with .claude/rules/ section: setup, path-specific rules, the frontmatter reference, symlinks and user-level rules. Read November 25, 2026.
  • Explore the .claude directory, for rules/ in the project and home file tables and the line that rules are guidance Claude Code does not enforce. Read November 25, 2026.

No rule set was written for this page. Every pattern, path and limit is transcribed from those pages.

Common questions

What is the difference between .claude/rules and CLAUDE.md?

Both are instructions Claude reads. Rules split the same kind of guidance into one file per topic under .claude/rules, and a rule can be scoped to file paths so it loads only when Claude touches a matching file. A rule without paths frontmatter loads at launch with the same priority as .claude/CLAUDE.md.

When does a path-scoped rule load?

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.

Why is my .claude/rules file being ignored?

Four causes cover most cases: a symlink whose target is outside the working directory needs external-import approval, a rule that points at a network path never loads, excluding project from --setting-sources skips project rules, and a paths pattern relative to the wrong base directory matches no file.

Can a rule set a field other than paths?

No. paths is the only frontmatter field Claude Code reads. Any other field is ignored without an error, and the frontmatter is removed before the rule loads into context.

Do user-level rules override project rules?

No. Claude Code loads user-level rules before project rules, so a project rule appears later in context, but neither set overrides the other: if they conflict, Claude may follow either one.

Rules that hold across every session

Omniscio runs several agent sessions in one window, each with its own context and its own diff view, and hands each one the same project instructions. Any model, any harness: Claude Code, Codex, OpenCode, Devin, Pi, and Hermes all supported.