5 CLAUDE.md Patterns That Actually Work
Update, October 2026: this post describes an earlier Brewcode version, and some of the features and commands it presents are retired. See the current docs.
Your CLAUDE.md file is the single most important configuration in a Claude Code project. It is loaded at the start of every session and directly shapes how the model interprets your codebase, writes code, and makes decisions.
Most developers either leave it empty or dump unstructured notes into it. These five patterns produce consistently better results.
1. Import Syntax
Reference other files directly instead of duplicating content. Claude Code resolves @path/to/file imports and injects their content into context.
See @README.md and @docs/architecture.md
Review @.claude/rules/testing.md
This keeps your CLAUDE.md concise while giving Claude access to detailed documentation. Update the source file once and every session picks up the change.
2. Conditional Rules
Use explicit if/else patterns to scope instructions by context. Claude interprets these as conditional logic.
If editing files in `src/api/`:
- Use Express router patterns
- All handlers must return typed responses
- Include error middleware
If editing files in `src/ui/`:
- Use React functional components
- Prefer composition over inheritance
This prevents frontend rules from leaking into backend code and vice versa.
3. Convention Tables
Pipe-delimited tables are compact and scannable. Use them for naming conventions, file patterns, and decision rules.
| Pattern | Rule |
|---------|------|
| `*.test.ts` | Jest, GIVEN/WHEN/THEN comments |
| `*.api.ts` | Express handler, typed req/res |
| `*.hook.ts` | React hook, `use` prefix required |
Tables consume fewer tokens than prose and are easier for Claude to parse consistently.
4. Scoped Instructions
Place a CLAUDE.md in subdirectories to add context-specific rules. Claude loads the nearest CLAUDE.md relative to the file being edited.
project/
CLAUDE.md # global rules
src/
api/
CLAUDE.md # API-specific: auth patterns, error handling
ui/
CLAUDE.md # UI-specific: component patterns, styling
Keep global rules global and specific rules local. This scales better than one massive file.
5. Memory Anchors
Tell Claude explicitly when to save information for future sessions. Without anchors, learned context is lost after compaction.
When you discover a project convention not listed here,
save it to `.claude/memory/MEMORY.md` with the format:
## [Category]
- [Convention]: [Description]
Memory anchors turn one-time discoveries into persistent knowledge. Combined with Auto Handoff, this creates a growing project memory that improves every session.
These five patterns are not theoretical. They are extracted from production projects using Brewcode daily. Start with convention tables and import syntax — they have the highest impact-to-effort ratio.