CLAUDE.md is a plain markdown file you place at the root of your project that gives Claude Code persistent instructions every time it starts a session. Think of it as an onboarding document for a new team member who reads it before every task. A good CLAUDE.md captures your build commands, your code style, your workflow rules, and crucially, the tools Claude should reach for first. A bad one is either empty, 600 lines long, or contradicts itself. This guide shows you exactly what to include, what to skip, and gives you a downloadable template with ToolRouter pre-wired so Claude automatically checks for existing tools before writing anything from scratch.
If you have not picked an MCP toolkit yet, read our best MCP tools for Claude guide first — the ToolRouter section of the template assumes you are using it. Want to skip straight to the template? Download the CLAUDE.md template — drop it into any project, fill in the bracketed fields, and you are done.
What Is CLAUDE.md?
CLAUDE.md is an official Claude Code feature. When you run Claude Code inside a project directory, it looks for a file named CLAUDE.md (case sensitive) and loads the entire contents into the conversation context before your first message. Anything you write in that file becomes part of every session, automatically, with no extra prompting required.
According to Anthropic's official memory documentation, CLAUDE.md content is delivered as a user message after the system prompt — which means Claude treats it as guidance, not enforced configuration. It is closer to a briefing than a contract, which is why specificity and pruning matter more than volume.
If you are new to Claude Code itself, start with the Claude MCP CLI walkthrough — it covers the underlying protocol that makes everything below work.
Why CLAUDE.md Matters in 2026
Anthropic's best-practices guide recommends treating CLAUDE.md like any frequently-used prompt: prune it regularly, review it when things go wrong, and keep it focused on the rules Claude would otherwise miss. In practice the file is the single highest-leverage thing you can write to make Claude reliable on your project — much higher than any individual prompt.
A few numbers worth knowing:
- Claude Code hit roughly $1 billion in annualised revenue within six months of launch, according to Uncover Alpha's reporting on Anthropic's numbers. The tool is already used on real production codebases every day.
- Claude Code crossed 2 million weekly active users in early 2026, per Anthropic's own milestone announcement. Growth in adoption means more shared CLAUDE.md patterns, templates, and community tooling showing up every week.
- Anthropic's own docs recommend keeping each CLAUDE.md file under 200 lines — longer files reduce adherence and consume more context window. The best CLAUDE.md files are short, specific, and pruned regularly.
If you use Claude Code without a CLAUDE.md, you are leaving most of its value unused. Every correction you give Claude in chat is a rule that belongs in the file.
Where CLAUDE.md Lives
Claude Code reads CLAUDE.md from several locations and concatenates them. Understanding the hierarchy is important because you can split instructions across scopes — personal preferences in your home directory, project rules in the repo, team secrets in a gitignored local file.
| Scope | Location | What it's for |
|---|---|---|
| Managed policy | /Library/Application Support/ClaudeCode/CLAUDE.md (macOS) or /etc/claude-code/CLAUDE.md (Linux) | Org-wide rules set by IT or security |
| Project | ./CLAUDE.md at the repo root (or ./.claude/CLAUDE.md) | Shared team rules, checked into git |
| User | ~/.claude/CLAUDE.md | Your personal preferences, applied to every project |
| Local project | ./CLAUDE.local.md | Personal notes for this project only — add to .gitignore |
All four concatenate. They do not override each other. If your home file says "always use 2-space indentation" and your project file says "this project uses tabs", Claude sees both rules and may pick either — so avoid contradictions.
Claude Code also picks up CLAUDE.md files from subdirectories as it reads files inside them. You can use this to scope rules — a CLAUDE.md in src/auth/ only loads when Claude is working in auth code.
The 12 Sections Every Good CLAUDE.md Has
These are the sections that appear again and again in the best public CLAUDE.md files (see the josix/awesome-claude-md curated list for real-world examples). You don't need all twelve — pick the ones that match your project and delete the rest.
- Project overview — one short paragraph describing what the project does and who uses it
- Tech stack — runtime, framework, database, package manager, module system
- Project structure — where handlers, components, tests, and configs live
- Build, run, and test commands — exact commands a teammate would type
- Available MCP servers — tools Claude has access to, with rules on when to use them
- Code style — naming, formatting, imports, in positive voice
- Architectural decisions — constraints like "ESM only" or "no default exports"
- Workflow rules — branches, commits, deploy flow, what never to do
- Environments and env vars — prod, staging, local URLs and gotchas
- Do not touch — files or directories Claude should leave alone
- Common mistakes to avoid — repeated corrections, captured in positive voice
- Testing strategy — how to run tests, where fixtures live, what to mock
The most overlooked section is number 5 — available MCP servers. Most CLAUDE.md files document the project's internal code but never tell Claude what external tools are already connected. That gap is where Claude ends up writing custom scraping code when there's a perfectly good scraping tool already installed.
Why Your CLAUDE.md Should Mention ToolRouter First
If Claude does not know what tools are already available to it, it will write from scratch. Every time. And the code it writes from scratch is usually worse than the purpose-built tool sitting one discover call away.
ToolRouter connects Claude to 165+ verified tools through a single MCP connection — web search, image generation, SEO audits, web scraping, data extraction, competitor research, video generation, deep research, and dozens more. Once ToolRouter is connected, you can write one rule in your CLAUDE.md that saves hours of agent-written custom code.
The rule sounds obvious when you read it:
Before writing any external integration from scratch, check ToolRouter first. Call thediscovertool with a plain-English description of what you need. If a matching tool exists, use it viause_tool. Only fall back to writing custom code if ToolRouter has no matching tool.
That single rule changes Claude's default behaviour from "install a new package" to "check for an existing tool first". The best MCP tools guide covers what's in the ToolRouter catalogue in detail.
Connecting ToolRouter
In Claude, go to Settings → Connectors → Add custom connector and enter:
- Name: ToolRouter
- URL:
https://api.toolrouter.com/mcp
Works in Claude chat, Claude Desktop, Claude Code, and Cowork. No download required. Once connected, every Claude session on that machine can discover and use ToolRouter tools automatically — and if your CLAUDE.md tells it to, it will.
You can also start a new account at /connect if you don't have one yet.
The 5 Best Practices That Make CLAUDE.md Actually Work
These are drawn from Anthropic's official memory docs, HumanLayer's "Writing a good CLAUDE.md", and the awesome-claude-md collection. They apply to every project regardless of language or framework.
1. Write in positive voice, not negations
Large language models process banned concepts the same way they process encouraged ones. "Don't use default exports" plants the idea of default exports in Claude's head. "Use named exports" does the opposite. Always phrase rules as what to do, not what to avoid.
2. Be specific, not descriptive
"Format code properly" is useless. "Use 2-space indentation" is actionable. "Run tests" is useless. "Run npm test before every commit" is actionable. Every rule should be verifiable — you should be able to look at the output and say yes-or-no whether Claude followed it.
3. Link, don't embed
Do not paste large code snippets, full API docs, or long lists into CLAUDE.md. Link to them instead. A CLAUDE.md that says "see src/lib/errors.ts for the shared error handler" is better than one that pastes 40 lines of error-handling code — the pasted version goes stale the moment the file changes.
4. Put the most-violated rules at the top or bottom
Practitioners have observed that Claude pays less attention to the middle of a long file than to the start or end. If you have a rule Claude keeps breaking, move it to the top. If it is still being broken, make it shorter and more specific.
5. Prune ruthlessly
Anthropic's rule of thumb: add a line to CLAUDE.md only if removing it would cause Claude to make a mistake. If a rule has never been violated, delete it. If a rule describes something Claude already does correctly by default, delete it. The best CLAUDE.md files grow slowly over time, not quickly at project start.



