Skip to content

Path-scoped rules

.claude/rules/ splits project instructions into topic files that can load conditionally. A rule without paths: frontmatter loads at session start like CLAUDE.md; a rule with paths: loads only when Claude reads a matching file — saving context.

.claude/rules/testing.md
---
paths:
- "**/*.test.ts"
- "**/*.test.tsx"
---
# Testing Rules
- Use descriptive test names: "should [expected] when [condition]"
- Mock external dependencies, not internal modules
- Clean up side effects in afterEach

Subdirectories are discovered automatically (.claude/rules/frontend/react.md works). Like CLAUDE.md, rules are guidance — for guaranteed behavior use hooks or permissions.

Question 1When does a rule with paths: frontmatter load?