CLAUDE.md: How to Make Your AI Actually Understand Your Project
Ever had your AI suggest code that just doesn't fit your project? Let's fix that. Here's how to write a CLAUDE.md that makes your AI coding assistant genuinely helpful.
Why This Little File Makes a Big Difference
Here's the thing about AI coding assistants: they're incredibly smart, but they're not mind readers. Drop an AI into a codebase without context and it'll make assumptions. Sometimes those assumptions are wrong.
CLAUDE.md is a simple Markdown file that lives in your project root. AI assistants read it automatically. Think of it like onboarding a new team member—except this team member can read really, really fast.
Real talk: A good CLAUDE.md can cut your "no, not like that" corrections by 50-70%. That's not hype—it's just what happens when you give context upfront instead of fixing things afterward.

The Four Sections Every CLAUDE.md Needs
You don't need to write a novel. These four sections cover 90% of what your AI needs to know:
1. Project Overview
What does this thing do? Two sentences max. This sets the mental model for everything else.
## Project Overview
TaskFlow is a project management app for remote teams.
Built with Next.js 15 and PostgreSQL. Focus on real-time
collaboration and Slack integration.2. Commands
What commands does your project use? List them all. The AI will actually use these instead of guessing.
## Commands
```bash
npm run dev # Start dev server (localhost:3000)
npm run build # Production build
npm run test # Run all tests
npm run test:watch # Tests in watch mode
npm run db:migrate # Run Prisma migrations
```3. Architecture
Where does stuff go? This is huge for the AI knowing where to put new files.
## Architecture
### Directory Structure
- `src/app/` - Next.js App Router pages
- `src/components/` - React components
- `src/lib/` - Utilities (no React)
- `src/hooks/` - Custom React hooks
- `src/db/` - Prisma schema and queries
### Key Patterns
- Server Components by default
- Client Components only when needed
- Zustand for client state4. Coding Standards
The "do this, don't do that" section. Be specific—vague rules get vague results.
## Coding Standards
### Do
- Use TypeScript strict mode
- Write tests for new features
- Keep functions under 50 lines
- Use descriptive variable names
### Don't
- Use `any` type (use `unknown` instead)
- Skip error handling
- Use inline styles (use Tailwind)
- Commit console.logsLevel Up: Advanced Tricks
Show, Don't Just Tell
One good code example beats ten rules. Show what "good" looks like in your project:
### Component Pattern
```tsx
// How we do server/client splits here:
export default async function UserList() {
const users = await db.user.findMany()
return <UserListClient users={users} />
}
// UserListClient.tsx - 'use client' at top
```Point to Key Files
Help the AI find the important stuff quickly:
### Key Files
| File | Purpose |
|------|---------|
| `src/db/schema.prisma` | Database schema |
| `src/lib/auth.ts` | Authentication logic |
| `src/types/index.ts` | Shared type definitions |Explain Your Domain
The AI doesn't know your business logic. Spell it out:
### Business Logic
- **Workspace**: A team's shared space
- **Project**: A collection of tasks
- **Task**: A unit of work
- Tasks can only be assigned to Workspace members
- Free tier: max 5 members per Workspace
Mistakes That'll Trip You Up
Being Too Vague
"Write clean code" means nothing. "Functions under 50 lines, no nested callbacks deeper than 3 levels" means something.
Writing Too Much
If your CLAUDE.md is 1000 lines, the important stuff gets buried. Aim for under 500 lines. Use bullet points and tables.
Letting It Go Stale
Outdated docs cause more problems than no docs. When you change a pattern, update CLAUDE.md. Seriously.
Skipping Business Context
The AI has no idea what a "workspace" or "subscription tier" means in your app. Explain the concepts.
Start Here (Quick Wins)
Don't have time for everything? These four things give you the biggest bang for your buck:
- 1Add your test command
The AI will run tests after changes if it knows how. Game changer.
- 2List your "don't do" rules
Things you always have to correct? Write them down. Once.
- 3Show one good component example
The AI learns from examples. One good one is worth a lot.
- 4Document your folder structure
So new files end up where they belong. Every time.