Learn · Configuration & workflows · CCAR-F task 3.3
Path-specific rules
One .claude/rules file with a paths glob covers a file type across every folder, and loads only when Claude touches a matching file.
Key ideas
- Path-specific rules live in .claude/rules/*.md with a paths: glob in YAML frontmatter.
- A rule loads only when Claude works with files matching its glob, keeping context lean.
- One glob rule covers a file type wherever it lives, e.g. **/*.test.tsx across 40 folders.
- A subdirectory CLAUDE.md suits conventions for a single self-contained folder.
- Duplicating a convention into many CLAUDE.md files invites drift.
Worked example: Test conventions across the whole repo
Test files sit in 40 folders. One rule file scoped by a glob applies to all of them and stays out of context when Claude edits anything else.
Exam traps
- Creating a CLAUDE.md in every folder that has tests instead of one glob rule.
- Putting file-type conventions in the root CLAUDE.md, where they load in every session.
- Forgetting that rules are scoped by file paths, not by directory alone.
Official docs
Practise CCAR-F questions · Next lesson: Custom commands and skills