Task statement 3.3 · Claude Code configuration and workflows
Apply path-specific rules for conditional convention loading
In the monorepo, tests sit beside their code in every package, while Terraform lives only under packages/infra/terraform/. Each set of conventions must reach Claude when it works on those files, and stay out of context otherwise.
share
The tempting fix is a CLAUDE.md in each directory, because that works for one folder. It loads only when Claude reads files in its own directory, so the test conventions get copied into every package and drift apart. The root CLAUDE.md avoids copies, but the conventions then cost tokens in every session, including the many that never use them. A skill avoids that cost, but it loads on demand, so nothing applies automatically.
KnowledgeHow a rule with paths loads
A rule is a Markdown file in .claude/rules/. Its optional YAML frontmatter can hold a paths field that lists glob patterns. A glob is a filename pattern in which * matches any characters within one folder name and ** matches any number of folders, so **/*.test.tsx matches every .test.tsx file at any depth. A rule without paths loads at launch, but a rule with paths waits until Claude reads a file whose path from the repository root matches a glob. A frontend-only session therefore never loads the Terraform conventions, which cuts irrelevant context and token usage.
- At launch, rules without
pathsload with CLAUDE.md. - Rules with
pathswait. - Claude reads
packages/api/src/orders.test.ts. - Claude Code checks that path against every glob.
- Each matching rule loads into context.
repo/ ├── .claude/rules/ testing.md · api-conventions.md · terraform.md · security.md ├── packages/web/src/ Button.tsx · Button.test.tsx ├── packages/api/src/ orders.ts · orders.test.ts └── packages/infra/terraform/ main.tf
Interactive · choose the file Claude reads
Choose the file Claude reads, and see which rules load with it.
Matches **/*.test.tsx, so the testing rule loads in packages/web. The API and Terraform rules stay out of context.
Matches **/*.test.ts and packages/api/**/*, so two rules load. The same testing rule now covers a second package.
Matches packages/api/**/* only. It is not a test file, so the testing rule does not load.
Matches packages/infra/terraform/**/*. Test and API conventions cost no tokens in this session.
packages/web/ and packages/api/, which a CLAUDE.md inside one package cannot do. security.md has no paths, so it always loads.More precise than the guide. The guide says a path-scoped rule loads when Claude is editing a matching file. The docs say it triggers when Claude reads one, which normally happens before an edit (checked 2026-10-01). Exam answer: the rule loads when Claude edits a matching file.
KnowledgeThree places a convention can live
Three mechanisms can hold a convention, and they differ in what makes them load. A subdirectory CLAUDE.md is tied to one directory, so it suits files that share a folder, like Terraform. A paths rule is tied to what the file is, so it suits one file type spread across the codebase, like tests. A skill loads when a developer invokes it or Claude judges it relevant, so it suits an on-demand task, not a standard that must always hold.
packages/infra/CLAUDE.md
Loadson reading a file in its directory
paths: ["**/*.test.tsx"]
Loadson reading a matching file, anywhere
/release-checklist
Loadswhen invoked or judged relevant
More precise than the guide. Skills now accept paths too: Claude then loads the skill automatically only when working with matching files (checked 2026-10-01). Skills are still meant for task-specific workflows. Exam answer: a .claude/rules/ rule with a paths glob, for conventions that must apply automatically by file type.
SkillMoving the test conventions into a rule
Claude writes packages/api/src/orders.test.ts with snapshot tests, which the team banned. The ban sits in packages/web/CLAUDE.md, which loads only when Claude reads files in packages/web/, and this session never did. The fix moves the conventions into one rule whose globs match tests in every package. The guide's paths: ["terraform/**/*"] works the same way, but it matches a root-level terraform/ folder, so here the glob names the full path.
# .claude/rules/testing.md --- paths: ["**/*.test.tsx", "**/*.test.ts"] --- - No snapshot tests. Assert on rendered text or role. # .claude/rules/terraform.md --- paths: ["packages/infra/terraform/**/*"] ---
| Files in one directory | A CLAUDE.md there, or a rule whose glob names it. |
| One file type, many directories | A rule whose paths glob matches the type. |
| Every file | The root CLAUDE.md, or a rule without paths. |
- Globs match from the repository root, so
**/*.test.tsxfinds tests in every package. - A subdirectory CLAUDE.md covers one folder and a skill waits to be needed.
- A
pathsrule costs no tokens until Claude reads a matching file.