✻Founding-member pricing: every lesson for $19/mo. The first 3 lessons are free. Start lesson 1 →
Unit 1 · Claude Code Foundations · Lesson 7 of 40

CLAUDE.md: Your Project's Memory

Give Claude persistent memory with CLAUDE.md: where the files live, how they load, what to put in them, /init, imports and auto memory.

ACADEMY11 min+72 XP5-question quiz

🎯 By the end of this lesson you'll be able to

  • Know the CLAUDE.md scopes and where each lives
  • Generate a starter file with /init
  • Decide what belongs in CLAUDE.md and what doesn't
  • Understand auto memory and /memory

Claude starts every session fresh

Claude doesn't remember yesterday's session. Without help, you'd re-explain your test command, your folder conventions and that one gotcha every time. **CLAUDE.md** fixes this: it's a markdown file of instructions that Claude Code loads at the start of every session.

Where CLAUDE.md files live

ScopeLocationWho it's for
OrganizationManaged policy location set by ITEveryone in the company
User~/.claude/CLAUDE.mdYou, in every project
Project./CLAUDE.md or ./.claude/CLAUDE.mdThe whole team (commit it)
Local./CLAUDE.local.mdYou, in this project (gitignore it)

Files in your working directory and every directory above it load at launch. They're combined, not overridden, and the closest file is read last. A CLAUDE.md in a subdirectory loads on demand, when Claude starts working with files there.

/init: a starter in seconds

text
/init

/init explores your repo and writes a starter CLAUDE.md with build commands, test commands and the structure it discovered. If one already exists, it suggests improvements instead of overwriting. It can also migrate rules from other tools' files, like .cursorrules.

What to put in it

The best CLAUDE.md files are short and specific. Include things Claude can't easily discover, or would get wrong:

CLAUDE.md
# Shop API

## Commands
- Test: `pnpm test` (single file: `pnpm test -- path/to/file`)
- Typecheck: `pnpm tsc --noEmit`. Run it before saying you're done.

## Conventions
- Money is integer cents everywhere. Never use floats for currency.
- New endpoints go in `src/routes/` and need a test in `tests/routes/`.

## Gotchas
- `legacy/` is generated. Don't edit it; change `schema/` and run `pnpm gen`.
- Staging uses a different Stripe account; keys are in 1Password, not .env.

What to leave out: long architecture essays (Claude can read the code), instructions for rare tasks (make them skills, Unit 4), and rules that must never be broken. CLAUDE.md is guidance Claude follows, not enforcement. Hard rules belong in hooks and permissions (Units 3 and 7).

!
Keep it under ~200 lines

CLAUDE.md loads on every request, so every line costs context, every time. Long files also dilute the important lines. If something applies only to one part of the codebase, move it to a path-scoped rule in .claude/rules/ (Unit 3).

Imports

Pull other files in with @path syntax:

markdown
See @README.md for an overview and @docs/api-conventions.md for API rules.

Imports keep files organized, but the imported content still loads, so they don't save context.

Auto memory: Claude takes its own notes

Besides the CLAUDE.md you write, Claude Code keeps auto memory: notes Claude writes for itself as it learns your preferences and project facts. It's stored per repository under ~/.claude/projects/<project>/memory/, with a MEMORY.md index that loads at session start.

  • Say "remember that…" and Claude saves it to auto memory.
  • Say "add this to CLAUDE.md" and it goes in the shared file instead.
  • Run /memory to see every memory file, open them, or turn auto memory on and off.
◎Where should this go?pick the best fit
"Run pnpm test to test. Money is integer cents."
Short, always-relevant facts belong in CLAUDE.md.
"Our 14-step release procedure, used once a month."
Long procedures for occasional tasks belong in a skill that loads on demand.
"Never, ever edit files in migrations/applied/."
A rule with no exceptions needs enforcement, and a PreToolUse hook can block the edit.

Check your understanding

?Lesson quiz10 XP per correct answer · +25 for a perfect score
QUESTION 1 OF 5

Where should team-wide project instructions live?

Why: The project CLAUDE.md is shared with the team through version control.
QUESTION 2 OF 5

How do multiple CLAUDE.md files combine?

Why: Files are combined, not overridden, ordered from the root down.
QUESTION 3 OF 5

What's the best home for a rule that must never be broken?

Why: CLAUDE.md is guidance. Hooks and permissions are enforcement.
QUESTION 4 OF 5

What does /init do?

Why: /init explores the repo and writes, or suggests improvements to, CLAUDE.md.
QUESTION 5 OF 5

Why keep CLAUDE.md short?

Why: Every line costs context every turn, and focus matters.
0 / 5 correct
Academy lesson

Unlock lesson 7 and the next 33

You've finished the free lessons. Join the Academy for $19/month to unlock every lesson, quiz, terminal simulation and puzzle, plus the final exam and your certificate of completion.

  • All 40 lessons across 9 units
  • 165+ quiz questions
  • Final exam + certificate
  • New lessons as Claude Code evolves
  • XP, streaks and badges
  • Cancel anytime

Already a member? Log in to continue.

Key takeaways

  • CLAUDE.md gives Claude persistent, shared project memory.
  • Scopes stack: organization → user → project → local, closest read last.
  • Keep it short: commands, conventions, gotchas. Move procedures to skills.
  • CLAUDE.md guides; hooks and permissions enforce.

Nice work. Lesson 7 done?

Mark it complete to earn +72 XP, keep your streak alive and unlock badges.

Written by Curtis Cornell from Anthropic's public Claude Code documentation. Last reviewed November 14, 2026. Claude Code changes fast; if something here differs from your version, the official docs win.

Start lesson 1 free →