What a useful CLAUDE.md looks like, how to structure it, which rules work and which don't. The line between an agent that "helps you type" and one that knows your repo.
If your repo doesn't have a CLAUDE.md in 2026, you're losing hours every week. Not because AI
doesn't work: it does. But because every session you start from scratch explaining the same things.
This guide explains what a useful CLAUDE.md looks like, how to structure it, and what NOT to
include (because it saturates the context and tanks response quality).
It's a file at the project root (or per feature) that your agent reads automatically when it opens the repo. It holds the rules, conventions, and prohibitions you expect it to follow.
It's not a README. The README is for humans landing on the repo. CLAUDE.md is for the agent about to write code in the repo.
# [Project Name] — Development Guide
## Core Stack
- The bare minimum: framework, DB, auth, package manager
## Critical Rules (NON-NEGOTIABLE)
### 1. Directory Structure
### 2. Import Rules
### 3. Dependency Rules
### 4. Language & Code Style
### 5. No Comments Policy
### 6. No Business Logic in Page Components
## Project Structure
## Decision Tree: Where to Put New Code?
## Anti-Patterns (DO NOT DO THIS)Each section is 5-15 lines, not 5 paragraphs. The goal isn't to teach; it's to remind.
console.log, use @/lib/errors/logger". The agent can check.// Wrong
import { Button } from '@/shared/components/ui';
// Right
import { Button } from '@/shared/components/ui/button';On top of the root CLAUDE.md, add one per feature in sensitive modules:
src/features/auth/CLAUDE.md
src/features/payments/CLAUDE.md
src/features/blog/CLAUDE.mdEach with:
draft → published → archived)So when the agent touches src/features/blog/, it also reads local rules and doesn't have to guess.
1. Too long: if your CLAUDE.md is 800 lines, the agent processes it but loses priorities. Aim for 200-400 lines max at the root.
2. Contradictory rules: "always use X" in one place, "avoid X" in another. Happens when you edit at different times. Review the whole file when adding.
3. No "WHY" on weird rules: if you say "don't use Edge runtime", briefly explain: "Prisma doesn't support it." Without the reason, the agent may skip the rule when the situation looks different.
4. Confusing README with CLAUDE.md: README explains what the project is. CLAUDE.md explains
how to work inside it. Don't mix them.
CLAUDE.md is the difference between an agent that "helps you type" and an agent that "works in
your repo as if it had known it for months".
5 minutes a day writing it saves 30 minutes a day of repeated prompts. In a month that's hours. In six, a whole feature.
Subscribe for more tutorials and tips on building products with AI
The four pieces that turn a boilerplate into an operational copilot. What they are, when to use each, and how to fit them into your repo.
The end-to-end flow with Claude Code on an AI-native boilerplate. What the human does, what the agent does, and why the result is 5x faster.