Builds on step 1. You have outgrown CLAUDE.md when it passes 200 lines or when most of it only matters for one area of the code.
Read time1 min
SectionClaude Code Setup Playbook
01 — 5 · rule files
What to do
Why: rule files load only when relevant, so the always-on briefing stays short.
Do this:
Create .claude/rules/ with one file per topic, grouped in folders (backend/, ui/, testing/).
Use paths: frontmatter so a rule loads only when Claude works on matching files.
In every rule, show a BAD example, a GOOD example and one line on why.
Add a one-line "load when" note for each rule to CLAUDE.md, or let paths: handle it.
02 — 5 · rule files
Example
Example..claude/rules/backend/error-handling.md:
markdown
---
paths: ["api/**/*.ts"]
---
Throw `AppError` from handlers. Raw `Error` can leak stack traces to the client.
```ts
// BAD
throw new Error("Invoice not found");
// GOOD
throw new AppError("Invoice not found", 404);
```
03 — 5 · rule files
Check it works
Check: ask Claude to add a handler in api/. It should use AppError without being told. Then touch a file outside api/ and confirm the rule doesn't load. /memory shows what is loaded.
Watch out:
Frontmatter that fails to parse is ignored, and the rule then loads everywhere. Keep the file's first line as --- and add a CI check for it.
Stale rules are worse than missing ones, because the agent trusts them. Delete rules that no longer match the code.
If a rule keeps getting broken, turn it into a lint rule (step 4).
Keep one place per policy. Link to it instead of restating it.