Skip to content
FeaturesPricingBlogDownload

← All posts

CLAUDE.md explained: project memory for Claude Code

CLAUDE.md is a Markdown file Claude Code reads at the start of each session. Where each file goes, how the files load, what to put in, what belongs elsewhere.

Diagram card on a light background showing user, project and folder CLAUDE.md files loading sections for commands, conventions and files to leave alone

CLAUDE.md is a plain Markdown file that Claude Code reads at the start of every session, so instructions you would otherwise repeat in each chat are already in context: build commands, conventions, where things live, what to leave alone. Claude Code's memory documentation (checked November 2026) describes it as the place for "what you'd otherwise re-explain." You write it, you commit it with the project, and Claude Code loads it on its own.

If your repository already uses AGENTS.md for several coding tools, AGENTS.md explained covers that file and how a CLAUDE.md can import it. This post is about CLAUDE.md itself: the locations, how loading works, what to put in, and the mechanisms that should hold the things that do not belong there.

Where does a CLAUDE.md file go?

There are four scopes. Claude Code loads them from broadest to most specific, so a project instruction appears in context after a personal one.

Scope Location Who it is for
Managed policy macOS /Library/Application Support/ClaudeCode/CLAUDE.md, Linux and WSL /etc/claude-code/CLAUDE.md, Windows C:\Program Files\ClaudeCode\CLAUDE.md Everyone on the machine, set by IT
User ~/.claude/CLAUDE.md You, in every project
Project ./CLAUDE.md or ./.claude/CLAUDE.md The team, through version control
Local ./CLAUDE.local.md You, in this project only; add it to .gitignore

Most people need two of these: a project file the team shares, and a user file for personal habits such as "explain shell commands before running them."

How does Claude Code load CLAUDE.md files?

At launch, Claude Code reads CLAUDE.md and CLAUDE.local.md from the directory you started in and every directory above it. The files are combined, not overridden: content runs from the top of the filesystem down to your working directory, and CLAUDE.local.md comes after CLAUDE.md at each level.

Files in subdirectories below where you started behave differently. They are not loaded at launch. Claude Code loads each one the first time Claude reads, writes or edits a file in that subdirectory. That makes a nested file the right home for rules that only matter in one part of a project:

repo/
  CLAUDE.md              loaded at launch
  web/
    CLAUDE.md            loaded once Claude touches a file in web/
  scripts/
    CLAUDE.md            loaded once Claude touches a file in scripts/

A few loading details from the documentation:

  • Imports. @path/to/file pulls another file into context. Relative paths resolve from the file that contains the import, and imports can nest up to four hops deep.
  • External imports ask first. The first time a project file imports something outside the working directory, Claude Code shows an approval dialog listing those files.
  • HTML comments are stripped. A block comment such as <!-- why this rule exists --> is removed before the content reaches the model, so you can leave notes for people without spending context on them.
  • Imports do not save space. An imported file loads together with the CLAUDE.md that imports it.

To see what actually loaded, run /context all in a session and look under Memory files. A nested file does not appear there until it loads, at which point a Loaded line with its path appears in the terminal.

What should you put in CLAUDE.md?

Facts Claude needs in every session and cannot reliably work out on its own. The documentation suggests adding a line when Claude makes the same mistake twice, when a code review catches something Claude should have known, or when you type the same correction you typed last session.

# Project

A Next.js site with a Postgres database. App code is in `web/`,
database migrations in `db/migrations/`.

## Commands

- Dev server: `pnpm dev`
- Tests: `pnpm test` (all), `pnpm test web/lib` (one folder)
- Before saying a task is done: `pnpm typecheck && pnpm test`

## Conventions

- Dates in UI copy use `formatDate()` from `web/lib/dates.ts`.
- New database columns need a migration; never edit an applied migration.

## Do not

- Edit files in `web/generated/`. Run `pnpm codegen` instead.
- Add a dependency without saying why.

<!-- Rule above added after two PRs pulled in date libraries. -->

Write rules that can be checked. The documentation's own examples: "Use 2-space indentation" instead of "Format code properly", and "Run npm test before committing" instead of "Test your changes." It recommends keeping each CLAUDE.md under 200 lines, because longer files "consume more context and reduce adherence." Contradictory rules are worse than missing ones, since Claude "may pick one arbitrarily."

