Rules — Conditional context
🌐 日本語
NOTE
Rules are markdown files loaded only when a glob pattern matches the files in the current turn. They keep CLAUDE.md small by deferring domain-specific guidance until it's relevant.
How it works
- Each rule declares a
globs:frontmatter (e.g."**/*.test.ts"). - The rule body is injected into context only when the LLM touches a matching file.
- Multiple rules can match — they accumulate, so design for additivity.
Related chapters
Structural problems it addresses
- Context Rot — don't pay for context you don't need.
- Priority Saturation — narrow scope keeps signal high.
- Instruction Decay — re-injected each time a matching file appears.
See also
- Topic: CLAUDE.md — for always-loaded context.
- Topic: Skills & Agents — for context loaded by the LLM's decision rather than by file match.
- Feature Index