This article covers CLAUDE.md Files Explained in detail. Every Claude Code session starts fresh — unless you give it a memory. A CLAUDE.md file is a plain Markdown document that Claude Code reads automatically at the start of every session in your project. It is where you write down the things you would otherwise repeat forever: how to build and test the project, which conventions the team follows, where the tricky parts of the architecture live. Set it up once, and every future session begins already oriented.
What Is a CLAUDE.md File, Exactly? – CLAUDE.md Files Explained
Think of the CLAUDE.md file as a briefing note pinned above a new engineer’s desk. When Claude Code launches in a directory, it loads the applicable memory files into context before your first prompt. There is no magic or training involved — the file is simply always-there context, written in normal Markdown, stored in your repository, and editable with any text editor.
Memory comes in several scopes, and Claude Code merges them:
| Scope | Location | Shared with |
|---|---|---|
| User memory | ~/.claude/CLAUDE.md |
Only you, across all projects |
| Project memory | ./CLAUDE.md in the repo root |
Everyone who clones the repo |
| Local memory | ./CLAUDE.local.md |
Only you, in this project (gitignore it) |
Files in parent and child directories also play a role: Claude reads memory from parent folders up the tree, and picks up additional CLAUDE.md files in subdirectories when it works in them — handy in monorepos where each service has its own quirks. Organizations can additionally deploy a managed policy file that users cannot override.
Generate Your First CLAUDE.md File with /init – CLAUDE.md Files Explained
You do not have to start from a blank page. Inside any project, run:
/init
Claude scans your repository — manifests, build scripts, CI configuration, README, existing conventions — and drafts a CLAUDE.md capturing your build, test and lint commands plus the project’s structure. Treat that draft as a starting point: the generated file is good, but a human pass that adds the non-obvious facts (the migration folder that must never be edited by hand, the flaky test that always fails on Mondays) is where the real value appears.

What Should You Put in a CLAUDE.md File?
The highest-value contents are facts Claude cannot reliably infer from code:
- Commands: exact build, test, lint and dev-server commands, including the fast single-test variant.
- Conventions: naming, formatting, error-handling and commit-message rules the team actually enforces.
- Architecture notes: how the major pieces fit together and where new code of each kind belongs.
- Gotchas: generated files, environment quirks, forbidden patterns, and “always run X before Y” rules.
- Preferences: response style, libraries to prefer or avoid, and review standards.
A compact example:
# Project: Billing API
## Commands
- Test: `pytest -q` (single file: `pytest tests/test_invoices.py -q`)
- Lint: `ruff check .` — must pass before committing
- Run locally: `make dev` (port 8080)
## Conventions
- All money values are integer cents, never floats
- New endpoints go in `app/api/`, schemas in `app/schemas/`
## Gotchas
- Never edit `app/legacy/` — it syncs from the old system nightly
- The `test_ledger.py` suite needs a local Postgres on port 5433
Grow the File with the # Shortcut and /memory
Two features keep memory maintenance painless. While chatting, start a message with # — for example # always run migrations with make migrate, never by hand — and Claude Code will ask which memory file to save it to, appending the note for you. And the /memory command opens your memory files in an editor so you can review, prune and reorganize them directly.
You can also pull in other documents with imports: a line like @docs/architecture.md inside a CLAUDE.md file includes that file’s content, which lets big projects keep memory modular instead of growing one giant document.
Because project memory is committed to the repository, treat changes to it like code changes: propose edits in pull requests, review them with the team, and let the file evolve as the project’s conventions do. Teams that do this find the CLAUDE.md file quietly becomes their most accurate onboarding document — written for an AI, but perfectly readable by every new human who joins.
Keep It Short: CLAUDE.md File Best Practices
Because the file is loaded into every session, it competes for context with your actual work. Treat it like a sharp onboarding doc, not a wiki:
- Aim for the facts that change behavior; delete anything Claude can discover by reading the code.
- Prefer short, direct statements (“Use 2-space indentation”) over paragraphs of rationale.
- Move long procedures — deployment checklists, release playbooks — into on-demand documentation or skills, and leave a one-line pointer in CLAUDE.md.
- Review it like code: when a rule stops being true, remove it in the same pull request.
For the complete memory reference, see Anthropic’s official memory documentation. Pair a tight CLAUDE.md with the workflows in our best practices guide and our slash commands cheat sheet, and Claude Code stops feeling like a generic chatbot and starts feeling like a teammate who has read the handbook.