Your First CLAUDE.md in 20 Minutes: The Minimal File That Actually Helps
8 November 2026 · Updated 28 November 2026 · 11 min read · by Yang Kai
Skip the 200-line template. Write a minimal CLAUDE.md in 20 minutes that stops Claude Code guessing — then grow it only when you catch a repeat mistake.
15-line starter CLAUDE.md
Contents
- What you need before you start
- What CLAUDE.md actually does
- Step 1 (minutes 0–5): answer three questions on paper
- Step 2 (minutes 5–15): write the starter file
- Stack
- Commands
- Boundaries
- Definition of done
- Step 3 (minutes 15–20): run one real task
- After the first week: growing the file without bloating it
- The mistakes every beginner makes
- How you will know it is working
Every Claude Code session starts from zero. The agent has no memory of yesterday’s session, your build command, or the folder it must never touch — so it guesses, and the guesses cost you the first ten minutes of every session. A CLAUDE.md file ends that, but the common first move, pasting in a 200-line template copied from someone else’s project, buries the five lines that matter under rules for a stack you do not run.
This guide writes the other version: a minimal file of about 15 lines, built from one real task in your own project, in 20 minutes. It covers the three questions the file must answer, the exact starter text, how to test it, and how the file should grow afterwards. The facts about how Claude Code loads and uses these files are taken from Anthropic’s official documentation, checked November 2026.
The quick version: create CLAUDE.md in your project root. Put in what the project is, the exact build and test commands, two or three hard boundaries, and your definition of done. Run one real task. Add one line per repeated mistake, and nothing else.
What you need before you start
- A project Claude Code can open — any repo, at any stage.
- Claude Code installed and able to run in that project.
- One small, real task ready to test with (a typo fix, a small field addition, a rename). You will use it in the last five minutes.
- 20 minutes and a timer, if a timer helps you resist polishing.
No template downloads, no other tools. If the project is brand new and has no build command yet, that is fine — the file will be shorter, and it grows with the project.
What CLAUDE.md actually does
Claude Code begins each session with a fresh context window. A CLAUDE.md file is how instructions survive that reset: it is a plain markdown file that Claude reads at the start of every session, before your first prompt. Think of it as the sticky note you would leave for whoever picks up the project next — except the reader is an agent, and the note is loaded automatically.
The file you write today is the project-level one, but it helps to know it sits in a hierarchy. Per Anthropic’s documentation, the locations are, from broadest to most specific:
| Scope | Location | What belongs there |
|---|---|---|
| Managed policy | Set by your organisation’s IT (for example /etc/claude-code/CLAUDE.md on Linux) |
Company-wide standards you cannot override |
| User | ~/.claude/CLAUDE.md |
Your personal preferences, applied to every project |
| Project | ./CLAUDE.md or ./.claude/CLAUDE.md |
The file in this guide: shared with the team through version control |
| Local | ./CLAUDE.local.md |
Personal notes for one project; add it to .gitignore |
Files from every level are combined, with the more specific ones read later. Files in subdirectories load on demand, when Claude works in that directory. You only need the project file today; the user file becomes useful once you notice preferences you repeat across projects.
Two facts from the docs shape everything below:
- Shorter follows better. Anthropic’s guidance is to target under 200 lines per file, because longer files consume more context and reduce how consistently instructions are followed. A 15-line starter is not a compromise; it is the correct shape.
- It is context, not a lock. CLAUDE.md content is delivered as guidance Claude tries to follow, not as enforced configuration. Specific, checkable instructions are followed far more reliably than vague ones — “Use 2-space indentation” lands; “format code properly” does not. (When a rule must be enforced without exception, that is a job for hooks, not this file.)
A short file beats a long one for a second reason, too: every line is weighed against every other line on every request. Fifteen lines that are all true and checkable outperform two hundred lines where the important rules are buried under generic advice. The Context Budget Audit covers that trade-off in depth; the short version is that context is a budget and your CLAUDE.md spends it first.
Step 1 (minutes 0–5): answer three questions on paper
Before you open an editor, answer these in plain sentences, on paper or in a scratch note:
First, how do you build and check this project? Not how the framework usually builds — how this repo builds. If the command is npm run build, write that. If there is a separate type check or test command, write that too. Agents guess commands constantly, and a guessed command wastes more time than almost any other mistake.
Second, what should the agent never touch without asking? For most projects this is environment files, migrations, lockfiles, or a folder of published content. You already know what makes you nervous. Write that down.
Third, what does done mean? A workable default: build passes, no new type errors, and a short summary of what changed. Yours might include running the tests, or checking the page in a browser. Pick the version you would accept from a junior colleague.
That is the whole research phase. If you cannot answer one of these yet, leave it out — a missing line is better than a vague one.
Step 2 (minutes 5–15): write the starter file
Create a file called CLAUDE.md in the root of your project and paste this in, replacing the bracketed parts with your answers:
# Project: [Name] — [one line: what it is and who it serves]
## Stack
- [Framework + language, e.g. Astro 5, TypeScript strict]
- Package manager: [npm/pnpm/yarn — pick the one this repo uses]
## Commands
- Dev: [e.g. npm run dev]
- Build: [e.g. npm run build]
- Test/check: [e.g. npm run check, or delete this line]
## Boundaries
- Never edit .env files or the lockfile by hand.
- Ask before changing: [your sensitive folder or config]
## Definition of done
- Build passes. Summarise what changed and what you did not test.
Count it: that is the fifteen-line starter. It looks almost too small, and that is the point. It covers the three questions and nothing else. There is no style guide in it, no architecture tour, no list of every folder. The agent can read the folders itself. What it cannot read is your intent — and intent is exactly what those fifteen lines carry.
Two details matter more than they look:
- Name the package manager explicitly. Monorepos and older projects routinely trip agents into using the wrong one, and the resulting lockfile churn is miserable to undo.
- Keep the boundaries section even if it feels obvious. It is not obvious to a fresh session. Obvious-to-you is precisely the category of thing this file exists for.
Note: Claude Code can draft this file for you — running /init in a project generates a starter CLAUDE.md from a scan of the codebase. Treat that output as a draft to cut down to the three questions above, not as a finished file: a generated file knows your stack, but it does not know your boundaries or your definition of done.
Step 3 (minutes 15–20): run one real task
Do not write another line until you have run a real task with this file in place. Pick something small and genuine — fix a typo in the UI copy, add a field to a form, rename a component. First, confirm the file actually loaded: run /context all in the session and check that your CLAUDE.md appears under Memory files (the /memory command opens the file for editing if you need to change anything).
Then watch what the agent does. You are looking for guesses:
- Did it run the right build command without being told?
- Did it stay out of the folder you marked?
- Did it stop at done, or did it keep polishing past the brief?
Every correct behaviour is the file working. Every guess is a candidate for exactly one new line. Resist fixing guesses with paragraphs — one guess, one line, in the same blunt style as the rest of the file. “Internal links use trailing slashes” is a line. A paragraph explaining your linking philosophy is context spend with no extra compliance.
After the first week: growing the file without bloating it
The growth rule comes straight from Anthropic’s documentation: add to CLAUDE.md when Claude makes the same mistake a second time, when a code review catches something it should have known, or when you catch yourself typing the same correction you typed last session. Three mechanisms keep growth from turning into bloat:
- Imports. A CLAUDE.md can pull in other files with
@path/to/filesyntax — for example,@READMEloads your README alongside it. Relative paths resolve against the file containing the import, and imports can nest up to four hops deep. Use imports to organise; note that they do not reduce context cost, because imported files load in full alongside the file that imports them. - CLAUDE.local.md. Personal preferences for one project — your sandbox URL, your preferred test data — belong in this sibling file, which loads alongside CLAUDE.md and stays out of version control once gitignored.
- Moving things out. A multi-step procedure does not belong in CLAUDE.md at all; it belongs in a skill. Rules that only apply to one part of the codebase belong in path-scoped rule files under
.claude/rules/. The main file stays the short, always-true core.
When the file does outgrow the starter shape, The CLAUDE.md That Actually Works is the fuller structure to graduate to, section by section. Teams sharing one file across several people have extra concerns — ownership, review, conflicting styles — covered in CLAUDE.md for Teams.
The mistakes every beginner makes
Writing for a human reader. Humans enjoy context and narrative; agents need checkable instructions. If a line cannot be verified — “write elegant code” — it will be nodded at and ignored. Rewrite it until a stranger could check whether it happened.
Copying a famous template wholesale. Templates encode someone else’s stack, someone else’s boundaries, someone else’s definition of done. Half the rules will be irrelevant, and irrelevant rules train the agent that rules in this file are decorative.
Front-loading rules for problems you have not had yet. You do not need a section on database migrations if your project has no database. Add rules in response to real friction, not in anticipation of imagined friction. The file should read like a log of lessons, because that is what a good one becomes.
Never deleting anything. Rules expire. A workaround for a bug fixed in March is still shaping behaviour in November if it stays in the file. Review it whenever you catch yourself repeating an instruction for the third time, and cut as aggressively as you add. If you also work with other coding tools, AGENTS.md vs CLAUDE.md explains what to share between the two files and what to keep separate — and the AGENTS.md field guide covers the shared format itself.
How you will know it is working
Within a week, two changes show up. Sessions start faster, because you stop re-typing the same setup in your first message. And the agent’s mistakes get more interesting — it stops failing on logistics (wrong command, wrong folder) and starts failing, when it fails, on the actual problem. That shift is the signal the file has done its first job.
At that point, graduate deliberately. Read The CLAUDE.md That Actually Works and adopt the fuller structure section by section, only where your project has earned the complexity.
Twenty minutes, fifteen lines, one real task. That is a better CLAUDE.md than most projects ever get — because it is yours, it is true, and every line in it has a reason to exist.
FAQ
What is CLAUDE.md? The instruction file Claude Code reads automatically at the start of every session in a project. It is where the facts you would otherwise retype into every prompt live permanently: stack, commands, conventions, and hard rules.
Why not start with a big template? Because a 200-line starter contains mostly rules for a project that is not yours, and the agent cannot tell the vital five from the decorative rest. Anthropic’s own guidance targets under 200 lines per file; a minimal file you fully understand beats a comprehensive one you never read.
Where should my CLAUDE.md live?
In the project root (./CLAUDE.md, or ./.claude/CLAUDE.md) for project rules. Personal preferences that apply everywhere go in ~/.claude/CLAUDE.md; personal notes for one project go in CLAUDE.local.md, gitignored. Files from all levels are combined each session.
What is the first rule most people should add? The verification rule: how the agent proves work is done — build command, test command, and “show me the result.” It prevents the most common early disappointment, the confident “done” that was never run.
Does CLAUDE.md guarantee Claude follows my rules? No. Per Anthropic’s documentation, the file is delivered as context Claude tries to follow, not enforced configuration, so vague or conflicting instructions may be missed. Write specific, checkable lines, and use hooks for anything that must happen without exception.
When should the file grow? When the agent makes the same mistake twice. The first occurrence is bad luck; the second is a missing rule, and that is the moment it earns its line.
Category: Claude Code & Context Engineering · Tags: #claude-code #claude-md #tutorial #ai-coding
Next step: this article is part of Claude Code guides, which covers the full topic from first setup to advanced use.