6 min read

CLAUDE.md Template: Copy the 6-Section File

This CLAUDE.md template comes from Anthropic's docs and the production files I studied for my CLAUDE.md video: six short sections, under 80 lines, nothing Claude Code could work out for itself. Below is the template, where the file goes, and the research behind keeping it short.

A good CLAUDE.md template has six short sections: commands Claude cannot guess, code standards that differ from defaults, a brief architecture map, your workflow, common mistakes and explicit don'ts. Keep it under 80 lines and move anything task-specific into skills.

The video above walks through it live. Here is the written version.

Anthropic's documentation page on CLAUDE.md files, the reference behind this CLAUDE.md template
Anthropic's memory documentation is the source for every path and rule below.

What CLAUDE.md is and why it matters

CLAUDE.md is a plain markdown file that Claude Code reads at the start of every session. It is where you put the instructions you would otherwise repeat in every conversation: how to run the project, the rules you care about, the mistakes you are tired of correcting.

Two things make it more important than it looks:

  • It loads every session. Every line rides along with every request, so one bad instruction affects the whole session, not one answer.
  • It is advice, not enforcement. Anthropic's docs say Claude treats it as context, not configuration. If something must never happen, use a hook instead, which can block an action outright.

The research: why shorter beats longer

Two studies from early 2026 changed how I write these files.

Researchers at ETH Zurich tested context files across real coding tasks with Claude Code, Codex and Qwen Code. Files generated automatically lowered the success rate slightly and raised cost by more than 20%. Files written by developers helped, but only by about 4% on average. The agents followed every instruction, so extra instructions meant extra steps.

SkillsBench tested skills instead of context files. Carefully written skills raised pass rates by 16.2 percentage points on average. Skills the model wrote for itself added nothing.

The lesson from both: what you put in the context matters more than how much. Write it by hand, keep it to what Claude cannot discover, and put task procedures in skills that load only when needed.

Where CLAUDE.md files go

Claude Code reads several CLAUDE.md files and combines them. From Anthropic's memory documentation:

  1. 1

    Managed policy

    set by IT for a whole organisation

  2. 2

    User

    ~/.claude/CLAUDE.md, your rules for every project

  3. 3

    Project

    ./CLAUDE.md, shared with the team through git

  4. 4

    Local

    ./CLAUDE.local.md, your private notes, gitignored

  5. 5

    Subdirectory

    loads only when Claude works in that folder

Where CLAUDE.md files live, broadest scope first

All of them are added to the context together, with the files closest to where you started Claude read last. If two instructions contradict each other, Claude may pick either one, so review the files now and then and delete anything that conflicts.

Keep the user file to 10 or 15 lines. It loads into every project you open.

The 6-section CLAUDE.md template

Copy this into CLAUDE.md at the root of your project and replace every line with your own:

markdown
# Project name

## Commands
- `pnpm dev` starts the app on port 3000
- `pnpm test:unit` runs unit tests only (the full suite takes 9 minutes)
- `pnpm db:reset` wipes and reseeds the local database

## Code standards
- TypeScript strict mode. Never use `any`; use `unknown` and narrow it
- Server components by default; add "use client" only for interactivity

## Architecture
- `app/` routes, `components/` shared UI, `lib/` data and helpers
- Full system design: @docs/architecture.md

## Workflow
- Branch from main, one feature per branch
- Run type check and lint before every commit

## Common mistakes
- The payments webhook needs the raw body; do not parse it as JSON

## Don'ts
- Never edit generated files in `src/gen/`
- Never commit `.env` or anything with a key in it

What each section is for:

  1. Commands: only the ones Claude cannot guess. It already knows npm install. It does not know your custom test script or which command is slow.
  2. Code standards: only rules that differ from the normal way of doing things. Claude already knows common conventions; restating them wastes space.
  3. Architecture: three to five lines, enough to orient. Use @path/to/file to point at a longer document instead of pasting it in.
  4. Workflow: how work moves through your project: branches, checks, commits.
  5. Common mistakes: the section that pays off most over time. Every time Claude repeats an error, add one line here.
  6. Don'ts: explicit negatives with strong words. "Never" works better than "try to avoid".

That comes to 30 to 50 lines for most projects.

What to leave out

Most bloated files I see carry the same dead weight:

Leave outWhyPut it here instead
A long project overviewClaude finds the right files just as fast without itNowhere, or one line
Step-by-step proceduresThey load every session even when unusedA Claude skill
Rules for one folder onlyThey pollute every other taskA subdirectory CLAUDE.md or .claude/rules/
Things that must never happenCLAUDE.md is advice, not a lockA PreToolUse hook
Style rules Claude already followsEvery line competes for attentionDelete it

Anthropic's own guidance is to stay under 200 lines per file. I aim for under 80.

A CLAUDE.md template for business work

Not every Claude Code folder holds software. If you use it to run content, leads or proposals, the same rules apply with different sections:

markdown
# My business workspace

## Read first
- business/offer.md, business/voice.md, business/ideal-customer.md

## Rules
- Prices come only from business/offer.md
- If a fact is missing, write [CONFIRM: ...] instead of guessing

## Where things go
- Drafts in outputs/<type>/ with today's date in the file name

## Never
- Send, post or publish anything. Drafts only

This is the shape of the workspace in my Claude Code tutorial for non-developers.

Keep it improving

Treat the file as something you maintain, not something you write once:

  1. 1

    Notice a repeat mistake

    the same correction twice

  2. 2

    Add one line

    under Common mistakes or Don'ts

  3. 3

    Prune monthly

    delete lines Claude no longer needs

  4. 4

    Move procedures out

    anything with steps becomes a skill

The file gets better every week instead of longer

The CLAUDE.md maintenance loop

Run /context in a session to confirm which memory files actually loaded.

CLAUDE.md template: FAQ

Should I use /init to create my CLAUDE.md?

Use /init as a starting point, then cut it down hard. It generates a file from what it finds in your project, and the ETH Zurich results suggest auto-generated files hurt more than they help unless you edit them into something short and specific.

How long should a CLAUDE.md file be?

A CLAUDE.md file works best at 30 to 80 lines. Anthropic recommends staying under 200 lines per file, because longer files use more context and Claude follows them less consistently.

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

CLAUDE.md is Claude Code's instruction file and AGENTS.md is the shared format other coding agents read. Claude Code can read an AGENTS.md in place of CLAUDE.md, so one well-written file can serve several tools.

Does CLAUDE.md work in the Claude desktop app?

CLAUDE.md works anywhere you run Claude Code, including the Code tab in the Claude desktop app, because it is a file in the project folder Claude Code opens.

Get a workspace with this already done

The AI Operator Kit is a Claude Code workspace built on these rules: a short instruction file, business facts in their own files, and 18 skills that load only when you need them.

More on claude

View all