Claude Certified Architect – Foundations Practice Question 64: Path Scoped Rules
Claude Certified Architect, Foundations · Test 7 · question 4 of 10
A monorepo's root CLAUDE.md has grown to 600 lines. About 150 of them are testing conventions that matter only when editing *.test.ts files, which are scattered across dozens of packages. Claude Code follows the file less reliably, and every session pays the context cost. How should the team restructure the instructions so the testing rules load only when relevant?
Show answer and explanation
Answer:
D is correct. A rule file in .claude/rules/ can declare paths glob patterns in YAML frontmatter; per the Claude Code memory docs, rules without a paths field load unconditionally, while path-scoped rules trigger when Claude reads, writes or edits a file matching the pattern. A single glob like **/*.test.ts covers every package, and the docs recommend moving instructions that matter for only part of the codebase into path-scoped rules.
A is wrong because a rules file with no paths field is loaded unconditionally, so it only reorganizes the text without saving context. B is wrong because imported files are expanded and loaded into context at launch, so an import does not reduce the context cost. C is wrong because nested CLAUDE.md files load when Claude reads files in their own directories, which means dozens of duplicated files to maintain, and it is keyed to location rather than to the file type.