← Back to Journal
Answers

What is CLAUDE.md and what do you put in it?

Daniela Salgado · Published

What is CLAUDE.md? It is a text file that Claude Code reads at the start of every session: you write the rules, commands and decisions you do not want to repeat. It can live in your home folder or in each project. Anthropic recommends under 200 lines per file; whatever does not fit is split into rules or skills.

What is CLAUDE.md for?

Every Claude Code session starts with a fresh context window; what you explained yesterday is not there today unless it is written somewhere Claude reads at startup [1]. CLAUDE.md is that place: standing instructions loaded before your first message. In Anthropic's context-engineering guide, such files are described as dropped into context up front, while other material Claude retrieves only when it needs it [2].

Where does it live?

There are four locations, depending on who the instructions are for [1]:

ScopeLocationPurpose
OrganizationThe system's managed policy directoryCompany-wide standards, managed by IT
Personal~/.claude/CLAUDE.mdYour preferences across all your projects
Project./CLAUDE.md or ./.claude/CLAUDE.mdProject rules, shared with your team through version control
Local./CLAUDE.local.mdYour own preferences for that project; add it to .gitignore

Claude Code loads the CLAUDE.md files from the folder where you open the session and from every folder above it. They are added together rather than replacing each other, and what is closest to where you work is read last. Files in subfolders load when Claude reads or edits a file in that subfolder [1].

What do you write in CLAUDE.md?

What Claude cannot guess and you want it to follow every time. The documentation asks for instructions concrete enough to verify [1]:

  • "Use 2-space indentation," instead of "Format code properly."
  • "Run npm test before committing," instead of "Test your changes."
  • "API handlers live in src/api/handlers/," instead of "Keep files organized."

A short example of what it looks like:

# Project rules

## Commands
- Install: npm install
- Test: npm test
- Type check: npm run typecheck

## Conventions
- 2-space indentation.
- User-facing text is written in Mexican Spanish.

## Do not touch
- The migrations/ folder: it changes only through a new migration.

It is a format example, not a required template. Grouping with headers and bullets helps: Anthropic notes that Claude follows organized sections more easily than dense paragraphs [1].

How long should it be?

Under 200 lines per file. Longer files consume more context and reduce how well Claude follows them [1]. If yours grew:

  • Move specifics into path-scoped rules, which load only when Claude works with matching files [1].
  • Move procedures into skills. A skill's body is read only when it is used [3].
  • Importing other files organizes but does not save. A CLAUDE.md can pull in other files with @path/to/file, up to four hops deep; imported files load together with the file that imports them, so they cost the same [1].

How do you create the first one?

With the /init command. Claude analyzes the project and generates a file with the build commands, test instructions and conventions it finds. If a CLAUDE.md already exists, /init suggests improvements instead of overwriting it. From there, add what Claude would not have discovered on its own [1].

How do you keep it healthy?

Two habits the documentation recommends [1]:

  1. Check that nothing contradicts itself. If two instructions clash, Claude may pick one arbitrarily. Review your CLAUDE.md files, the ones in subfolders and your rules from time to time, and remove what is outdated.
  2. Ask for an audit. /doctor prompt-audit checks your instruction files for outdated content, references to files or commands that no longer exist, and contradictions; it returns a report with proposed edits and changes nothing until you ask.

For notes meant only for people, block-level HTML comments (<!-- like this -->) are stripped before the content reaches Claude and cost no context [1].

What about AGENTS.md?

If your repository already uses AGENTS.md (the instructions file used by other AI coding tools), Claude Code can read it as your project instructions. By default it reads it only when there is no CLAUDE.md in your working directory or above; if both exist, it reads the CLAUDE.md files, and a CLAUDE.md can import the AGENTS.md so one file is shared [1]. Reading AGENTS.md directly requires Claude Code v2.1.277 or later [1].

Frequently asked questions

What is the CLAUDE.md file?
A markdown file with standing instructions for Claude Code: how you work, which rules you follow, which commands you use. It is written in plain text and Claude reads it at the start of every session. It can be personal, per project, or organization-wide.
How many lines should CLAUDE.md have?
Anthropic recommends under 200 lines per file: longer files consume more context and reduce how well Claude follows them. Instructions that apply to only part of the work are better moved to path-scoped rules or skills, which load only when needed.
Does Claude always obey what CLAUDE.md says?
It is not enforced configuration: Claude treats it as context. That is why instructions should be concrete and verifiable ("run npm test before committing," not "test your changes") and should not contradict each other.
How do I create my first CLAUDE.md?
With the /init command: Claude analyzes your project and generates a first file with the build commands, test instructions and conventions it finds. If one already exists, /init suggests improvements instead of overwriting it.

Sources

  1. Anthropic — "How Claude remembers your project," Claude Code documentation, accessed December 2, 2026. https://code.claude.com/docs/en/memory
  2. Anthropic — "Effective context engineering for AI agents," Anthropic Engineering, September 29, 2025. https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents
  3. Anthropic — "Extend Claude with skills," Claude Code documentation, accessed December 2, 2026. https://code.claude.com/docs/en/skills