Sonith Manakkat

Claude AI, part 7 of 127 min read10 visuals

CLAUDE.md and memory: teach Claude once, reuse forever

What CLAUDE.md is, where it lives, what to put in it (and what never to), how auto memory differs, and how Projects in the Claude app do a similar job.

  • CLAUDE.md is a plain file Claude Code reads at the start of every session
  • Keep it short, concrete and free of secrets
  • Commit it to the repo so the whole team shares it

Share on LinkedIn

Share
Reading level

Every new Claude Code session starts with a fresh desk. Anthropic's memory documentation says it plainly: each session begins with a fresh context window, and two mechanisms carry knowledge across sessions. One you write (CLAUDE.md). One Claude writes for itself (auto memory). This part covers both, plus the closest thing in the Claude chat app (Projects). Plain pictures first, expert details in the panels.

What CLAUDE.md is

You writeCLAUDE.mdIt sits inyour projectClaude readsit atsessionFewerrepeatedcorrections
You write it once, Claude reads it every session.

When should you add something? Anthropic's guidance is to treat CLAUDE.md as the place you write down what you would otherwise re-explain:

  • Claude made the same mistake twiceWrite the rule down.
  • A code review caught somethingClaude should have known it about this codebase.
  • You typed the same correction againSame clarification as last session.
  • A new teammate would need itThe same context makes people productive too.
Good reasons to add a line.

Where it lives

ScopeLocation (as documented)Shared with
Organisation (managed policy)macOS: /Library/Application Support/ClaudeCode/CLAUDE.md. Linux and WSL: /etc/claude-code/CLAUDE.md. Windows: C:\Program Files\ClaudeCode\CLAUDE.mdEveryone in the organisation
You, all projects~/.claude/CLAUDE.mdOnly you
This project./CLAUDE.md or ./.claude/CLAUDE.mdThe team, through source control
You, this project./CLAUDE.local.md (add to .gitignore)Only you
Expert viewHow the files combine

Anthropic's documentation says Claude Code loads CLAUDE.md and CLAUDE.local.md from the current working directory and every directory above it. All discovered files are concatenated into context rather than overriding each other, ordered from the filesystem root down to your working directory, so instructions closest to where you launched Claude are read last. Files in subdirectories below the working directory are not loaded at launch; each loads once Claude reads, writes or edits a file in that subdirectory.

Block-level HTML comments (<!-- notes for maintainers -->) are stripped before injection, so you can leave notes for humans without spending context. To skip other teams' files in a large monorepo, the docs describe a claudeMdExcludes setting. --add-dir directories are not loaded by default; an environment variable (CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1) turns that on.

  1. 1A new session beginsThe context window starts fresh.
  2. 2CLAUDE.md files are foundFrom your working directory and every directory above it, plus your own and any organisation file.
  3. 3They are joined, not overriddenOrdered from the filesystem root down, so the closest file is read last.
  4. 4Auto memory is addedThe first 200 lines or 25KB of MEMORY.md, whichever comes first.
  5. 5Then you typeSubdirectory CLAUDE.md files load later, when Claude reads a file there.

Takeaway. Claude starts every session already holding both memory systems.

What loads when a Claude Code session starts, per the memory documentation.

What to put in it

Too vague

  • "Format code properly"
  • "Test your changes"
  • "Keep files organized"

Concrete

  • "Use 2-space indentation"
  • "Run npm test before committing"
  • "API handlers live in src/api/handlers/"
Concrete beats vague.
  • Build and test commandsThe exact commands to run.
  • ConventionsNaming, style, patterns to follow.
  • Project layoutWhere things live and why.
  • Do and do-not rules"Never edit files under /generated".
Typical contents.
Expert viewWriting instructions that stick

Anthropic's guidance: write instructions concrete enough to verify; target under 200 lines per CLAUDE.md file, because longer files consume more context and reduce adherence; use headers and bullets; and avoid contradictions, since Claude may pick one arbitrarily. @path/to/file imports let you split a file but do not reduce its context cost, because imported files also load at launch (recursive imports go up to four hops). For instructions that matter only for part of the codebase, use .claude/rules/ files, optionally scoped with paths: frontmatter so they load only when Claude works with matching files.

