CLAUDEMD(5)CLAUDEMD(5)

NAME

CLAUDE.md — instruction file for Claude Code

SYNOPSIS

~/.claude/CLAUDE.md

./CLAUDE.md

./.claude/CLAUDE.md

./<subdir>/CLAUDE.md

METADATA

FORMATMarkdown
FILENAMECLAUDE.md
CASE SENSITIVEYes
TOOLClaude Code
ENCODINGUTF-8
GIT COMMITTEDYes
MAX SIZEUnder 200 lines (~10KB)
SINCEClaude Code v0.2.x (early 2025)

DESCRIPTION

CLAUDE.md is the primary instruction file for Claude Code, Anthropic's agentic coding CLI. When Claude Code starts a session, it reads and concatenates all CLAUDE.md files from the user's home directory down through the project root to the current working directory. This creates a layered configuration system where global preferences provide defaults, project-level instructions set team standards, and subdirectory files add context-specific guidance.

CLAUDE.md files above the working directory are loaded in full at launch. Subdirectory CLAUDE.md files load on-demand when Claude reads files in those directories. More specific instructions always take precedence over broader ones.

The file uses standard Markdown with no special schema — headings, lists, code blocks, and prose all work naturally. The one special syntax is the @-include directive, which inlines another file's content. For modular organization, .claude/rules/ provides auto-loaded rule files that don't need explicit @-includes.

CLAUDE.md is designed to be committed to version control and shared with the entire team. It should describe the project's conventions, architecture, and development workflow — the same things you'd tell a new team member on their first day. Target under 200 lines for best adherence; beyond that, signal-to-noise ratio decreases and context window consumption increases.

Related files: .claude/settings.json (permissions), .claude/rules/*.md (modular rules), .claude/skills/*/SKILL.md (reusable tasks), .mcp.json (MCP servers), .claudeignore (file exclusions).

Load Order
1~/.claude/CLAUDE.md(global)
2./CLAUDE.md(project)
2./.claude/CLAUDE.md(project)
3./<subdir>/CLAUDE.md(directory)

Lower numbers load first. Higher-priority files override lower ones.

STRUCTURE

├──Project Title / Overview
A brief description of what the project is — language, framework, purpose. Helps Claude understand context before reading code.
├──Code Style
Formatting preferences, naming conventions, import ordering, and linting rules. Be specific: 'Use named exports, not default exports.' Don't restate rules already enforced by Prettier/ESLint configs.
├──Architecture
High-level system structure — directory layout, key abstractions, data flow. Reference actual paths in the repo.
├──Commands
Build, test, lint, and deploy commands. Claude will use these to verify its own changes. List them exactly as typed in a terminal.
├──Git Conventions
Commit message format, branch naming, PR conventions. E.g. 'Conventional Commits: feat:, fix:, chore:'
└──Notes / Gotchas
Anything that would trip up a new contributor: legacy patterns to avoid, known sharp edges, migration state.

ANNOTATED EXAMPLE

CLAUDE.md
markdown
1# Acme API Server
2
3> TypeScript + Express REST API with PostgreSQL.
4> Deployed on AWS ECS. Monorepo managed with Turborepo.
5
6## Code Style
7
8- TypeScript strict mode — no `any`, no `ts-ignore`
9- Named exports only (no default exports)
10- Prefer functional patterns: map/filter/reduce over for-loops
11- Error handling: use Result<T, E> type from `src/lib/result.ts`
12- Use `import type` for type-only imports
13
14## Architecture
15
16- `src/routes/`  — Express route handlers (thin layer, delegates to services)
17- `src/services/` — Business logic, one file per domain entity
18- `src/db/`       — Drizzle ORM schema and query helpers
19- `src/lib/`      — Shared utilities (logger, result type, validation)
20- `src/middleware/` — Express middleware (auth, rate-limiting, error handler)
21
22## Commands
23
24```bash
25pnpm install          # Install dependencies
26pnpm dev              # Start dev server (port 3000)
27pnpm test             # Run Vitest suite
28pnpm test:e2e         # Run Playwright API tests
29pnpm lint             # ESLint + Prettier check
30pnpm db:migrate       # Run pending Drizzle migrations
31pnpm db:seed          # Seed dev database
32```
33
34## Git Conventions
35
36- Conventional Commits: `feat:`, `fix:`, `chore:`, `docs:`
37- Branch naming: `feat/short-description`, `fix/issue-number`
38- Squash merge to main; delete branches after merge
39- Run `pnpm lint && pnpm test` before committing
40
41## Notes
42
43- The `src/legacy/` directory is being migrated to the new service pattern.
44  Do not add new code there. If you need to modify legacy code, migrate
45  the relevant module to `src/services/` first.
46- All dates are stored as UTC in the database. Never use local time.
47- The auth middleware at `src/middleware/auth.ts` uses JWT tokens.
48  Never bypass auth checks — always use the `requireAuth` middleware.
49
50@docs/api-patterns.md
51@docs/database-conventions.md

