
CLAUDE.md: The Most Important File in Your AI Project
Without CLAUDE.md, Claude Code is like a junior without onboarding. How to write this file so AI understands your architectural decisions from the very first prompt.

Vít Šafařík
AI & business productivity
You launch Claude Code on a new project. You write a prompt. The AI generates code — functional, but wrong. Different naming conventions, components in the wrong folder, inline styles instead of Tailwind. You spend 20 minutes fixing what the AI could have done right from the start.
This problem has nothing to do with Claude Code’s quality. It has everything to do with the fact that you didn’t give the AI context.
CLAUDE.md solves this problem. It’s a configuration file that Claude Code reads first — before it processes your first prompt. Everything you write there becomes the “project law” for the AI.
Why You Can’t Afford to Ignore CLAUDE.md
Claude Code is an agentic tool. It doesn’t wait for step-by-step instructions — it autonomously reads the codebase, makes decisions, and executes changes. Without context, this autonomous approach fills in gaps with assumptions.
And assumptions in a production project are expensive.
Practical impact: developers who use CLAUDE.md properly report 60–70% fewer iterations when generating code. A working feature in 30 minutes instead of 90 minutes of back-and-forth fixes. Numbers from real projects, not a marketing slogan.
CLAUDE.md isn’t documentation for humans. It’s onboarding for AI. Write it accordingly.
Anatomy of a Functional CLAUDE.md
A good file covers four areas. Each serves a different purpose.
1. Stack and Technical Dependencies
## Tech Stack
- Next.js 15 App Router (NOT Pages Router)
- TypeScript strict mode, no `any`
- Tailwind CSS v4 — no inline styles, no CSS modules
- Prisma ORM, PostgreSQL
- React Query for server state, Zustand for client stateThis isn’t a readme. It’s a list of rules. Claude Code actively applies these rules — if you write “NOT Pages Router,” the AI will use App Router without asking. If it’s not there, it could be 50/50.
2. Architectural Conventions
## Project Structure
- Components: `/components/[feature]/[ComponentName].tsx`
- Server actions: `/app/actions/[feature].ts`
- Utility functions: `/lib/[domain].ts`
- Types: always in `/types/` or inline in component, NOT a global `types.ts`
## Naming Conventions
- Components: PascalCase
- Hooks: camelCase with `use` prefix
- Server actions: camelCase verb + noun (createUser, updatePost)Without this section, the AI will invent its own structure. Sometimes it’ll match your convention, sometimes not. In a monorepo, this can be catastrophic.
3. What Not to Do
This is the most underestimated part of CLAUDE.md. Explicit prohibitions work better than implicit rules.
## Forbidden
- NEVER use `console.log` in production code — use logger from `/lib/logger.ts` instead
- NEVER add new npm packages without a comment explaining why
- NEVER modify files in `/config/` without my confirmation
- DO NOT simplify error handling — every error must be explicitly handledThis list comes from what hurts you most in the project. Update it continuously.
4. Project Context and Business Rules
## About the Project
E-commerce platform for B2B customers. Users are procurement managers
in companies, not tech-savvy consumers.
## Critical Business Rules
- Prices are always displayed without VAT (B2B standard)
- Minimum order: 5,000 CZK
- Product availability is loaded real-time from ERP (never from cache)With this context, Claude Code writes fundamentally different code than without it. It will automatically validate minimum order values, it will be cautious about caching where it would be wrong, and it will suggest UI appropriate for a B2B context.
CLAUDE.md for Different Project Types
Next.js + Tailwind (Most Common Stack 2025/2026)
Key things that must be included:
- Explicitly App Router or Pages Router
- Rules for Server vs Client Components (
'use client'only where necessary) - How to work with environment variables
- How to handle loading and error states
Monorepo (Turborepo, Nx)
Place CLAUDE.md both in root and in each package separately. The root file covers global conventions, package-level files specify each application’s specifics. Claude Code reads both and applies them correctly.
Design System / Component Library
Focus on:
- How props are named (size vs variant vs appearance?)
- What belongs in atomic vs molecular components
- How types are exported
Keeping CLAUDE.md Alive
The biggest mistake: you write CLAUDE.md once and forget about it.
The right workflow is different. Every time you fix code generated by Claude Code, ask yourself: “Why did the AI get this wrong?” If the answer is “because it didn’t know” — add it to CLAUDE.md.
After a month of actively using Claude Code, you’ll have a CLAUDE.md that covers 90% of edge cases specific to your project. The AI will then generate code that barely needs review.
Specific trigger for updates: whenever you fix the same thing twice, it must go into CLAUDE.md.
Advanced: CLAUDE.md for Teams
If multiple people use Claude Code on the same project, CLAUDE.md becomes a shared convention. You version it in git like any other file.
Add a workflow section:
## Git Workflow
- Branches: `feature/`, `fix/`, `chore/` prefix
- Commit messages: Conventional Commits (feat, fix, docs, refactor)
- PR: always include testing checklist
- Claude Code MUST NOT commit directly to mainClaude Code actively respects these rules — it won’t make direct commits to main for you, and it will suggest correct commit messages.
Template to Get Started
I don’t want to give you a copy-paste template, because CLAUDE.md must match your project, not a generic example. But here’s a minimal structure to start from:
# [Project Name]
## What This Project Does
[One sentence]
## Tech Stack
[List of technologies with explicit versions]
## Architecture
[Folder structure, naming conventions]
## Forbidden
[What the AI must not do]
## How to Run the Project
[Development, build, test commands]This minimum will prevent 70% of problems. Add the rest iteratively.
Investment vs. Return
Writing a good CLAUDE.md takes 2–3 hours on a project you don’t know. On a project you work on daily, maybe 45 minutes.
The return: every developer who uses Claude Code on that project saves iterations from day one. For a team of three, it pays for itself within a week.
If you’re using Claude Code and don’t have a CLAUDE.md, or have an empty one — that’s low-hanging fruit that costs less than one afternoon session.
If you’re unsure how to structure CLAUDE.md for your specific project, or want to understand where you’re losing time in your AI workflow, reach out — I’m happy to take a look at your setup.
For a deeper audit of how you’ve integrated AI into your development process, check out the AI audit. We’ll review not just CLAUDE.md, but your entire workflow from prompts to deployment.
Share this article
Found this article helpful? Share it with colleagues who might benefit.