CLAUDE.md File: Best Practices, Examples and 3 Templates
What a CLAUDE.md file is, where each one goes, what to put in and leave out, three templates to copy, and what to do when Claude reads the file but still breaks a rule.
By Yotam DahanUpdated 16 min readClaude Code
A CLAUDE.md file is a plain-text Markdown file that Claude Code reads at the start of every session, so you can write down your rules, context and preferences once instead of repeating them in every conversation. Put it in a project's main folder for that project's rules, or in ~/.claude/CLAUDE.md for rules that apply to everything you do. Claude treats it as guidance rather than hard settings, so short, specific instructions work best.
Markdown is simply text with a few symbols for structure: # starts a heading and - starts a bullet. There is no required CLAUDE.md file format beyond that; headings and short bullets just make your rules easier for Claude to follow. Everything below follows Anthropic's memory docs, checked November 22, 2026.
CLAUDE.md and Claude Code memory
Every Claude Code session starts with a fresh memory. Two things carry knowledge from one session to the next: CLAUDE.md files that you write, and auto memory notes that Claude writes for itself.
| CLAUDE.md | Auto memory | |
|---|---|---|
| Who writes it | You | Claude |
| What it holds | Rules, context and preferences | Notes on your corrections and preferences |
| When it loads | Every session, in full | Every session, up to the first 200 lines or 25KB of its index |
| Best for | Anything you would otherwise repeat | Small learnings Claude picks up as you work |
When you say "remember that I invoice in euros", Claude saves it to auto memory, and notes such as "Saved 2 memories" show when that happens. To put a rule in CLAUDE.md instead, say "add this to CLAUDE.md".
Does Claude read CLAUDE.md every time?
Yes, automatically, at the start of every conversation, including the fresh one you get after /clear. Claude Code passes it to Claude as a message right after its own built-in instructions, so Claude reads it and tries to follow it, but nothing forces it to. To block something no matter what, use a permission rule, covered further down.
CLAUDE.md file location: where each file goes
~ means your home folder (%USERPROFILE% on Windows), and ./ means the main folder of your project.
| Scope | Location | Use it for | Who it applies to |
|---|---|---|---|
| Personal, every project (the global CLAUDE.md) | ~/.claude/CLAUDE.md | Your language, tone and way of working | Only you |
| Project | ./CLAUDE.md or ./.claude/CLAUDE.md | The project's rules and context | Anyone who has the folder; commit it to share it |
| Personal, one project | ./CLAUDE.local.md | Private notes for this project; add it to .gitignore | Only you |
| Organization | /Library/Application Support/ClaudeCode/CLAUDE.md (Mac), /etc/claude-code/CLAUDE.md (Linux), C:\Program Files\ClaudeCode\CLAUDE.md (Windows) | Company-wide rules set by IT | Everyone on that machine |
On a Mac, the global file is /Users/yourname/.claude/CLAUDE.md; Finder hides folders that start with a dot, so press Cmd+Shift+. to see them. Here is what a small business project looks like on disk, with the business owner template from further down saved as its CLAUDE.md:

Claude Code loads the CLAUDE.md in the folder you start it in and in every folder above it, and the files add up rather than replace each other. A CLAUDE.md inside a subfolder loads only once Claude starts working with files in that subfolder.
Organization
Company rules from IT, if your company sets any
Your personal file
~/.claude/CLAUDE.md
Parent folders
Any CLAUDE.md in the folders above your project
This project
./CLAUDE.md first, then CLAUDE.local.md last
Because the most specific file is read last, a project rule sits closest to the work. Still, avoid contradicting your personal file, because when two rules conflict Claude may follow either one.
How to create a CLAUDE.md file
- Open your project folder in Claude Code. In the terminal, move into the folder and run
claude; in the desktop app, use the Code tab and Select folder. - Run
/init. Claude looks through the folder and writes a starter CLAUDE.md. If one already exists, it suggests improvements instead of overwriting it, and it carries over rules you wrote for Cursor or GitHub Copilot. - Or let Claude interview you. For a folder with little in it yet, the prompt below gets better results than
/init. - Edit it.
/memorylists your CLAUDE.md files and opens one in your editor, or you can simply say "add this rule to CLAUDE.md". - Reload it. The file is read at session start, so run
/clearor start a new session after editing; Anthropic's prompt caching page explains why mid-session edits wait. - Check that it loaded. Run
/context alland look for the file under Memory files.
On November 6, 2026 we ran /init twice on fresh copies of the small landing page project from our vibe coding guide, a yoga studio site made of one HTML file and one stylesheet, with Claude Opus 5.5 in Claude Code 2.1.303, and kept the logs. Each run took under a minute (32 and 41 seconds) and wrote a 33-line file.
Both found what a new helper would otherwise trip over: all five booking buttons share one placeholder link, the hero photo is cropped to hide a mirror the copy says is not there, and testimonials and the address must not be invented. The second run also caught a real bug we had missed: the page uses a split-reverse style that the stylesheet never defines.