SPECIAL DIRECTIVES

@filename.md
@filename.md

Include directive. Inlines the content of the referenced file at that point. Paths are relative to the CLAUDE.md that contains the directive. Use this to keep the main file short and split concerns into separate docs (e.g. @docs/architecture.md, @docs/style-guide.md).

COMMON MISTAKES

Gotchas
&cross;WRONG claude.md, Claude.md, Claude.MD
&check;RIGHT CLAUDE.md (exact case required)

The filename is case-sensitive on all platforms, including macOS (which has a case-insensitive filesystem by default — the file will be found but Claude Code checks the exact name). It must be uppercase CLAUDE with a lowercase .md extension.

&cross;WRONG Putting API keys, tokens, or passwords in CLAUDE.md
&check;RIGHT Never put secrets in CLAUDE.md — it is committed to git

CLAUDE.md is a versioned file intended to be shared with your team. Treat it like any other source file. Use environment variables or .env files for secrets.

&cross;WRONG Writing exhaustive rules that restate Prettier/ESLint config ('Always use exactly 2 spaces, never use tabs...')
&check;RIGHT State principles and let Claude infer the rest from existing code and tool configs

Claude reads your codebase and its config files. If your project already uses Prettier with a config, you don't need to restate every Prettier rule. Over-constraining wastes tokens and can conflict with tool configs.

&cross;WRONG Putting all documentation in a single enormous CLAUDE.md (200+ lines)
&check;RIGHT Use @includes to split into focused files, or use .claude/rules/ for modular rules

A 50KB CLAUDE.md is expensive to process on every request. Split into @docs/architecture.md, @docs/testing.md, etc. Or use .claude/rules/ where each .md file is auto-loaded. Target under 200 lines per file for best adherence.

&cross;WRONG Duplicating project-root instructions in every subdirectory CLAUDE.md
&check;RIGHT Subdirectory files extend the parent — only add what's specific to that directory

All CLAUDE.md files from the root to the current working directory are concatenated in order. Subdirectory files should contain only the delta: additional rules, overrides, or context specific to that subtree.

&cross;WRONG Using CLAUDE.md to set permissions or security policies
&check;RIGHT Use .claude/settings.json for tool permissions; CLAUDE.md is for instructions

CLAUDE.md is an instruction file, not a security boundary. Permissions for shell commands, MCP tools, and file access are managed in .claude/settings.json with allow/deny arrays using tool-scoped patterns like Bash(npm run *) or Read(./.env).

&cross;WRONG Confusing .claude/rules/ with CLAUDE.md @includes
&check;RIGHT Rules auto-load from .claude/rules/; @includes are explicit references in CLAUDE.md

Files in .claude/rules/ are always loaded into context automatically — no @-reference needed. They can also be path-scoped with glob patterns to only load when working on matching files. @includes in CLAUDE.md inline content at a specific point in the file.

USED BY

SIMILAR FILES

AGENTS.mdAgents Instruction File
.cursorrulesCursor Rules (Legacy)

COMPARISONS

agentconfig.ing2026-03-16CLAUDEMD(5)