What does not belong in CLAUDE.md?

Anything that only applies sometimes. CLAUDE.md loads in full on every session, so it is the most expensive place to store an instruction. Claude Code has other places for the rest:

You want Use Why
Rules for one file type or folder .claude/rules/*.md with a paths field in front matter Loads only when Claude works with matching files
A multi-step procedure, such as a release A skill in .claude/skills/<name>/SKILL.md Only its description loads until it is used
Something that must always happen, such as a lint before commit A hook Runs as a shell command at a fixed point
Something that must never happen, such as reading .env permissions.deny in settings Enforced by the client
Preferences Claude picks up from your corrections Auto memory Claude writes it; see below

The last two rows are the ones people miss. The documentation is direct that CLAUDE.md is "context, not enforced configuration". The text is delivered as a user message after the system prompt, and Claude tries to follow it without any guarantee. If a rule must hold every time, it belongs in a hook or a deny rule, not in prose.

How is CLAUDE.md different from auto memory?

You write CLAUDE.md. Claude writes auto memory. Auto memory is a separate folder of Markdown notes, at ~/.claude/projects/<project>/memory/, where Claude saves corrections and preferences it decides are worth keeping, with a MEMORY.md index that loads at the start of each session. It stays on your machine and is not shared with the team.

When you say "remember to use pnpm", Claude saves it to auto memory. To put an instruction in CLAUDE.md instead, ask for it explicitly ("add this to CLAUDE.md") or edit the file through /memory, which lists every memory location and opens the one you pick in your editor. How to keep memory files useful is covered in AI memory files in Markdown.

How do you keep CLAUDE.md from going stale?

Review it like code, because a wrong line affects every session after it.

  • Start from /init. It analyzes the codebase and writes a starting file with build commands and conventions. If a CLAUDE.md exists, it suggests improvements instead of overwriting.
  • Audit it. /doctor prompt-audit (Claude Code v2.1.283 or later) looks for instructions that reference files or commands that no longer exist, and for files that contradict each other. It proposes edits and changes nothing until you agree.
  • Move, do not grow. When a section only matters for one folder, move it into a nested CLAUDE.md or a path-scoped rule.
  • Delete reversed rules. A rule that no longer applies is not harmless background. Claude will follow it.

Common questions

Is there a size limit?

Each CLAUDE.md that loads at launch is read in full up to 4 MiB; a larger file is skipped entirely. The 200-line guidance is about how well Claude follows the file, not a hard cap.

Does /init read rules from other tools?

Yes. When it generates a CLAUDE.md, /init reads Cursor rules in .cursor/rules/ or .cursorrules and Copilot's .github/copilot-instructions.md, and folds the relevant parts in.

Editing CLAUDE.md in Noteline

Noteline, which we make, opens a project folder and edits CLAUDE.md and CLAUDE.local.md as plain Markdown, with headings, lists and fenced code formatted as you type. The Table of Contents panel (Cmd+Shift+O on a Mac, Ctrl+Shift+O on Windows and Linux) jumps between sections of a long file. Hidden folders are skipped in the sidebar, so .claude/CLAUDE.md, .claude/rules/ and skills are easier to edit in your code editor. If Claude Code rewrites the file while you have it open, a bar offers Use disk version or Keep my version. Noteline has no AI features and does not run Claude Code.

Give your next idea a Markdown file.

Write a note, copy it into your prompt, and keep the original as a plain .md file.

Try desktop free for 14 days ↓Free on iPhone, iPad and Android →

Desktop: 14-day trial, then $9.99 once. Mobile apps: free. No account.

Keep reading

  • How to keep AI meeting notes as Markdown files you own
  • AI memory files: what your assistant should remember, kept in Markdown
  • An AI research workflow in Markdown: sources, summaries and claims

A Markdown note editor with everything you need

We’re listening

Tell us what you need or what gets in your way. If something isn’t working, write to us any time.

contact@noteline.io→

Product

  • Download
  • Pricing
  • Features
  • Changelog

Learn

  • Markdown syntax
  • Use cases
  • Blog

Compare

  • vs Obsidian
  • vs Notion

Support

  • Help
  • Support
  • Privacy
  • Terms

© 2026 Notelinecontact@noteline.io