Part of the guide: What is Claude Code? What it does, what it costs, and how to start

What is CLAUDE.md? The Claude Code instructions file, with examples

Written by Jeff Pascal · Updated · 6 minute read

In short

  • CLAUDE.md is a plain Markdown file of standing instructions. Claude Code loads it at the start of every session, so you stop repeating the same context.
  • Put the project file at ./CLAUDE.md (shared with your team) and your personal one at ~/.claude/CLAUDE.md (all your projects). Type /init to have Claude write a first draft.
  • Anthropic suggests under 200 lines per file. Claude treats it as context, not as a hard rule: to block an action every time, you need a hook.

CLAUDE.md is a Markdown file with standing instructions for Claude Code. Claude Code reads it at the start of every session, so the things you would otherwise explain again each time (how to run the tests, where files live, which rules to follow) are already in its context. You write it in plain text, and you can ask Claude to write the first version with /init.

Checked on 18 November 2026 against Anthropic's page on how Claude remembers your project. If you are new to Claude Code itself, start with what Claude Code is.

Why the file exists

Every Claude Code session starts with an empty context window. Claude does not remember yesterday's conversation unless something carries it over. Anthropic gives you two ways to carry knowledge between sessions:

CLAUDE.md Auto memory
Who writes it You Claude
What it holds Instructions and rules Things Claude learned from your corrections
Where it applies A project, you, or your whole organization One repository
When it loads Every session, in full Every session (the first 200 lines or 25KB)

Use CLAUDE.md for what you want Claude to do. Auto memory fills itself as you work; you can see and edit both with the /memory command.

Where the CLAUDE.md file goes

The location decides who the instructions apply to. Claude Code reads these, from the broadest to the most specific:

Scope Location Applies to
Organization macOS: /Library/Application Support/ClaudeCode/CLAUDE.md; Linux and WSL: /etc/claude-code/CLAUDE.md; Windows: C:\Program Files\ClaudeCode\CLAUDE.md Everyone on that machine (set by IT)
You ~/.claude/CLAUDE.md All your projects on this computer
Project ./CLAUDE.md or ./.claude/CLAUDE.md Everyone who works in the project (commit it)
You, in one project ./CLAUDE.local.md Only you; add it to .gitignore

Three loading rules worth knowing:

  • Claude Code loads the CLAUDE.md files in the folder you start it in and in every folder above it. They are joined, not replaced: the file closest to your starting folder is read last.
  • A CLAUDE.md in a subfolder loads later, when Claude reads or edits a file in that subfolder.
  • HTML comments (<!-- note -->) are removed before Claude sees the file, so you can leave notes for people without using context.

The Desktop app and the terminal read the same CLAUDE.md files, so one file covers both. The differences between the two are in Claude Code desktop vs CLI.

What to put in it

Anthropic's rule of thumb: write down what you would otherwise re-explain. Add a line when Claude makes the same mistake twice, when you type the same correction you typed last session, or when a new colleague would need the same context.

Good content:

  • the commands to build, test or run the project;
  • where things live ("API handlers are in src/api/handlers/");
  • conventions you check for ("2-space indentation", "dates as YYYY-MM-DD");
  • "always" and "never" rules ("run npm test before committing").

Make each instruction concrete enough to check. "Use 2-space indentation" works better than "format code properly".

What to leave out:

  • Long procedures. A multi-step routine you use now and then belongs in a skill. A skill's body loads only when it is used, while CLAUDE.md loads every time.
  • Rules for one part of the project. Put them in .claude/rules/ with a paths list, so they load only when Claude works on matching files.
  • Things Claude can read from the code anyway, such as a full file list.
  • Contradictions. If two lines disagree, Claude may pick either one.

How long should it be?

Aim for under 200 lines per file. The official page says longer files use more context and Claude follows them less consistently. You can split a long file with imports (below), but imported files still load in full, so imports organize the file without making it cheaper.

Two example files

A code project

# Bakery orders app

## Commands
- Install: `npm install`
- Run locally: `npm run dev` (port 3000)
- Tests: `npm test` (run before every commit)

## Layout
- API handlers: `src/api/handlers/`
- Database migrations: `db/migrations/`, one file per change

## Rules
- TypeScript strict mode; no `any`.
- Prices are stored in cents as integers.
- Never edit files in `db/migrations/` that are already merged.

See @README.md for the project overview.

A folder of business documents

CLAUDE.md is not only for code. A dental practice in Austin that keeps invoices, supplier price lists and patient letter templates in one folder could use:

# Practice admin folder

- Invoices are in `invoices/YYYY-MM/`. File names: `YYYY-MM-DD_supplier_amount.pdf`.
- Price lists are CSV files in `suppliers/`. Use a comma as separator.
- Letters to patients use the templates in `templates/`. Never put a patient's full name in a file name.
- Before you rename or move more than 10 files, show me the list and wait for my OK.
- Write in US English, dates as MM/DD/YYYY.