I want a CLAUDE.md for this folder. Ask me up to 8 questions, one at a time, about my business, who the work is for, my tone of voice, the rules I always want followed and what "done" means for me. Then write a CLAUDE.md under 60 lines with clear headings, and show it to me before you save it.Does a CLAUDE.md file actually change what Claude writes?
Yes, for the rules Claude would not guess, and not at all for the rest.
We gave Claude Code (Claude Opus 5.5) the same job 30 times: turn a bakery's weekly orders and price list into a sales summary, then write an Instagram post for one seasonal product. Five made-up bakeries, in Maple Falls (US), Guadalajara, Valencia, Belo Horizonte and Lyon, each ran three times with its CLAUDE.md of 4 to 6 rules and three times with the file deleted. Our own script then checked every file.
| What we checked | Without CLAUDE.md | With CLAUDE.md |
|---|---|---|
| Every item amount and the week total right | 15 of 15 runs | 15 of 15 runs |
| No long dash anywhere in the file | 1 of 15 runs | 15 of 15 runs |
| Mexican amounts marked MXN, as the rule asks | 0 of 30 amounts | 30 of 30 |
| Brazilian amounts written R$ 1.234,50 | 20 of 30 | 30 of 30 |
| Spanish and French amounts in the local format | 60 of 60 | 60 of 60 |
The arithmetic was right every time either way: CLAUDE.md does not make Claude more accurate, it makes it follow your house style. The rules that changed the result were the ones Claude did not infer on its own, such as "no long dashes" or "add MXN after pesos". The rule that changed nothing, the local number format in Spain and France, is exactly the kind of line to delete during a review.
CLAUDE.md best practices: what to put in and what to leave out
Treat CLAUDE.md as the place for things you would otherwise re-explain. A good trigger for a new line is Claude making the same mistake twice, or you typing the same correction you typed last week.
| Put in | Leave out |
|---|---|
| Who you are and who the work is for | Passwords, API keys and account numbers |
| Your tone of voice and the words you never use | Long background documents |
| How the folder is organized and how files are named | Details that change every week |
| Rules that always apply, such as "drafts only, never send" | Vague wishes like "write well" |
| What "done" looks like for your work | Step-by-step procedures you only need sometimes |
| Mistakes Claude has made before | Anything Claude can see by opening the files |
Be concrete
"Use US English and paragraphs of three sentences or fewer" works, while "write nicely" doesn't.
Stay short
Anthropic recommends under 200 lines per file, since longer files use more context and get followed less reliably.
Use headings
Group rules under headings and bullets instead of long paragraphs.
Avoid conflicts
If two rules contradict each other, Claude may pick either one, so prune old rules regularly.
Emphasize sparingly
Mark one critical rule with IMPORTANT. If every line is important, none of them stands out.
How long should a CLAUDE.md file be?
Under 200 lines, and for most business folders well under 100. Claude Code warns you at startup, and in /status, when a file is over the recommended length or when all your instruction files together get too big, and it skips any single file over 4 MiB. Every line loads into every session, so a lean file also stretches your plan further, as the guide to Claude Code usage limits explains.
Pull other files in with @ imports
If your rules already live in another file, import it instead of copying it. A line such as @brand/voice.md loads that file at startup, and the path is read from the folder the CLAUDE.md sits in. Imported files can import others, up to four levels deep.
- Spaces in a path need a backslash before each one:
@Brand\ Kit/voice.md. - To mention a path without importing it, wrap it in backticks.
- Files outside the project, such as
@~/.claude/my-rules.md, trigger a one-time approval dialog in that project.
CLAUDE.md imports keep things organized but don't make the file any lighter, because imported files load at startup too.
Three CLAUDE.md templates you can copy
These CLAUDE.md examples are written for people who don't code. Each is 21 to 25 lines, about an eighth of Anthropic's 200-line ceiling, so there is room for your own rules. Replace everything in square brackets, delete what doesn't apply, and trim again after a week of real use.
Template 1: business owner
Save this as ~/.claude/CLAUDE.md to apply it everywhere, or as CLAUDE.md in the folder you use for admin work.
# About me and my business
- I run [BUSINESS NAME], a [TYPE OF BUSINESS] in [CITY OR MARKET].
- Customers are [WHO THEY ARE]. Main products or services: [LIST].
- I'm not a developer. Explain anything technical in one plain sentence.
# How to work with me
- Ask me questions before starting anything that takes more than a few steps.
- Show me a short plan before changing more than 3 files.
- Reply in [LANGUAGE], in short paragraphs, without jargon.
# Rules that always apply
- Never send emails, messages or payments. Prepare drafts for me to send.
- Never delete files. Move anything you want removed into a folder called _trash.
- Never invent numbers, prices or facts. If something is missing, ask me.
- Currency is [CURRENCY]. Dates are written [DATE FORMAT].
# Files and folders
- Incoming documents are in /inbox. Finished work goes in /output.
- Name files like YYYY-MM-DD_topic.
# When you finish a task
- List what you changed, what you couldn't do and anything you were unsure about.
# When compacting
- Keep the list of files changed and any open questions.The last section follows a tip from Anthropic's best practices page: a "when compacting" instruction tells Claude what to keep when it summarizes a long conversation.
Template 2: marketer
Save this as CLAUDE.md in your marketing folder. For full marketing workflows that use it, see Claude Code for marketers.
# Brand
- Brand: [BRAND NAME]. We sell [OFFER] to [AUDIENCE].
- Voice: [THREE ADJECTIVES]. We sound like [EXAMPLE], never like [ANTI-EXAMPLE].
- Words we never use: [LIST].
- Spelling: [US OR UK] English.
# Facts and claims
- Use only the facts in /brand/facts.md and in the files I give you.
- Every statistic needs a source link. If you can't find one, leave the number out.
- Don't name competitors unless I ask.
# Channels and formats
- LinkedIn: under [NUMBER] words, one idea per post.
- Email: subject line under [NUMBER] characters, one call to action.
- Instagram captions: the hook goes in the first line, under [NUMBER] words in total.
# Files
- Briefs are in /briefs. Drafts go in /drafts, one file per piece, named channel_topic_date.
# Before you say you're done
- Check every claim against the source files and list anything unsupported.Template 3: website project
Save this as CLAUDE.md in the main folder of the site.
# Project
- Website for [BUSINESS NAME]: [WHAT THE SITE IS FOR].
- The one action we want from visitors: [FOR EXAMPLE, BOOK A CALL].
- Built with [STACK, FOR EXAMPLE PLAIN HTML AND CSS]. Hosted on [HOST].
# Commands
- Preview locally: [COMMAND]
- Check before publishing: [COMMAND]
# Design rules
- Colors: [HEX CODES]. Fonts: [FONTS]. Keep plenty of white space.
- Mobile first: check every change at phone width before saying it's done.
- Every image needs alt text. Buttons say what happens next ("Book a call", not "Submit").
# Content rules
- Use only the copy in /content and facts I confirm. No invented reviews, numbers or logos.
- Every page needs its own title and meta description.
# Don't
- Don't add new libraries, plugins or services without asking me.
- Don't change domain, DNS or hosting settings.
# Done means
- The check command passes, the page works at phone width, and you list what you changed.Should you copy the Karpathy CLAUDE.md?
The file people call "Karpathy's CLAUDE.md" is a community file built from Andrej Karpathy's posts about the mistakes AI coding tools make; he didn't publish it himself. It is short and built around four ideas: think before coding, simplicity first, surgical changes and goal-driven execution.
If you write code, it is a sound base to paste above your own project rules. If you don't, two of its ideas carry over: ask when something is unclear instead of guessing, and agree how success will be checked before starting. Templates 1 and 3 already cover both in plain language, with "ask me questions before starting" and the "Done means" section.
When CLAUDE.md isn't enough
Permission rules
For things that must never happen, such as reading .env files, add a deny rule in your settings. Claude Code enforces it whatever the instructions say.
Skills
For step-by-step procedures you only need sometimes. A skill loads only when it's used, so it doesn't weigh down every session.
Hooks
For actions that must run at a fixed moment, such as a check after every file edit. They run as commands, not suggestions.
Rules folder
For instructions that only matter for some files, saved in .claude/rules/ and loaded when Claude works on matching files.
The guide on how to create a Claude skill shows how to turn a procedure into a skill. For deny rules, Anthropic's permissions guide has the syntax, and our Claude Code cheat sheet includes a starter settings file.
CLAUDE.md vs AGENTS.md
AGENTS.md is the same idea for other coding tools, such as OpenAI's Codex. Since version 2.1.277, Claude Code reads an AGENTS.md on its own, but only when there is no CLAUDE.md or CLAUDE.local.md in your folder or above it.
To keep one set of rules for every tool, put @AGENTS.md on the first line of your CLAUDE.md and add Claude-only rules below it. To have Claude read both files without an import, open /config and set Project instructions to claude-md-and-agents-md.
CLAUDE.md not working? Fixes for common problems
| What you notice | Why | Fix |
|---|---|---|
/context all doesn't list your file under Memory files | It is in a folder Claude Code doesn't read, or misnamed | Move it to the project's main folder or ~/.claude, named exactly CLAUDE.md |
Instruction file not loaded (a Read deny rule covers it) | A deny rule in your settings blocks that file | Narrow or remove the Read deny rule that matches its path |
| You edited the file and nothing changed | It was read when the session started | Run /clear, or /compact if you are mid-task |
A CLAUDE.md length warning at startup or in /status | One file, or all of them together, is too long | Trim below 200 lines and move procedures into skills |
| Claude ignores your AGENTS.md | A CLAUDE.md or CLAUDE.local.md on the path takes priority | Import it with @AGENTS.md, or change Project instructions in /config |
A rule vanished after /compact | It was only said in chat, or lives in a subfolder file | Move it into the project's main CLAUDE.md, which Claude re-reads after compacting |
| Claude reads it but still breaks a rule | The rule is vague, or another file contradicts it | Rewrite it as something checkable and delete the conflicting line |
If a rule must hold every single time, move it into a permission rule or a hook instead of making it louder.
Quick check0 of 3 correct
Where do you put rules that should apply to every project on your computer?
Not quite.
The CLAUDE.md inside the .claude folder in your home folder loads in every session, in every project.
You changed CLAUDE.md halfway through a session. When does Claude see the change?
Not quite.
The file is read when the session starts, so edits load the next time that context is rebuilt.
What is the surest way to stop Claude from reading your .env file?
Not quite.
CLAUDE.md is guidance. A permission rule is enforced by Claude Code no matter what the instructions say.
What to do next
Open your most-used project folder, run /init or the interview prompt, and keep the result under 60 lines for the first week. Every time you correct Claude, ask whether that correction belongs in the file, and remove anything Claude already does on its own. Then follow the Claude Code tutorial for beginners to see CLAUDE.md working inside a real project, or start with the free first lesson of our Claude Code course (early access, open for pre-order), which sets up a business folder and its first CLAUDE.md. That lesson uses the nesting described above on purpose: one business-level file holds your prices, tone and rules, and every later project folder in the course, from the landing page to the invoice agent, inherits it, so the file you maintain here is the one the whole course builds on.
Two more CLAUDE.md templates and a monthly review
Ready-to-fill CLAUDE.md templates for content creators and freelancers, plus a 10-point monthly review that keeps the file short and sharp.
Enter your email and the full section opens right here.
Frequently asked questions
How is CLAUDE.md different from Project instructions in the Claude app?
Project instructions live inside a Project in the Claude app and apply only to chats in that Project. CLAUDE.md is a file on your computer that Claude Code reads from your folders, so you can edit it in any text editor, keep it next to the files it describes and use the same rules in the terminal, VS Code or the desktop app.
Does the file have to be named CLAUDE.md exactly?
Yes. Save it as CLAUDE.md with the .md ending. A file saved as claude md without the dot, or as a .txt file, will not be loaded.
Does CLAUDE.md work in the desktop app and VS Code too?
Yes. The terminal, the desktop app's Code tab and the VS Code extension all run the same Claude Code engine, so the same CLAUDE.md files load in each of them.
Where is the global CLAUDE.md file on Windows?
It lives at %USERPROFILE%\.claude\CLAUDE.md, which is usually C:\Users\YourName\.claude\CLAUDE.md. If it doesn't exist yet, run /memory in Claude Code and pick the user file, and it is created for you.
Can Claude Code update CLAUDE.md by itself?
Only when you ask, for example with "add this rule to CLAUDE.md", or when you accept the trims that /doctor proposes. Separately, it writes its own auto memory notes without being asked, and you can browse and edit those through /memory.
Can I keep notes in CLAUDE.md that Claude won't read?
Yes. Block-level HTML comments, such as <!-- note for the team -->, are stripped before the file reaches Claude, so they cost nothing in context. Comments inside code blocks are kept.
Keep reading
Claude Code Tutorial: How to Use Claude Code in 9 Steps
Learn how to use Claude Code step by step on a real project: build a one-page business site with plan mode, permissions and rewind, plus 10 beginner tips.
Claude Code · 16 min readHow to Create a Claude Skill: 6 Steps + SKILL.md Example
How to create a Claude skill: write SKILL.md, test it (we ran 51 trigger tests), upload it to the Claude app or let Claude write it, and fix what breaks.
Claude Code · 17 min readClaude Code Commands Cheat Sheet (2026): Shortcuts and Flags
Claude Code commands cheat sheet: 60+ slash and CLI commands, 20+ shortcuts, config files and fixes, plus a free printable one-pager. Checked November 2026.
Claude Code · 19 min read