Skip to content
yemi-kelani/agentspecs

Instruction files

What goes in a repository's AGENTS.md or CLAUDE.md, how long it can be, and what the evidence says about whether it helps.

Most coding agents read a file from the repository at the start of every session: AGENTS.md, CLAUDE.md, a Copilot instructions file or a Cursor rule. This page asks what goes in that file, how long it can be, and whether it makes the agent’s work any better.

Evidence In controlled tests, adding an instruction file did not significantly change whether coding agents solved tasks, and it raised cost by about a fifth (R1, R1a, R191). Agents did act on the concrete instructions in such files, without following them every time (R1c, R3d). Vendor and practitioner guidance converges on short, human-written files that hold only what the agent cannot work out alone and point to detail elsewhere (R50, R56, R58). None of the size limits comes from an experiment, and one study found no effect of length from 25 to 500 lines (R3).

  • Evidence Across four agent setups on SWE-bench Lite and on 138 tasks from repositories with their own context files, adding an AGENTS.md-style file did not significantly change task success: LLM-generated files moved it by about -0.5 to -2 points, developer-written ones by about +2.4 (R1). The repositories were all Python.
  • Evidence A smaller study of 288 runs (15 tasks for Claude Code and 17 for Codex, from 3 repositories) found no significant change in pass rate between no context and the full AGENTS.md in the system prompt (R191). It could rule out only effects larger than about 10 to 15 points, and many tasks sat at floor or ceiling.
  • Evidence Developer-written files did about 7% better than LLM-generated ones, though still not significantly better than no file (R1d).
  • Evidence Files raised inference cost by about 19% to 23% and added 2.5 to 3.9 agent steps per task (R1a), with up to 22% more reasoning tokens for one model (R1e). A separate study tied an AGENTS.md to a 28.6% lower median runtime for Codex, without measuring correctness (R2). See conflict C1.
  • Evidence In Vercel’s evals on Next.js 16 APIs that models had not seen in training, a compressed docs index in AGENTS.md passed 100% of cases against 53% with no docs (R20). The index shrank from about 40KB to 8KB with no loss, and points to local doc files read on demand (R20b). The sample size is not disclosed. See conflict C3: the rows fit together if a file helps only when it carries facts the model cannot get elsewhere.
  • Evidence A tool such as uv was used about 1.6 times per task when the file mentioned it, against under 0.01 times when it did not (R1c).
  • Evidence Without an instruction file, none of 524 functions carried a required annotation; with one, about 68% did (R3d). A written rule changed behaviour without guaranteeing it.
  • Evidence In the same study, which task the agent was doing moved compliance more (45% to 84%) than any file-structure choice (R3e).
  • Evidence One practitioner often saw agents miss instructions in detailed spec files, and at other times follow them too eagerly (R7a).
  • Evidence The Claude Code docs describe CLAUDE.md as advisory context, and point to hooks for anything that must happen every time (R85).
  • Evidence In a factorial study of Claude Code sessions on one TypeScript codebase, a CLAUDE.md of 25, 100, 250 or 500 lines made no detectable difference to following one simple rule (60% to 68%), and neither did a conflicting rule (R3). Moving the rule from line 2 to line 250 made none either (R3a), nor did splitting the file in two or adding nested files (R3b). It is a single-author preprint scoring a trivial marker.
  • Evidence Other studies found accuracy falling as inputs grew or as more instructions had to be followed at once (R4, R6). See conflict C2 and Context limits.
  • Evidence The Claude Code docs set a target of under 200 lines per CLAUDE.md because longer files reduce adherence, and note that imports organise a file without cutting its context cost (R47). They warn that a bloated file gets rules lost, and suggest testing each line by asking whether removing it would cause mistakes (R48).
  • Evidence Other vendor figures run from about 100 lines for OpenAI’s AGENTS.md map to 500 for Cursor rules (R58, R53), and one practitioner keeps a root CLAUDE.md under 60 lines (R64). None of these figures comes from a published experiment (R58).
  • Evidence OpenAI’s Codex team replaced one large AGENTS.md with a map of roughly 100 lines pointing into a structured docs directory (R56). It reports that the large file crowded out the task, made every rule look equally important, went stale quickly and could not be checked mechanically (R57).
  • Evidence AGENTS.md is plain Markdown with no required fields, meant for build, test and style instructions that would clutter a README (R45).
  • Evidence The Claude Code docs list what belongs: commands the agent cannot guess, non-default style rules, test instructions and project gotchas. They list what to leave out: what it can learn by reading the code, standard conventions, detailed API docs and file-by-file descriptions (R50).
  • Evidence Repository overviews did not help agents reach the files they needed any sooner (R1b). That shows overviews did not help there; it does not show they hurt.
  • Evidence BMad’s project-context step writes a small block of unobvious, project-specific facts and leaves out repo maps, overviews, style a linter can enforce, and history (R63).
  • Evidence Cursor advises adding a rule only after the agent repeats the same mistake, and referencing files rather than copying their contents in (R53, R54). HumanLayer advises never using the model as a linter (R64).
  • Evidence Anthropic describes loading detail just in time: the agent holds file paths and reads through tools when needed, which Claude Code mixes with CLAUDE.md files loaded up front (R52). Anthropic calls the same idea, progressive disclosure, the core design principle of Agent Skills (R60); agentskills.io covers skills in depth.
  • Evidence OpenAI routes Codex to its plan format through a short AGENTS.md section that says when to use it and points to PLANS.md (R55). BMAD always loads three architecture files (coding standards, tech stack, source tree) and tells its developer agent that the story file holds everything else (R144). Kiro steering files have four inclusion modes: always, on a file match, manual and auto (R65).
  • Evidence On-demand detail can go unread: in Vercel’s evals, a skill the agent was free to call was never invoked in 56% of cases, a figure that may predate the final eval suite (R20a), and small wording changes in the pointer swung results (R20c).
  • Write the file by hand, and limit it to what the agent cannot work out alone: commands it cannot guess, non-default conventions and project gotchas (R1d, R50, R63).
  • Name concrete tools and commands; agents used a tool far more often when the file mentioned it (R1c).
  • Leave out repository overviews and file-by-file tours: overviews did not help agents find files sooner (R1b), and the Claude Code docs list file descriptions among things to omit (R50).
  • Keep the file short and point to longer material: vendor targets run from about 100 to 500 lines (R58), and OpenAI moved from one large file to a short map (R56, R57). The one controlled test of length found no compliance effect up to 500 lines, so the case for brevity rests on context cost and vendor guidance (R3, R47).
  • Test each line by asking whether removing it would cause a mistake (R48), and consider adding a rule when the agent repeats a mistake rather than in advance (R53).
  • Back any rule that must always hold with a hook, linter or CI check: a written rule took compliance from 0% to about 68%, not to 100% (R3d), and Claude Code treats the file as advisory (R85).
  • If the agent needs facts it cannot have learned, such as a framework version newer than the model, consider a compact index in the file that points to local docs: one vendor eval found it beat an on-demand skill (R20, R20b, R20a).
  • Expect the file to cost tokens and steps on every task, about a fifth more in one study (R1a).

For how files in different folders and tools combine, see Team context.

  • Whether instruction files help outside Python and TypeScript, beyond 500 lines, or for rules harder than a comment marker (R1, R3).
  • Whether any line or token count marks a point where adherence drops; the vendor figures come from no published experiment (R58).
  • Whether a file helps on work that spans several sessions, which none of the controlled tests covered (R1, R191).
  • Whether a short index with on-demand detail beats an always-loaded file beyond one framework’s docs (R20); see conflict CS2.
  • Whether rule updates cause better compliance, given one before/after result (R183) and a controlled null (R191); see conflict CT1.
  • Open questions collects these gaps.