The line about patient names matters most here: it puts a privacy rule in every session, without you having to remember it.

How to create one

  1. Open a terminal in your project folder and start Claude Code with claude.
  2. Type /init. Claude reads the project and writes a CLAUDE.md with the commands and conventions it finds. If a CLAUDE.md already exists, /init suggests improvements instead of overwriting it.
  3. Open the file and cut what is obvious or wrong. Add the rules Claude could not discover by itself.
  4. Check that it loaded: type /context all and look under Memory files.
  5. To edit it later, type /memory, choose the file and it opens in your editor.

You can also tell Claude in the conversation: "add this to CLAUDE.md: we use pnpm, not npm". If you only say "remember that…", Claude saves it to auto memory instead.

Figuring out which rules belong in your first CLAUDE.md takes some trial and error. If you want to test ideas alongside others learning to amplify themselves with AI, you can join my free WhatsApp community, Team of One.

Imports: pulling in other files

A CLAUDE.md can include other files with @path, for example @README.md or @docs/git-instructions.md. Paths are relative to the CLAUDE.md file. Imported files can import others, up to four levels deep. A path inside backticks is not imported, so you can mention a file without loading it.

The first time a project file imports something outside the project folder, Claude Code asks you to approve it.

CLAUDE.md, AGENTS.md and other tools

Other coding agents, such as OpenAI Codex and Cursor, read a file called AGENTS.md. Claude Code handles both:

  • only AGENTS.md in the project: Claude reads it;
  • both files: Claude reads only CLAUDE.md;
  • a CLAUDE.md with the line @AGENTS.md: Claude reads both.

If your team uses several tools, keep the shared rules in AGENTS.md and import it from a short CLAUDE.md. How the tools compare is in Claude Code vs Cursor vs Codex.

If Claude ignores your CLAUDE.md

  1. Check that it loaded. /context all, then the Memory files list. A file that is not there is not seen.
  2. Check where you started Claude Code. A CLAUDE.md in a sibling folder does not load.
  3. Make the line specific. "Run npm test before committing" instead of "test your changes".
  4. Look for conflicts. Type /doctor prompt-audit: Claude reports outdated or contradicting instructions and proposes edits, and changes nothing until you ask.
  5. Use a hook for hard rules. CLAUDE.md is context. If an action must never happen, the official page points to a PreToolUse hook, which blocks it every time.

You can write the instructions in any language, and one line can set the language Claude answers in. See the Claude Code language setting.

Questions

Where do I put CLAUDE.md?

For a project, in the project's top folder as CLAUDE.md (or .claude/CLAUDE.md). For instructions that should apply in every project on your computer, in ~/.claude/CLAUDE.md. Claude Code also reads CLAUDE.md files in the folders above the one you start it in.

How long should a CLAUDE.md file be?

Anthropic's documentation says to aim for under 200 lines per file. Longer files take more of the context window and Claude follows them less consistently.

Does Claude always follow CLAUDE.md?

Not always. The official page says Claude treats CLAUDE.md as context, not enforced configuration. Specific, short, non-conflicting instructions are followed more reliably. To block an action no matter what, use a PreToolUse hook.

What is the difference between CLAUDE.md and AGENTS.md?

AGENTS.md is the instructions file other coding agents read. Claude Code reads an AGENTS.md when the folder has no CLAUDE.md. If both exist, it reads only CLAUDE.md, unless your CLAUDE.md imports AGENTS.md with @AGENTS.md.

Should I commit CLAUDE.md to Git?

Commit the project CLAUDE.md so your team gets the same instructions. Keep personal notes for one project in CLAUDE.local.md and add that file to .gitignore.

Sources

  1. code.claude.com: CLAUDE.md: locations and scope, load order, /init, @imports (four hops), target under 200 lines, context not enforced configuration, CLAUDE.local.md, .claude/rules/, AGENTS.md, /memory, /context all, auto memory (first 200 lines or 25KB), /doctor prompt-audit, checked 18 November 2026
  2. code.claude.com: skills: a skill body loads only when used; move a procedure out of CLAUDE.md into a skill, checked 18 November 2026
  3. code.claude.com: /init, /memory, /context and /doctor in the commands reference, checked 18 November 2026
  4. code.claude.com: the Desktop app and the CLI both read CLAUDE.md and CLAUDE.local.md, checked 18 November 2026
  5. claude.com: Using CLAUDE.md files: Customizing Claude Code for your codebase, checked 18 November 2026

Free WhatsApp community

Learning AI? Learn it on real work.

In “Team of one” I post what I actually tried on my own work. Most of it is in Romanian, but ask in English any time and we will work it out together.

Join the community