CLAUDE.md & Memory Files
If you do one thing to make Claude Code better, do this. CLAUDE.md is a plain-text file Claude reads at the start of every session — your project's permanent briefing.
- Why CLAUDE.md is the single highest-leverage Claude Code setting
- How the memory hierarchy merges from global to project-specific
- How to generate a starting file with /init and trim it down
- What belongs in CLAUDE.md — and what to keep out
- How @imports let you reference docs without duplicating them
Why it's the highest-leverage setting
Without it, you re-explain your project every session ("we use pnpm, tests are in __tests__, don't touch /generated…"). With it, Claude already knows. Good instructions here improve every future interaction at once.
The memory hierarchy
Claude Code reads memory from several places and merges them, roughly most-global to most-specific:
- User memory — your personal preferences across every project.
- Project memory (
./CLAUDE.md, committed) — how this repo works. Shared with your team. - Nested — drop a
CLAUDE.mdin a subfolder for rules that only apply there.
Know your memory layers
Press Enter or Space to flip the card. Use the left and right arrow keys to move between cards.Term shown.1 / 4
Generate a starting point
Guided walkthrough1 of 3
- Claude inspects the code and drafts a CLAUDE.md for you automatically.
- The draft is a starting point, not the finish line. Trim it to what is true and useful.
- Grab a ready-made starter from the CLAUDE.md Templates page and adapt it to your repo.
Generate a draft CLAUDE.md
/init
Grab a ready-made starter from CLAUDE.md Templates.
What to put in it
- What the project is, in two sentences.
- Tech stack and how to run / test / lint.
- Conventions Claude can't infer (naming, structure, commit style).
- Guardrails: "run tests before declaring done", "never edit
/vendor", "never commit secrets".
What NOT to put in it
- Claude follows CLAUDE.md literally — stale, vague, or wishful instructions actively hurt.
- Describe how the project actually works today; short and true beats long and aspirational.
- Avoid giant pasted docs (use @imports instead), secrets, and rules you don't actually follow.
- Review it periodically so it stays accurate as the project evolves.
Imports
Pull in existing docs instead of duplicating them — e.g. reference your style guide with an @path/to/file import so there's one source of truth. See the official memory docs for the exact syntax.
- One source of truth: reference a file with @imports rather than pasting its contents into CLAUDE.md.
- If a doc already exists, link it — don't copy it. Copies drift out of date.
Check yourself
Check yourself
0/3- CLAUDE.md is the highest-leverage setting: it improves every future session at once.
- Memory merges from global to specific: enterprise policy, then user, project, and nested CLAUDE.md files.
- Start with /init, then edit the draft down to what is actually true.
- Include the project summary, run/test/lint commands, conventions, and guardrails.
- Keep it short and true — use @imports for big docs, and never commit secrets.
Next
- AGENTS.md & Cross-Tool Interop — share one instruction file across every coding agent
- Plan Mode — safe first changes
- Permissions & Modes — what Claude may do unattended
- Walkthrough: Customize Claude Code for a real repo