The memory we recommend for Codex is Glen, shared memory for coding agents.Go to tryglen.com →
AGENTS.md3 min read

Glen, shared memory for coding agents

Writing AGENTS.md for Codex: what loads, what fits, what to leave out

Codex reads AGENTS.md before it starts work: the global file in ~/.codex (or AGENTS.override.md in its place), then one file per directory from the repo root down, until the total reaches project_doc_max_bytes, 32 KiB by default. Put the rules every task must follow there. Leave personal habits to Codex memories and the history of past sessions to a searchable team memory such as Glen.

Get Glen for Codex
On this page
  1. How Codex assembles its instructions
  2. What earns a place in AGENTS.md
  3. AGENTS.md, Codex memories or Glen
  4. One file, several agents
  5. Knowledge that doesn't fit in a file
  6. Frequently asked questions

How Codex assembles its instructions

  1. Your global file, ~/.codex/AGENTS.md. An AGENTS.override.md there is used in its place.
  2. The AGENTS.md at the repository root.
  3. An AGENTS.md in each directory below that, down to the one you are working in.

Codex stops adding files once the combined text reaches project_doc_max_bytes, which is 32 KiB unless you change it. A deep monorepo with a long root file can hit that ceiling before the most specific directory gets read. Raising the setting is possible, but every byte you add rides along on every request.

What earns a place in AGENTS.md

  • The commands Codex should run: install, test, lint, typecheck, and the order that matters.
  • Conventions you'd otherwise repeat in review, such as where new modules go or how errors are returned.
  • Lines it must not cross. Generated files stay untouched; secrets never get logged.
  • Short pointers into deeper docs, so the detail loads only for tasks that need it.

AGENTS.md, Codex memories or Glen

Three places Codex knowledge can live
AGENTS.mdCodex memoriesGlen
Written byPeople, by handCodex, once enabledGlen's hooks, every turn
Stored inThe repo and ~/.codex$CODEX_HOME/memories/Your organization's hosted memory
EnabledAlwaysOff by default (memories = true)After glen install
ReachesEveryone with the repoOne machineTeammates, filtered by what each may see
Good forRules that must always holdYour own habitsWhy past work went the way it did

OpenAI recommends keeping required team guidance in AGENTS.md, and that advice holds with Glen installed. Recall from Glen depends on a prompt matching past work. A rule in AGENTS.md applies whether or not anything matches.

One file, several agents

AGENTS.md is not Codex-only. Cursor reads it alongside its rules, and Grok Build reads it too. A team that mixes agents can commit one AGENTS.md and get the same rules everywhere, instead of keeping three files in sync.

Knowledge that doesn't fit in a file

The 32 KiB cap is a good discipline, and it also means most of what a team learns never makes it in. Which fix was tried first, why a timeout is 45 seconds, what a reviewer objected to: all of that lives in session transcripts. Glen records those for the organization and returns the relevant part with the prompt that needs it, so AGENTS.md can stay lean. When something recalled from Glen proves to be a standing rule, promote it into AGENTS.md.

Frequently asked questions

Where does Codex look for AGENTS.md?

In ~/.codex for your global file (AGENTS.override.md takes its place if present), then in the repository root and each directory below it down to where you are working.

What is project_doc_max_bytes in Codex?

The limit on how much AGENTS.md text Codex loads, 32 KiB by default. Files past that budget are not read.

Should I use AGENTS.md or Codex memories?

AGENTS.md for anything the team needs, because it is shared through git. Codex memories stays on one machine, which suits personal preferences.

Can other coding agents read AGENTS.md?

Yes. Cursor and Grok Build both read AGENTS.md, so a single committed file can carry the same rules to several agents.

More in this guide

Related guides on agent memory

Fix your agents’ amnesia.

Glen gives Codex the memory of every session your team has run. Start on your own or with up to two teammates. Your first 15,000 memories are free, no credit card.

Start free at tryglen.com