Saltar al contenido
Pathrule

artículos

Artículos
Ingeniería
/Sertan Helvacı/6 min de lectura

Esta página solo está disponible en inglés.

How Big Can AGENTS.md and CLAUDE.md Get?

Every coding agent reads an instruction file, and almost nobody checks how much of it arrives.

We read the docs and the source of seven agents to find where each one stops, and what it does with the rest.

Respuesta breve

There is no shared limit. Codex stops at 32 KiB of AGENTS.md combined and silently cuts the rest, deepest files first. Claude Code loads a CLAUDE.md up to 4 MiB, skips anything larger, and recommends under 200 lines. Windsurf caps rule files at 12,000 characters. Cursor, Copilot, Gemini CLI and OpenCode set no hard cap.

Pathrule
Pathrule es la capa de inteligencia entre tú, tu espacio de trabajo y tus agentes de programación.

Qué cubre este artículo

  • Codex combines AGENTS.md files from the project root down to the working directory and stops at 32 KiB by default (project_doc_max_bytes = 32768); past that the text is truncated with only a log warning, so the deepest, most specific file is the one that gets cut.
  • Codex does not load AGENTS.md files below the working directory; its base instructions tell the model to look for them itself.
  • Claude Code loads a CLAUDE.md file of up to 4 MiB in full and skips a larger file entirely; its docs recommend under 200 lines per file.
  • Claude Code reads AGENTS.md natively from v2.1.277, but by default only when no CLAUDE.md or CLAUDE.local.md exists in the working directory or above it.
  • Claude Code @path imports reach at most four hops and load at launch, so they organise a file without reducing its context cost; Gemini CLI imports reach five levels.
  • Windsurf (documented as Devin Desktop) limits workspace rule files to 12,000 characters and the global rules file to 6,000; Cursor recommends rules under 500 lines and GitHub suggests about 1,000 lines per Copilot instructions file.
  • Gemini CLI and OpenCode set no size cap; Gemini CLI reads AGENTS.md only when it is added to context.fileName.

Comparación

