# Path-specific rules in .claude/rules

*Claude Certified Architect - Foundations Study Guide · Claude Code Configuration & Workflows · Last updated October 22, 2026 · https://www.certifyforce.com/study-guide/claude-certified-architect-foundations/claude-code-configuration-and-workflows/path-specific-rules-in-claude-rules*

How a paths glob in a .claude/rules/ file makes conventions load only when Claude reads, writes or edits a matching file, how the patterns resolve, what silently breaks scoping, and when a path-scoped rule beats a subdirectory CLAUDE.md. Also covers compaction, symlinked rules and logging loads with the InstructionsLoaded hook.

- Certification: Claude Certified Architect - Foundations
- Exam section: Claude Code Configuration & Workflows
- Study guide: https://www.certifyforce.com/study-guide/claude-certified-architect-foundations

**Official exam objective:**

> Apply path-specific rules for conditional convention loading

## What the exam expects

- Create a `.claude/rules/` file with YAML `paths` frontmatter (for example `paths: ["terraform/**/*"]`) so its conventions load only when Claude works with matching files.
- Write glob patterns that match files by type in any directory, such as `**/*.test.tsx`, and spot patterns that match too little.
- Choose a path-scoped rule over a subdirectory CLAUDE.md when conventions apply to files spread across the codebase, and the reverse when one team owns one directory.
- Diagnose rules that load everywhere or never, including after compaction and through symlinks.

Key terms: **path-scoped rule** (a rule file whose `paths` frontmatter limits when it loads); **glob** (a pattern such as `src/**/*.ts`, where `**` spans any depth); **base directory** (the folder a rule's patterns are relative to); **unconditional rule** (a rule without `paths`, loaded at launch); **lazy load** (loading triggered by a file access during the session).

## Key facts

| Fact | Detail | Source |
|---|---|---|
| Frontmatter key | `paths` only; other keys ignored without error | [How Claude remembers your project](https://code.claude.com/docs/en/memory) |
| `paths` formats | YAML list or comma-separated string | [How Claude remembers your project](https://code.claude.com/docs/en/memory) |
| Load trigger | Read, Write or Edit of a matching file, or a single-file Bash read | [How Claude remembers your project](https://code.claude.com/docs/en/memory) |
| Rule without `paths` | Loads at launch, every session | [How Claude remembers your project](https://code.claude.com/docs/en/memory) |
| Unparseable frontmatter | Rule loads unconditionally; `claude --debug` shows the error | [How Claude remembers your project](https://code.claude.com/docs/en/memory) |
| Project rule base directory | The directory containing the rule's `.claude` folder | [How Claude remembers your project](https://code.claude.com/docs/en/memory) |
| `*.md` | Root-level Markdown files only | [How Claude remembers your project](https://code.claude.com/docs/en/memory) |
| Expansion budget | 1,000 expanded patterns per rule's `paths` list | [How Claude remembers your project](https://code.claude.com/docs/en/memory) |
| After `/compact` | Scoped rules reload on demand, not re-injected | [Explore the context window](https://code.claude.com/docs/en/context-window) |
| External symlinked rules | After approval, only rules without `paths` load | [How Claude remembers your project](https://code.claude.com/docs/en/memory) |
| `InstructionsLoaded` | Logs loads with `load_reason`, `globs`, `trigger_file_path`; no blocking | [Hooks reference](https://code.claude.com/docs/en/hooks) |

## Check yourself

- Why does a rule with `globs:` frontmatter load in every session?
- When does a rule with `paths: ["db/migrations/**/*.sql"]` enter context?
- Why choose a path-scoped rule over subdirectory CLAUDE.md files for test conventions?
- What happens to a loaded scoped rule after `/compact`?
- Which hook logs each rule load with the glob and trigger file?

## Sources

- [How Claude remembers your project](https://code.claude.com/docs/en/memory)
- [Set up Claude Code in a monorepo or large codebase](https://code.claude.com/docs/en/large-codebases)
- [Explore the .claude directory](https://code.claude.com/docs/en/claude-directory)
- [Explore the context window](https://code.claude.com/docs/en/context-window)
- [Hooks reference](https://code.claude.com/docs/en/hooks)
- [Extend Claude with skills](https://code.claude.com/docs/en/skills)
- [Claude Certified Architect – Foundations Exam Guide v1.0](https://everpath-course-content.s3-accelerate.amazonaws.com/instructor%2F6nizmqk8tpzpfjvt6qmmav7rh%2Fpublic%2F1783542750%2FClaude+Certified+Architect+%E2%80%93+Foundations+Exam+Guide.pdf)

## About the full unit

The "Core concepts", "Exam traps" and "Worked scenario" sections of this unit, its 9 linked practice questions, and unlimited timed mock exams are included with the Claude Certified Architect - Foundations pack (USD $19): https://www.certifyforce.com/practice-exams
