How to Write a Good CLAUDE.md File: A Beginner's Guide (2026)
A CLAUDE.md file is a short set of plain-English instructions Claude Code reads at the start of every session — so it already knows your project, your rules, and your gotchas before it touches a single file. Here's exactly what to put in one, what to leave out, and a copy-paste starter you can use today.
A CLAUDE.md file is a short, plain-English document that Claude Code reads automatically at the start of every session. It's where you tell the AI what your project is, how to run and test it, the rules it must follow, and the mistakes to avoid — so it starts each conversation already knowing your setup instead of guessing. Think of it as the onboarding note you'd hand a new teammate on day one. This guide shows you exactly what to write, what to leave out, and gives you a starter file you can copy today.
What is a CLAUDE.md file, and why does it matter?
CLAUDE.md is a Markdown file you keep in your project folder. Every time you open Claude Code in that folder, it reads the file before doing anything else. That means your instructions are always "in the room" — you don't have to re-explain your project, paste the same rules, or remind it which command runs your tests every single time.
Without one, Claude Code is smart but blind to your specifics. It might try npm test when your project uses something else, or rewrite a file you never wanted touched. With a good CLAUDE.md, it acts like someone who already read the onboarding doc: fewer wrong turns, fewer wasted rounds, and results that match how you actually work.
What will you learn in this guide?
- What a CLAUDE.md file is and where it lives on your computer
- The fastest way to create one (a single command)
- The five things worth including — and how to phrase them
- The four things you should NOT put in it (a common beginner mistake)
- A copy-paste starter file you can adapt in minutes
- How to keep it short and healthy as your project grows
Where does the CLAUDE.md file go?
In most cases it sits in the top folder of your project, right next to your code, named exactly CLAUDE.md. Claude Code looks for it there automatically. You can also keep a personal one that applies to every project — but if you're just starting, a single file in your project folder is all you need.
- Project file —
CLAUDE.mdin your project's main folder. Shared with anyone who works on that project. This is the one to start with. - Personal file — a global CLAUDE.md that applies across all your projects, for your own preferences. Optional, and best added later.
- Folder files — extra CLAUDE.md files inside sub-folders, for rules that only apply to one part of a big project. Advanced; skip it at first.
What's the fastest way to create a CLAUDE.md file?
You don't have to write it from scratch. Run the /init command inside your project and Claude Code looks at your files, works out your tech stack, and drafts a starter CLAUDE.md for you. Then you read it, fix anything wrong, and trim what you don't need. Starting from /init and editing is far easier than facing a blank page.
/init, actually read the file it made. It's a draft, not gospel — the AI guessed some things. Correct the wrong lines and delete the filler before you rely on it.What are the five things worth putting in a CLAUDE.md?
You don't need many sections — you need the right ones. These five cover almost everything a beginner benefits from. The rule for each: include it only if Claude couldn't reliably guess it on its own.
- Project summary — one or two lines on what this project is. Example: "A small website for a local bakery, built with Next.js." It orients the AI more than you'd expect.
- How to run, test, and build it — the exact commands. Claude Code can't know whether you use one tool or another; tell it, and you save it from guessing wrong and burning several turns.
- Key conventions and structure — a quick map: where the important folders are, which patterns you follow, anything unusual about how the project is organized.
- Rules and boundaries — what it must NOT do without asking. For example: don't delete files, don't change the database, always show a plan before a big change.
- Gotchas — the project-specific traps. "The config file looks unused but it's loaded at build time" is the kind of note that prevents a painful mistake.
What should you NOT put in a CLAUDE.md file?
This is where most people go wrong: they treat CLAUDE.md as a dumping ground and it balloons to hundreds of lines. A bloated file is actually worse than a short one, because the important rules get lost in the noise. Leave these out:
- Anything a formatter or linter already enforces. Don't spend lines telling the AI to add semicolons or use two-space indentation — your tools do that automatically. Never send an AI to do a linter's job.
- Things Claude can just read from the code. If the answer is obvious from the files themselves, you don't need to repeat it. Recent Claude Code versions even flag CLAUDE.md content it could have figured out on its own.
- Long pasted documents. Instead of pasting a whole style guide, point to it: "See docs/style.md." A short pointer beats a giant wall of text.
- Secrets, passwords, or API keys. The file is often shared with your whole team and checked into version control. Sensitive values never belong here.
/doctor checkup that can suggest trimming a CLAUDE.md by cutting anything the AI could already derive from your codebase. If your file has grown long, it's a quick way to spot the dead weight.How long should a CLAUDE.md file be?
Shorter than you'd think. A high-signal CLAUDE.md is usually well under 150 lines, and many good ones are closer to 80–120. The goal isn't to cover everything — it's to cover the things the AI can't guess and would otherwise get wrong. If a line wouldn't make a human reviewer raise an eyebrow when it's broken, it probably doesn't need to be there.
There's also a simple test for where a rule belongs. If breaking it would block your project from building or shipping, enforce it with an automatic tool, not a sentence in CLAUDE.md. If breaking it would just make a teammate frown, that's exactly the kind of thing CLAUDE.md is for.
A copy-paste starter CLAUDE.md you can adapt
Here's a clean, minimal starter. Copy it into a file named CLAUDE.md in your project folder, then swap in your own details. Keep only the lines that are true for you — delete the rest rather than padding it out.
# ProjectA small marketing website for a local bakery. Built with Next.js.# Commands- Run locally: npm run dev- Run tests: npm test- Build for production: npm run build# Structure- Pages live in src/app- Shared components live in src/components- Do NOT edit anything in src/generated (it's auto-created)# Rules- Show a plan before any large change, and wait for my OK- Never delete files or run data-changing commands without asking- Match the style of the surrounding code# Gotchas- The config in next.config.ts looks unused but is read at build time
How do you keep a CLAUDE.md healthy over time?
A CLAUDE.md isn't set-and-forget, but it also shouldn't grow endlessly. The trick is to edit it when reality changes — not to keep piling on. Two simple habits keep it in good shape:
- Update it when a rule changes. If you switch a command or add a new folder Claude should avoid, fix the line. An out-of-date instruction is worse than no instruction.
- Trim it when it gets long. Every few weeks, skim the file and cut anything the AI is clearly getting right on its own. Shorter files get followed more reliably.
Newer Claude Code versions also remember useful things they learn as they work, so you don't have to write down every small detail yourself. That's one more reason to keep CLAUDE.md focused on the non-obvious rules that really matter, and let the tool handle the rest.
Want to learn Claude Code the hands-on way?
Inside the club there's a full Claude Code course — step-by-step video lessons with me, plus a support group so you're never stuck. We start from the very basics, including setting up your first CLAUDE.md, and build up to agents and automations.
Frequently asked questions
What is a CLAUDE.md file?
A CLAUDE.md file is a short Markdown document in your project folder that Claude Code reads automatically at the start of every session. It tells the AI what your project is, how to run and test it, the rules it must follow, and the gotchas to avoid — so it starts each conversation already knowing your setup instead of guessing.
How do I create a CLAUDE.md file?
The fastest way is to run the /init command inside your project. Claude Code inspects your files, detects your tech stack, and drafts a starter CLAUDE.md for you. Then read it, correct anything wrong, and delete the filler. Editing a generated draft is far easier than writing one from a blank page.
Where does the CLAUDE.md file go?
In the top folder of your project, named exactly CLAUDE.md, right next to your code. Claude Code finds it there automatically. You can also keep a personal global file that applies to every project, but if you're starting out, a single file in your project folder is all you need.
What should I not put in a CLAUDE.md file?
Leave out anything a formatter or linter already enforces, anything Claude can just read from the code, long pasted documents (link to them instead), and any secrets, passwords, or API keys. The file is often shared with your team, so sensitive values never belong in it.
How long should a CLAUDE.md file be?
Shorter than most people expect — usually well under 150 lines, and often 80 to 120. Include only the things the AI can't reliably guess and would otherwise get wrong. A bloated file is worse than a short one, because the important rules get buried in the noise.
Do I need to know how to code to write a CLAUDE.md file?
No. A CLAUDE.md file is plain English (in Markdown), and the /init command drafts most of it for you. You mainly need to know a few basics about your project — what it is, which commands run it, and what the AI should not touch — and write those down in simple sentences.
Still have questions?
Stuck on a step, or want to send a screenshot and have someone take a look? That's exactly what the community is for — real people, quick answers, and no question too basic.
Try your first two weeks for $1No commitment · cancel anytime
