A CLAUDE.md file is the Markdown file where you write the standing instructions Claude Code should have in every session. AGENTS.md is an open format for the same kind of instructions, read by Codex, Cursor and other coding agents. If more than one agent touches your repository, put the shared rules in AGENTS.md and let CLAUDE.md import it.
We build with both Claude Code and Codex, and this website's repository uses that exact arrangement. If you want it set up around how your business works, it's part of our Claude Code setup and consulting.
What goes in a CLAUDE.md file
Write down what a competent new hire would get wrong in their first week. The agent can read your code, so it doesn't need a tour of every folder. It does need the facts that aren't visible there.
- The commands to build, lint and test, including the ones it should never run itself.
- Which file is the authority when two disagree, such as where booking links are defined.
- Rules with a reason behind them: a retired vendor, a consent checkbox, a folder that gets regenerated.
- Mistakes that keep coming back. In our repository one of them is unescaped apostrophes in JSX text.
Here is a short starting point you can adapt. The paths and rules are examples.
# Project: booking site
## Commands
- pnpm build (must pass before a commit)
- pnpm lint
- Never start the dev server. Ask the user to run it.
## Rules
- Booking URLs live only in lib/booking.ts.
- Do not add a new SMS opt-in form without approval.
- Escape apostrophes in JSX text.
## Where to look
- Tracking events: docs/ANALYTICS.md"Booking URLs live only in lib/booking.ts" can be checked in a diff. "Keep the code clean" can't, and it takes up room in every session.
CLAUDE.md vs AGENTS.md
| Question | CLAUDE.md | AGENTS.md |
|---|---|---|
| Who reads it | Claude Code | Codex, Cursor, GitHub Copilot coding agent and others, plus Claude Code under the conditions below |
| Format | Markdown, with @path imports | Plain Markdown, no required fields |
| Personal file | ~/.claude/CLAUDE.md | In Codex, ~/.codex/AGENTS.md |
| Best fit | Rules only Claude Code needs | Rules every agent should follow |
The AGENTS.md site describes it as a README for agents and says it is now stewarded by the Agentic AI Foundation under the Linux Foundation. It suggests sections such as a project overview, build and test commands, code style and security notes, and you can use any headings you like.
Version and loading rules, as of December 3, 2026
These details change, so check the Claude Code memory docs and the Codex AGENTS.md guide before you rely on one.
Does Claude Code read AGENTS.md?
Yes, from Claude Code v2.1.277. The default is a fallback: AGENTS.md is read only when there is no CLAUDE.md, .claude/CLAUDE.md or CLAUDE.local.md in the working directory or above it. Your personal ~/.claude/CLAUDE.md doesn't count against that check.
This can catch a team out. One developer adds a CLAUDE.local.md for private notes, and on that machine the shared AGENTS.md is no longer picked up by default. The fix we'd use is a committed CLAUDE.md whose first line imports the shared file:
@AGENTS.md
## Claude Code only
- Use plan mode before changing anything under app/api/.You can also change the behavior under /config, in the Project instructions setting. Its values are claude-md-or-agents-md (the default), claude-md-and-agents-md, claude-md and managed-only. A symlink from CLAUDE.md to AGENTS.md works too, with two drawbacks noted in the docs: the Edit and Write tools won't write through a symlink, and on Windows creating one needs Administrator rights or Developer Mode. We prefer the import.
Claude Code also does not read AGENTS.override.md or AGENTS.local.md. Plain /init reads Cursor and Copilot rule files, and it reads AGENTS.md only when CLAUDE_CODE_NEW_INIT=1 is set.
Where Claude Code looks for CLAUDE.md
- Managed policy, set by IT. On Linux and WSL that is /etc/claude-code/CLAUDE.md.
- User: ~/.claude/CLAUDE.md, for your preferences across projects.
- Project: ./CLAUDE.md or ./.claude/CLAUDE.md, shared through git.
- Local: ./CLAUDE.local.md, private to you and listed in .gitignore.
- Subdirectories: loaded when Claude reads or edits files in that folder.
These files are concatenated, ordered from the filesystem root down to your working directory. If two of them contradict each other, don't count on a particular winner; remove one of the rules. Imports use @path, resolve relative to the file that contains them, and can nest up to four hops. An import that points outside the working directory from a project file asks for your approval first.
How Codex reads AGENTS.md
Codex starts with your global file in ~/.codex (or CODEX_HOME), then walks from the project root down to the current directory. In each folder it takes at most one file, checking AGENTS.override.md, then AGENTS.md, then any names you list in project_doc_fallback_filenames. Files closer to where you are working come later and override earlier guidance. The combined size limit is set by project_doc_max_bytes, 32 KiB by default. For install and config.toml basics, see our OpenAI Codex CLI setup guide.
A repository that already has a CLAUDE.md and no AGENTS.md has two options: move the shared content into AGENTS.md, or add CLAUDE.md to Codex's fallback filenames. We'd move the content, because the fallback lives in one person's Codex config and the file in git reaches everyone. Check any @ lines first: the Codex guide doesn't describe an import syntax, so don't assume Claude's will carry over.
When one file gets too big
The Claude Code docs say to aim for under 200 lines per CLAUDE.md. Importing other files helps you organize, but imported text still gets loaded, so it doesn't save context. Sort each instruction by when it's needed.
| Instruction | Where we'd put it |
|---|---|
| True in every session | AGENTS.md or CLAUDE.md |
| Only matters for some files | .claude/rules/ with a paths field, or a subdirectory file |
| A multi-step procedure | A skill |
| Must never be broken | A PreToolUse hook or a permission deny rule |
| Where a long build currently stands | A handoff file and a task board |
A path-scoped rule is a Markdown file with a short header:
---
paths:
- "app/api/**/*.ts"
---
- Validate the request body before calling any outside service.
- Never log email addresses or phone numbers.The last row of the table is the one we learned on long agent builds, where fresh sessions lost track of what was done. Progress notes change by the hour and don't belong in the instruction file. You can step through a recorded run of the handoff file and board we use to keep a multi-agent build on track.
Mistakes we'd avoid
- Keeping two full copies of the rules. Someone edits one, and the two agents start working from different instructions. Import the shared file.
- Treating a rule as a lock. The docs are direct that CLAUDE.md is context and isn't enforced configuration.
- Pasting API keys or client data into it. A committed instruction file travels with the repository.
- Giving an instruction only in chat and expecting it to last. Project-root CLAUDE.md is loaded again after /compact, while something you only typed can drop out of the summary.
- Assuming the file loaded. Run /context all in Claude Code and look under Memory files.
What we'd do
Create AGENTS.md with your commands, your hard rules and pointers to the docs that own each topic. Add a CLAUDE.md that contains @AGENTS.md. Commit both, then give each agent a small task and ask it to list the rules it was given.
After that, add a line only when an agent gets something wrong that a sentence would have prevented, and delete lines that stopped being true. If you want the instructions, skills, hooks and tool connections built together, our Claude Code consulting service scopes it to the jobs your team repeats.
Frequently asked questions
- What is a CLAUDE.md file?
- A CLAUDE.md file is a plain Markdown file of standing instructions that Claude Code loads as context. It usually holds build commands, project layout, conventions and the things the agent should never do. Claude treats it as guidance, so a rule that must always hold belongs in a hook or a permission setting.
- Does Claude Code read AGENTS.md?
- Yes, as of December 3, 2026 the Claude Code docs say it can read AGENTS.md in place of CLAUDE.md, starting with version 2.1.277. By default it does that only when there is no CLAUDE.md, .claude/CLAUDE.md or CLAUDE.local.md in your working directory or above it. If you have both files, import AGENTS.md from CLAUDE.md or change the Project instructions setting.
- Should I use CLAUDE.md or AGENTS.md?
- Use AGENTS.md as the main file if more than one coding agent works in the repository. Add a CLAUDE.md that imports it when you also have rules only Claude Code should see. If your team only uses Claude Code and has no plans to change, a single CLAUDE.md is enough.
- Where should I put my CLAUDE.md file?
- Put team instructions in CLAUDE.md or .claude/CLAUDE.md at the project root and commit it. Personal preferences for every project go in ~/.claude/CLAUDE.md, and private notes for one project go in CLAUDE.local.md, which you add to .gitignore. Files in subdirectories load when Claude works with files there.
- How long should a CLAUDE.md file be?
- The Claude Code docs say to target under 200 lines per CLAUDE.md file. Longer files use more context on every session. Move area-specific rules into .claude/rules/ with a paths field, and move step-by-step procedures into skills.