Skip to content
AI Dev Toolkit.
Esc
  • Loading…

AI glossary · Agents and tools

CLAUDE.md vs AGENTS.md: what is each file?

Also called: AGENTS.md, CLAUDE.local.md, project instructions file

Definition

CLAUDE.md is a Markdown file of project instructions that Claude Code loads into context at the start of every session, and AGENTS.md is the open, tool-neutral equivalent read by many coding agents.

Explained

How does Claude Code load CLAUDE.md and AGENTS.md?

Claude Code reads CLAUDE.md files from several places: ./CLAUDE.md or ./.claude/CLAUDE.md for the project (committed and shared), ./CLAUDE.local.md for your own uncommitted notes, ~/.claude/CLAUDE.md for every project, and an organisation-wide managed file. Files in your working folder and the folders above it load at launch; files in subfolders load when Claude works there. An @path line imports another file, up to four hops deep.

AGENTS.md, which its site calls “a README for agents”, does the same job for Codex, Cursor and others (Gemini CLI reads it when configured to). Since v2.1.277, Claude Code reads AGENTS.md when there’s no CLAUDE.md or CLAUDE.local.md in your working folder or above it. To use both, the documented pattern is a CLAUDE.md that imports it with an @AGENTS.md line.

Claude treats these files as context, not enforced configuration. Anthropic suggests staying under 200 lines per file, because longer files use more context and are followed less reliably.

Example

A short CLAUDE.md and its recurring cost

This file is 126 tokens on OpenAI’s o200k_base tokenizer (Claude’s own tokenizer counts differently). It holds only what Claude can’t work out from the code: the commands, two architecture rules and a security rule.

Because it sits in the context, it goes out with every request: a 40-request session sends it 40 times, about 5,040 tokens, usually at the discounted prompt caching rate. Every line you add is paid for on every turn of every session, which is the best argument for keeping it short.

CLAUDE.md
# Acme web app

Next.js app with a Postgres database. Package manager: pnpm.

## Commands
- `pnpm dev`: start the app on http://localhost:3000
- `pnpm test`: unit tests (Vitest); run them before every commit
- `pnpm lint --fix`: lint and format

## Rules
- Server-only code lives in `src/server/`; never import it from client components.
- Change the database with a new file in `db/migrations/`; never edit an old migration.
- Never commit `.env` files or print secrets in logs.

Cost and quality

Why keep CLAUDE.md short?

A good CLAUDE.md saves the turns Claude would spend rediscovering your build commands and conventions, and stops repeated mistakes. A bloated one costs tokens on every request and dilutes the rules that matter. For rules that must always hold, use a hook instead.

Don’t mix up

Does Claude Code read AGENTS.md, and how is CLAUDE.md different from memory?

Does Claude Code read AGENTS.md?
Yes, from v2.1.277, but by default only when there’s no CLAUDE.md or CLAUDE.local.md in your folder or above it. What AGENTS.md is covers the format itself. Importing it from a CLAUDE.md with an @AGENTS.md line also works in sessions that can’t read AGENTS.md directly.
CLAUDE.md vs auto memory
You write CLAUDE.md. Auto memory is notes Claude writes for itself in a MEMORY.md file, of which the first 200 lines or 25 KB load each session.
CLAUDE.md vs system prompt
The system prompt is set by the app. CLAUDE.md is your project’s file that Claude Code adds to the context alongside it.

FAQ

Questions people ask

Is CLAUDE.md necessary?

No. Claude Code works without one, and since v2.1.277 it reads an AGENTS.md instead if that is all your repository has. Without either, you repeat your build commands, conventions and rules in every session. A short file saves that repetition, but keep it lean: it is loaded into context every session and costs tokens on every request.

How do I create a CLAUDE.md file?

Run /init in Claude Code: it analyses the codebase and writes a starter CLAUDE.md with build commands, test instructions and the conventions it finds, or suggests improvements if a file already exists. You can also create it by hand in the project root. Then trim it to what Claude can’t work out on its own. The CLAUDE.md guide walks through a complete example.

Should I symlink CLAUDE.md to AGENTS.md or import it?

Claude Code’s docs accept both, but the @AGENTS.md import is the safer default. A symlink (ln -s AGENTS.md CLAUDE.md) breaks on Windows clones unless symlinks are enabled in Git, leaving a one-line CLAUDE.md, and Claude’s edit tools won’t write through a symlink. The import also lets you add Claude-specific lines below it.

Go deeper

Try it and read more

Related

All 41 terms in the AI glossary

Written by Tahir Nazir. Checked .

How this was checked: Example file measured with gpt-tokenizer 4.0.0 (o200k_base). Locations, load order, imports, the 200-line guidance, AGENTS.md rules (v2.1.277) and auto memory limits checked against Claude Code’s memory docs; the AGENTS.md description and supporting tools against agents.md, on 2026-10-11. /init behaviour and the symlink and import trade-offs checked against the memory docs on 2026-10-16.

Keep exploring