What you will be able to do
- Use @path imports to pull standards files and AGENTS.md into a CLAUDE.md
- Split a monolithic CLAUDE.md into topic files under .claude/rules/, scoped with paths: frontmatter
- Choose between per-directory CLAUDE.md files and central path-scoped rules for a monorepo
1.Why one big CLAUDE.md stops working
Teams tend to keep adding to the project CLAUDE.md until it covers everything: style, testing, API design, deployment, every package. The documentation gives a size target, and that target has a cost behind it. A long file takes up context in every session and makes Claude follow it less reliably.
There are two separate tools for modularity, and they do different jobs. @imports keep the files tidy and reusable, but everything they reference is still loaded at launch. Path-scoped rules in .claude/rules/ also save context, because each one loads only when Claude works with files that match it. Whichever you use, group instructions under headers and bullets, because organized sections are easier for Claude to follow than dense paragraphs.
Checkpoint 1 of 6· Check yourself
Which change actually reduces how much CLAUDE.md content is in context at session start?
Path-scoped rules load only when Claude works with matching files. Imported files load at launch just like the parent file.
“Move instructions that matter for only part of the codebase into path-scoped rules, which load only when Claude works with matching files.”Source: code.claude.com
Sources1
2.The @import syntax
Inside a CLAUDE.md, @ followed by a path pulls that file's contents in. You can import inline in a sentence or as a list item. A path starting with ~ points into your home directory, which lets a committed project file reference a personal file that each developer keeps for themselves.
See @README for project overview and @package.json for available npm commands for this project.
# Additional Instructions
- git workflow @docs/git-instructions.md
# Individual Preferences
- @~/.claude/my-project-instructions.mdIf an import points at a file outside your working directory, Claude Code asks you to approve external imports. The most common real-world use is a repository that already has an AGENTS.md shared with other AI coding tools. You don't need to duplicate it. Import it, then add the Claude-specific lines below the import.
@AGENTS.md
## Claude Code
Use plan mode for changes under `src/billing/`.The difference between an import and an instruction written in words matters. A sentence like "read AGENTS.md first" doesn't load anything. Claude sees the file only if it decides to open it. The @AGENTS.md import guarantees the content is loaded, and keeping that import never causes Claude to read AGENTS.md twice.
Checkpoint 2 of 6· Check yourself
A CLAUDE.md contains only the sentence "Follow the conventions in AGENTS.md." What does Claude get at session start?
A reference in words is just text. Replacing it with an @AGENTS.md import makes the content load reliably.
“A CLAUDE.md that tells Claude in words to read AGENTS.md: Claude sees AGENTS.md only if it decides to open the file.”Source: code.claude.com
Checkpoint 3 of 6· Exam question
Two engineers on the same team report that Claude behaves inconsistently: one gets careful adherence to a 'always run the linter before committing' rule, while the other says Claude never mentions the linter at all, even in the same repository on the same branch. Before assuming the rule text is unclear, what is the fastest way to confirm whether the inconsistency is actually a memory-loading problem?
Correct answer: A — Have each engineer run `/memory` and compare which CLAUDE.md, CLAUDE.local.md, and rules files are loaded to see if the linter rule is missing
- A. Correct. `/memory` lists exactly which CLAUDE.md, CLAUDE.local.md, and rules files are loaded in the current session; if the linter instruction is missing from one engineer's list, that immediately isolates the problem to a loading/scoping issue rather than instruction wording.
- B. Stale git objects do not affect which memory files Claude Code discovers and loads, and re-cloning is a disruptive step with no diagnostic value here.
- C. CLAUDE.md files are read fresh at the start of each session; no OS reboot is required or relevant to whether an instruction is loaded.
- D. Version mismatches could cause differences, but comparing versions doesn't reveal what's actually loaded, and instruction-following isn't gated by a required version match for diagnosis.
Sources1
3.Per-package CLAUDE.md files in a monorepo
In a monorepo, the root CLAUDE.md holds what applies everywhere, such as coding standards and commit conventions. Each package then gets its own CLAUDE.md for the conventions of its stack.
Run package scripts from the package directory, not the monorepo root.
Prefix commit subjects with the package name, for example `api: add rate limiting`.
Never edit files under packages/*/generated/. Run `npm run codegen` in the package instead.A per-package file lives alongside its code, so the people who own that directory maintain its conventions, and the instructions are versioned with the code. Because import syntax works in any CLAUDE.md, a package maintainer can use @ to pull in only the shared standards files that apply to their package. For example, the API package's CLAUDE.md might import an API-conventions document that the web package has no use for. The sources show the per-package files and the import syntax separately, not one combined example. The pattern simply relies on the maintainer knowing which standards their package needs. If there are packages you never work in, claudeMdExcludes can skip their CLAUDE.md files altogether.
{
"claudeMdExcludes": [
"**/packages/web/**"
]
}Checkpoint 4 of 6· Check yourself
Why is a per-package CLAUDE.md a good fit when each package has its own maintainers?
Per-directory files sit next to the code they describe, so the owners of that code keep them current.
“Directory owners maintain their own conventions; instructions are versioned with the code”Source: code.claude.com
Sources2
4.Topic files in .claude/rules/
Instead of one long file, .claude/rules/ holds one markdown file per topic. The documentation's example has code-style.md, testing.md and security.md next to the main .claude/CLAUDE.md. Rules files are committed like CLAUDE.md, and a user-level ~/.claude/rules/ exists for personal rules. A rule without frontmatter applies broadly. Adding a paths: field restricts it to files that match the given globs.
---
paths:
- "src/api/**/*.ts"
---
# API Development Rules
- All API endpoints must include input validation
- Use the standard error response format
- Include OpenAPI documentation commentsCheckpoint 5 of 6· Fill the gap
Which frontmatter field scopes this rule to matching files?
---
? :
- "src/**/*.{ts,tsx}"
- "lib/**/*.ts"
- "tests/**/*.test.ts"
---paths is the only rule frontmatter field. It takes glob patterns as a YAML list or a comma-separated string.
Source: code.claude.comRules and per-directory CLAUDE.md files overlap, so choose deliberately.
| Approach | File location | Loads when | Use when |
|---|---|---|---|
| Per-directory CLAUDE.md | Inside the directory, alongside its code | At launch when started from that directory, or on demand when Claude reads a file there | Directory owners maintain their own conventions; instructions are versioned with the code |
| Path-scoped rule in .claude/rules/ | Central .claude/ at the repo root | When Claude works with a file matching the rule’s paths: glob | You want all conventions in one place, or the same rule applies to many scattered paths |
Checkpoint 6 of 6· Check yourself
A test-naming convention applies to test files scattered across twenty directories. Where should it go?
Central path-scoped rules suit a rule that applies to many scattered paths. They also stay out of context until a matching file is touched.
“You want all conventions in one place, or the same rule applies to many scattered paths”Source: code.claude.com
Exam traps
Each one states something that sounds right. Open it to see what is actually true.
1.Breaking CLAUDE.md into @imported files shrinks what loads into context at launch.Why is that wrong?
Imported files load at launch too. Only path-scoped rules defer loading until Claude works with matching files.
Covered in Why one big CLAUDE.md stops working
2.Writing "read AGENTS.md" in CLAUDE.md is as good as importing it.Why is that wrong?
A reference in words only works if Claude decides to open the file. An @AGENTS.md import loads it reliably and never causes a double read.
Covered in The @import syntax
Practise it for real
Replace part of a long CLAUDE.md with a path-scoped rule and confirm what loads
1.Create .claude/rules/api.md with paths: frontmatter set to "src/api/**/*.ts" and move your API instructions into it
Why: Path-scoped rules load only when Claude works with matching files
You should see: The API instructions are no longer part of the project CLAUDE.md
2.Start a session and run /context, checking the list under Memory files
Why: /context shows which memory files actually loaded
You should see: Your project CLAUDE.md is listed. If a file you expected is missing, Claude can't see it
3.Run /memory
Why: It lists memory file locations across user and project scopes and lets you open each one
You should see: You can tell user-level files from project-level files and open either in your editor
Stuck? Get a nudge
If a rule never seems to apply, check that its paths: glob actually matches the files Claude is working on.
Sources
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.https://code.claude.com/docs/en/memoryOfficial docs
“Size: target under 200 lines per CLAUDE.md file. Longer files consume more context and reduce adherence.”
↩︎ Why one big CLAUDE.md stops working“Organized sections are easier for Claude to follow than dense paragraphs.”
↩︎ Why one big CLAUDE.md stops working“Claude Code asks you to approve external imports”
↩︎ The @import syntax“A CLAUDE.md that already imports AGENTS.md | Your CLAUDE.md, with AGENTS.md included through the import”
↩︎ The @import syntax“Glob patterns that scope the rule to matching files. Accepts a YAML list or a comma-separated string”
↩︎ Topic files in .claude/rules/“Imports help you organize a long file but don’t reduce its context cost, because imported files also load at launch.”
↩︎ Exam trap 1“Keeping the import never makes Claude read AGENTS.md twice, whichever Project instructions value you use.”
↩︎ Exam trap 2“Imports help you organize a long file but don’t reduce its context cost, because imported files also load at launch.”
↩︎ Prediction“Move instructions that matter for only part of the codebase into path-scoped rules, which load only when Claude works with matching files.”
↩︎ Checkpoint“A CLAUDE.md that tells Claude in words to read AGENTS.md: Claude sees AGENTS.md only if it decides to open the file.”
↩︎ Checkpoint - 2.https://code.claude.com/docs/en/large-codebasesOfficial docs
“Root CLAUDE.md: instructions that apply everywhere, such as coding standards and commit conventions”
↩︎ Per-package CLAUDE.md files in a monorepo“Directory owners maintain their own conventions; instructions are versioned with the code”
↩︎ Per-package CLAUDE.md files in a monorepo“You want all conventions in one place, or the same rule applies to many scattered paths”
↩︎ Checkpoint - 3.https://code.claude.com/docs/en/claude-directoryOfficial docs
“Topic-scoped instructions, optionally path-gated”
↩︎ Topic files in .claude/rules/