Claude treats CLAUDE.md as context, not enforced configuration. The documentation says to block an action reliably with a PreToolUse hook instead. Useful commands: /init generates a starting file from your codebase, /memory opens your memory files, and /doctor prompt-audit (requires v2.1.283 or later) checks instruction files for outdated or conflicting content. If your repository uses AGENTS.md instead, the docs describe how Claude Code can read it in place of CLAUDE.md.

OrganisationYou, all projectsThis projectYou, this project1234
  1. Organisation The organisation file loads before your own and the project files.
  2. You, all projects Your personal file adds your habits for every project.
  3. This project The project file adds what the whole team agreed.
  4. You, this project CLAUDE.local.md is appended after CLAUDE.md in its directory, so it is read last there.

point from the widest scope to the narrowest, and all of them are joined into context, so avoid contradictions.

Takeaway. Put each rule at the narrowest scope that needs it.

The CLAUDE.md scopes, from widest audience to narrowest.

Auto memory: notes Claude writes itself

CLAUDE.md

  • You write it
  • Instructions and rules
  • Project, user or organisation scope

Auto memory

  • Claude writes it
  • Learnings and patterns
  • Per repository, shared across worktrees
The two memory systems.
Expert viewAuto memory details

Per Anthropic's memory page, auto memory records four kinds of notes (user, feedback, project and reference) and skips anything derivable from the codebase or already in CLAUDE.md. Files live under ~/.claude/projects/<project>/memory/. The first 200 lines or 25KB of MEMORY.md, whichever comes first, load at the start of every conversation; detailed topic files are read on demand. A CLAUDE.md file up to 4 MiB loads in full, but shorter files give better adherence. Subagents do not inherit the main conversation's auto memory, except a fork. You can audit and edit memory with /memory.

YouClaudeCLAUDE.mdCorrect itAdd one lineLoadedGets it right1234
  1. You to Claude You say "we use pnpm, not npm" again.
  2. You to CLAUDE.md You write the rule down once, in plain words.
  3. CLAUDE.md to Claude (reply) The next session starts by loading the file.
  4. Claude to You (reply) You no longer have to repeat the correction.

Takeaway. A rule in the file costs one edit and saves every future correction.

How a repeated correction becomes a lasting rule.

The chat-app cousin: Projects

If you use Claude in the browser or the app, Projects do a similar job. Anthropic's support pages describe a project as a self-contained workspace with its own chat history and knowledge base. Project instructions apply to every chat in the project, and files in the knowledge base are reused across chats.

  • Project instructionsHow Claude should behave in every chat of the project
  • Knowledge filesReused across every chat in the project
  • SharingOn Team and Enterprise plans, members can be given view or edit access
Projects in the Claude app, per Anthropic's support pages.
Expert viewLimits worth knowing

The support article says chats inside a project do not share context with each other unless the information is in the knowledge base; the project name and description are not visible to Claude; and on a paid plan, when knowledge nears the context limit, Claude turns on retrieval (RAG) mode to expand capacity. Anthropic's pricing page lists Projects among Pro features and memory among Free features. Plan availability changes, so check your plan.

Write down once what you would otherwise explain every time.

Frequently asked questions

Is CLAUDE.md a guarantee?

No. It is context that Claude follows as well as it can. Use a hook to enforce something every time.

How long should it be?

Under about 200 lines. Move rarely needed material into rules or skills.

Can I keep personal preferences out of the shared file?

Yes. Use ~/.claude/CLAUDE.md for all projects, or CLAUDE.local.md for one project, and keep the local file out of git.

Sources

Last checked: 2026-10-21. These are official pages. Check them for anything that may have changed since.

  1. How Claude remembers your project, Claude Code documentation
  2. Extend Claude Code (features overview)
  3. What are projects? Claude support
  4. Claude pricing page

Back to all articles