AgentSize limitPast the limitNested files
Codex CLI32 KiB combined (project_doc_max_bytes)Truncated, deepest file first, log warning onlyRoot to working directory at start; below it the model must look
Claude Code4 MiB per CLAUDE.md; under 200 lines recommendedA file over 4 MiB is skipped wholeAncestors at launch; subdirectories when Claude touches a file there
Windsurf (Devin Desktop)12,000 characters per rule file, 6,000 globalNot documentedSubdirectory AGENTS.md applies to <dir>/**
CursorNo hard cap; under 500 lines recommendedn/aNested AGENTS.md applies to its folder
GitHub CopilotNo hard cap in current docs; about 1,000 lines suggestedn/aNearest AGENTS.md wins (cloud agent); nested off by default in VS Code
Gemini CLINo cap foundn/aWorkspace and parents at start; just in time when a tool touches a folder
OpenCodeNo cap; files read wholen/aNearby files attached when the Read tool opens a file

Check your own files in five minutes

  • Measure what Codex reads: wc -c on every AGENTS.md from the repo root to the folder you work in. Over 32,768 bytes combined, the deepest file is being cut.
  • In Claude Code, run /memory to see which instruction files loaded, and watch for the length warning at startup or in /status.
  • If you keep both CLAUDE.md and AGENTS.md, check which one each agent actually reads: Claude Code ignores AGENTS.md when a CLAUDE.md is on the path, OpenCode ignores CLAUDE.md when an AGENTS.md exists.
  • In Gemini CLI, run /memory show; add AGENTS.md to context.fileName if you rely on it.
  • In VS Code with Copilot, enable chat.useNestedAgentsMdFiles if your AGENTS.md files live in subfolders.
  • Move anything that applies to one folder out of the root file and next to that folder.

Seven agents, seven different ceilings

An instruction file feels like configuration: you write it once and assume the agent has read it. It is not configuration. It is text that has to fit somewhere, and every agent decides on its own how much of it fits and what happens to the part that does not.

We read the documentation and, where the docs were vague, the source code of seven coding agents: Claude Code, Codex CLI, Cursor, GitHub Copilot, Gemini CLI, Windsurf and OpenCode. Everything below was checked on October 20, 2026. These numbers change between releases, so each one links to where it comes from.

Codex: 32 KiB, and the most specific file loses

Codex has the only limit most people will actually hit. It walks from the project root down to your working directory, takes at most one AGENTS.md per folder, and concatenates them. The Codex AGENTS.md guide says it stops adding files once the combined size reaches project_doc_max_bytes, 32 KiB by default.

What the guide does not dwell on is what happens at the boundary. In agents_md.rs the file that crosses the budget is truncated, and the only signal is a log warning. Because the budget is spent from the root down, the file that gets cut is the deepest one: the folder-specific instructions closest to the code you are changing.

Two more details matter. Codex does not load AGENTS.md files below your working directory at all; its base instructions tell the model to look for them when it works there. And it never reads CLAUDE.md unless you list it in project_doc_fallback_filenames. You can raise the limit in config.toml; the docs' own example is project_doc_max_bytes = 65536.

Claude Code: 4 MiB, all or nothing, and AGENTS.md only as a fallback

Claude Code's hard limit is generous. Its memory documentation says it loads a CLAUDE.md of up to 4 MiB in full and skips a larger file. Note the word skips: a file over the limit is not trimmed, it disappears.

The limit you should care about is the recommended one: under 200 lines per CLAUDE.md, because longer files consume more context and reduce adherence. Claude Code warns at startup when a file is over the recommended length. The frequently quoted 200 lines or 25KB figure is real, but it belongs to the auto-memory MEMORY.md index, not to CLAUDE.md.

Claude Code now reads AGENTS.md itself, from v2.1.277, but by default only when there is no CLAUDE.md in your working directory or above it, and a CLAUDE.local.md counts. Add a personal local file and your AGENTS.md quietly stops loading. If you want both, there is a setting that loads them together, or a one-line @AGENTS.md import in CLAUDE.md.

Nested files are loaded on demand: a subdirectory's CLAUDE.md arrives once Claude reads, writes or edits a file in that folder, and rules with paths: frontmatter load when Claude touches a matching file.

Windsurf has a ceiling; Cursor and Copilot have advice

Windsurf, whose documentation now lives under Devin Desktop, is the only other agent here with a published character limit: 12,000 characters per workspace rule file and 6,000 for the global rules file. The docs do not say what happens past it, so treat 12,000 as a wall. A root AGENTS.md is always on; one in a subdirectory applies only when Cascade reads or edits files under it.

Cursor documents no hard cap and recommends keeping rules under 500 lines. Two behaviours are worth knowing: a CLAUDE.md is applied to every conversation regardless of alwaysApply, and an @file reference inside a rule is not inlined, the agent reads that file only when it decides it needs it.

GitHub's code review guide suggests limiting any single instructions file to about 1,000 lines, beyond which response quality may deteriorate. Older posts quote a 4,000-character cap for Copilot code review; we could not find it in GitHub's current documentation. For the cloud agent, the nearest AGENTS.md in the tree wins. In VS Code, nested AGENTS.md support is behind chat.useNestedAgentsMdFiles, which is off by default.

Gemini CLI and OpenCode: no cap, so the cost is yours

Gemini CLI reads GEMINI.md from your workspace and its parents at startup, and loads more just in time when a tool touches a folder. We found no size cap in its docs or its memory discovery code, and everything it finds is sent with every prompt. It reads AGENTS.md only if you add it to context.fileName.

OpenCode reads AGENTS.md, falls back to CLAUDE.md, and reads each file whole. When its Read tool opens a file, it attaches instruction files found near that file. No cap means nothing is cut, and also that nothing stops the file from growing until every turn pays for all of it.

Imports organise a file; they do not shrink it

The usual fix for a long instruction file is to split it with imports. In Claude Code, @path imports reach at most four hops, and the docs are explicit that imported files load at launch, so splitting helps organisation but not context. Gemini CLI imports reach five levels and are likewise concatenated. Codex and OpenCode do not parse imports at all, and Cursor's @file is a pointer the agent may or may not follow.

So an import tree is the same file in more pieces. The only structure that changes what the agent reads is one that loads a piece when the agent is working where that piece applies: nested files, path rules, globs.

The limit that matters is the one before the ceiling

Few teams will hit 4 MiB. Many will hit the point where the file is read on every step and weighed on none of them. That point is measured in cost and adherence, not bytes.

We measured it. In PathruleBench, the same agent works through the same eight sessions while the team's knowledge grows from 500 to 2,000 items. CLAUDE.md files are read whole on every step. At 2,000 items, delivering the same knowledge by path instead cost about 55% less per chain and read 2.7 times fewer input tokens, and the agent passed more of the memory probes. At 500 items a plain file is cheap to read and hard to beat; the gap opens from about 1,000.

That is the idea behind Pathrule: keep a short root file for what really applies everywhere, and put the rest at the path where it applies, so each agent receives the slice for the code it is touching. Whatever tool you use, the checklist above tells you how much of your file is arriving today.