Write CLAUDE.md files that maximize Claude's adherence and performance.
Long CLAUDE.md = Claude ignores half of it. Critical rules get lost in noise.
For each line ask: "Would removing this cause Claude to make mistakes?"
| Section | Example |
|---|---|
| --------- | --------- |
| Project context | "Next.js e-commerce app with Stripe" (1 line) |
| Build/test commands | npm run test, pnpm build |
| Critical gotchas | "Never modify auth.ts directly" |
| Non-obvious conventions | "Use vi for state, not useState" |
| Domain terminology | "PO = Purchase Order, not Product Owner" |
feature/, fix/)# Project Name
One-line description.
## Commands
- Test: `npm test`
- Build: `npm run build`
- Lint: `npm run lint`
## Code Style
- [Only non-obvious conventions]
## Architecture
- [Brief, only if complex]
## IMPORTANT
- [Critical warnings - use sparingly]
| Location | Scope |
|---|---|
| ---------- | ------- |
~/.claude/CLAUDE.md | All sessions (user prefs) |
./CLAUDE.md | Project root (share via git) |
./subdir/CLAUDE.md | Loaded when working in subdir |
.claude/rules/*.md | Auto-loaded as project memory |
Before finalizing:
/init as starting point, then prune aggressively| Don't | Why |
|---|---|
| ------- | ----- |
| 200+ line CLAUDE.md | Gets ignored |
| "Write clean code" | Claude knows this |
| Duplicate rules across files | Wastes tokens, conflicts |
| Theoretical concerns | Only add for real problems |
| Long prose explanations | Use bullet points |
# MyApp
React Native app with Expo. Backend is Supabase.
## Commands
- `pnpm test` - run tests
- `pnpm ios` - run iOS simulator
## Style
- Prefer Zustand over Context
- Use `clsx` for conditional classes
## IMPORTANT
- NEVER commit .env files
- Auth logic lives in src/lib/auth.ts only
~15 lines. Covers what Claude can't infer. Nothing more.
共 1 个版本