CLAUDE.md and AGENTS.md are plain notes you leave in a project folder for a coding agent. Claude Code reads CLAUDE.md and Codex reads AGENTS.md, and both load before your first message. Whatever you would otherwise repeat every session goes in the file, so every session starts from the same rules, and a colleague who opens the folder gets them too.
The file shown below is for a small studio's juice-brand project, where the agent writes render scripts, contact sheets and ffmpeg cuts.
Know which files each agent reads
Claude Code reads a CLAUDE.md in the folder you start in and in every folder above it. It also reads your personal ~/.claude/CLAUDE.md, and a CLAUDE.local.md that you keep out of git for notes that are yours alone. Anthropic suggests keeping each CLAUDE.md under 200 lines, because every line is loaded into every session.
Codex reads ~/.codex/AGENTS.md and then one AGENTS.md per folder, starting at the top of the git repository and walking down to where you started. The closest file is read last, so its rules win. Codex stops adding files at 32 KiB.
Keep one file for both agents
Claude Code also reads AGENTS.md, but only when neither the folder nor any folder above it has a CLAUDE.md or CLAUDE.local.md. Add either and AGENTS.md goes quiet. The documented way to share one file is a CLAUDE.md whose first line is @AGENTS.md, which imports it, with anything meant only for Claude Code written underneath.
To see what loaded, run /context or /memory in Claude Code. In Codex, ask it to summarise its instructions, which is the check OpenAI's own page gives.
Write it as short orders
Write one order per line. Anthropic's memory page says specific, concise instructions are followed more reliably than long paragraphs, and a small studio's file can stay under forty lines. Put the paid-run rule at the top, because it is the reason the file exists. For the juice brand, the start of AGENTS.md might read like this.
The top of AGENTS.md for the juice brand's folderText Nothing that spends money runs without my typed yes. Write the script, run it with --dry-run, show me the total and stop.Never open .env. The Gemini key lives there.Drafts use gemini-omni-1.1-flash at 720p and 4 seconds unless I say otherwise.Renders go in renders/, logs in logs/, contact sheets in sheets/.Name renders like s03_t2_omni_720p.mp4 (shot, take, model, resolution).Copy prompts from the shot list word for word. Never reword them.ffmpeg: never use -y, give every output a new name, and explain each flag in one line before running it.
Add each model's price per second beside its id, copied from the maker's pricing page with the date you checked it. An agent quotes whatever the file says with complete confidence, so an undated figure turns into a wrong estimate printed by a script months later.
Back up the rules that must hold
A rule in CLAUDE.md or AGENTS.md is a request. Anthropic's permissions page says these files shape what Claude tries, while only permission rules, modes and hooks decide what it may do. So the line about never opening .env belongs in the file, and it also belongs in a deny rule, which the last lesson of this module sets up. The file tells the agent why, and the rule stops it on the day it forgets.
The file still beats the chat. A rule you only typed into the conversation can be dropped when a long session is compacted, while the project's file is read again from disk.
Avoid three small traps
A CLAUDE.local.md that you add for private notes also counts as a CLAUDE.md, so Claude Code stops reading AGENTS.md the moment it appears. That is one more reason to use the import. Codex reads AGENTS.override.md in place of the AGENTS.md beside it, so a forgotten override silently replaces the shared rules.
Neither agent picks up an edit to these files in the middle of a session. Codex builds its instructions once per session, and Anthropic says CLAUDE.md edits do not apply mid-session. Restart the agent after changing either file.
The next lesson covers writing a brief an agent can carry out.