GitHub’s analysis of over 2,500 agent configuration files — the ad-hoc but increasingly standard AGENTS.md (or CLAUDE.md, or repo-level agent.md) files developers commit alongside their code — found a clear pattern. The most effective files cover six areas, and use a three-tier boundary system rather than a flat list of rules.

This is the practitioner-facing operationalisation of Writing Specs for AI Coding Agents: the checklist your AGENTS.md should pass before you hand it to a coding agent.

Key

“Most agent files fail because they’re too vague.” The fix isn’t more words. It’s specific commands, real code examples, and graduated boundaries instead of blanket rules.

The six areas

Use this as a checklist for completeness.

1. Commands

Put executable commands early — not just tool names, but full commands with flags. The agent will reference these constantly.

# Good
Build:  npm run build       # compiles TypeScript, outputs to dist/
Test:   npm test            # Jest, must pass before commits
Lint:   npm run lint --fix  # auto-fixes ESLint errors
Dev:    npm run dev         # Vite, port 5173

Bad: “Use the build script.” Good: "Run `pnpm build` at the repo root; outputs to `dist/`."

2. Testing

How to run tests, what framework, where test files live, coverage expectations. “All new modules must have a corresponding *.test.ts in the same directory; run npm test before commit.”

3. Project structure

Where source code lives, where tests go, where docs belong. Be explicit:

src/        application code
tests/      unit & integration tests
docs/       documentation (Markdown)
scripts/    build & dev scripts

4. Code style

One real code snippet beats three paragraphs describing it. Include naming conventions, formatting rules, examples of good output. The agent imitates patterns far better than it follows abstract rules.

// Good — named export, explicit return type, no any
export function parseConfig(raw: string): Config { ... }

This is the same lesson as specificity beats abstract rules: examples are the highest-priority signal the agent uses to disambiguate.

5. Git workflow

Branch naming (feat/, fix/, chore/), commit message format (Conventional Commits, plain prose, etc.), PR requirements (description template, reviewers, CI gates).

6. Boundaries

What the agent should never touch — secrets, vendor directories, production configs, specific folders. “Never commit secrets” was the single most common helpful constraint in the GitHub study. Boundaries get their own treatment via the three-tier pattern below.

Three-tier boundaries (Always / Ask first / Never)

The most effective files don’t use a flat list of don’ts. They use a graduated three-tier system that tells the agent when to proceed, when to pause, and when to stop.

TierSymbolMeaningExamples
Always✅Take this action without askingRun tests before commits; follow naming conventions; log errors to monitoring; format with Prettier
Ask first⚠️Pause; require human approvalModify database schemas; add new dependencies; change CI/CD config; refactor public API surface
Never🚫Hard stopCommit secrets/API keys; edit node_modules/ or vendor/; remove failing tests without approval; force-push to main

Why three tiers, not two. A flat list of rules forces every action into either allowed or forbidden. Most real decisions are neither — they’re probably fine, but a human should look. Without a middle tier, you get either the agent that asks for permission constantly (the Always tier collapses into Ask first) or the agent that quietly does dangerous things (Ask first collapses into Always).

The middle tier is the load-bearing one. It’s the explicit place to put high-impact, ambiguous changes — schema migrations, dependency upgrades, anything that’s reversible-but-expensive or technically-fine-but-strategically-loaded.

Compare with Writing Conflict-Free Instructions: graduated rules with explicit precedence outperform absolute rules that the model has to silently arbitrate between.

Worked example: a complete AGENTS.md

# AGENTS.md — Tasks App
 
## Project
Web app for small teams to manage tasks. React 18 + TypeScript + Vite + Tailwind on the frontend; Node/Express + Postgres + Prisma on the backend.
 
## Commands
- Build:  `npm run build`
- Test:   `npm test`         (Jest, must pass before commits)
- Lint:   `npm run lint --fix`
- Dev:    `npm run dev`      (Vite + Express, port 5173)
 
## Project structure
- `src/`         application code
- `src/api/`     Express routes
- `src/db/`      Prisma schema & migrations
- `tests/`       unit & integration tests
- `docs/`        Markdown documentation
 
## Code style
- TypeScript strict mode; no `any` without a comment
- Functional React components, hooks only
- Named exports preferred over default exports
- Example:
  ```ts
  export function parseConfig(raw: string): Config { ... }

Git workflow

  • Branches: feat/<short-name>, fix/<short-name>, chore/<short-name>
  • Commits: Conventional Commits (feat: add task export)
  • PRs: filled-in template; CI green; one approving review

Boundaries

  • ✅ Always: run tests before commits; format with Prettier; follow naming conventions; log errors to Sentry
  • ⚠️ Ask first: schema changes (prisma/schema.prisma); new dependencies; CI config (.github/workflows/); auth flow changes
  • 🚫 Never: commit secrets or .env*; edit node_modules/; remove failing tests; force-push to main

This is what *not vague* looks like. Every line is something the agent can either do or check.

## Table of contents, not encyclopedia

OpenAI's Codex team learned a load-bearing lesson the hard way (see [[Harness Engineering at OpenAI]]). They first tried the **one big AGENTS.md** approach and it failed in four predictable ways:

1. **Context is scarce.** A giant instruction file crowds out the task, the code, and the relevant docs.
2. **Too much guidance becomes non-guidance.** When everything is "important", nothing is. Agents pattern-match locally instead of navigating intentionally.
3. **It rots instantly.** Monolithic manuals become graveyards of stale rules.
4. **It is hard to verify.** A blob does not lend itself to mechanical checks (coverage, freshness, ownership, cross-links).

Their replacement: **AGENTS.md is the table of contents, not the encyclopedia.**

A short AGENTS.md (roughly **100 lines**) is injected into context and serves primarily as a map. The repository's actual knowledge base lives in a structured `docs/` directory treated as the system of record:

AGENTS.md # ~100 lines, table of contents
ARCHITECTURE.md # top-level domain + layer map
docs/
├── design-docs/ # design decisions with verification status
├── exec-plans/ # active + completed plans, tech-debt tracker
├── product-specs/ # PRDs and feature specs
├── references/ # bundled external docs (e.g. *-llms.txt)
├── DESIGN.md
├── FRONTEND.md
├── PLANS.md
├── PRODUCT_SENSE.md
├── QUALITY_SCORE.md
├── RELIABILITY.md
└── SECURITY.md


> [!key insight]
> 
> **Give the agent a map, not a 1,000-page instruction manual.**
> AGENTS.md tells the agent where to look. The actual knowledge lives in disk-backed files that the agent reads on demand. This is the same always-attached vs on-demand pattern from [[Agent Harness]] "What Belongs in the Always-Attached Set", applied to project knowledge.

This pattern enables **progressive disclosure**: agents start with a small, stable entry point and are taught where to look next. It also enables mechanical verification: linters can check that AGENTS.md links resolve, that referenced docs exist, and that staleness markers are current. A recurring "doc-gardening" agent (see [[Golden Principles and Garbage Collection]]) opens fix-up PRs when the docs drift from the code.

### Train the file from sessions

The structure of the file should also be maintained from evidence. [[Kun Chen]]'s [[AGENTS.md as a Neural Net]] method treats each session as a forward pass and the transcript as the loss record. Review multiple sessions before adding a rule, make only a few edits per pass, keep the always-loaded file within a token budget, and require human approval before writing. Delete or extract rules as readily as you add them. Otherwise the six areas become a checklist that grows into the same bloated manual this page warns against.

The exception is a safety-critical boundary. It may deserve an immediate rule after one incident, but it should still be phrased narrowly and reviewed later for redundancy or drift.

The six areas above still apply. They just live in *referenced* files for anything beyond a one-liner, with AGENTS.md pointing into them.

## What "Agent Experience" (AX) means in practice

Just as APIs are designed for **DX** (developer experience), agent-consumable files should be designed for **AX** (agent experience):

- Clean, parseable formats — Markdown, OpenAPI, JSON Schema
- `llms.txt` files that summarise documentation for LLM consumption
- Explicit type definitions; no implicit context
- Protocols like MCP for tool integration

This is closely related to [[CLI Design for AI Agents]] (the same idea applied to command-line tools) and [[Tool Design for Agent Harnesses]] (applied to tool schemas).

## How this fits with `CLAUDE.md`, `cursorrules`, `.copilot-instructions.md`, etc.

Different vendors use different filenames; the underlying file is the same artifact. `AGENTS.md` is GitHub's convention; `CLAUDE.md` is Anthropic's; Cursor uses `.cursorrules`; Copilot uses repository custom instructions. **Cover the six areas in whichever file your tooling reads.** Some teams maintain one canonical `AGENTS.md` and symlink or generate the others.

## How this connects

- [[Writing Specs for AI Coding Agents]] — the umbrella; the six areas operationalise principle 2
- [[Spec-Driven Development]] — `AGENTS.md` is the always-on backdrop; SDD adds per-feature `spec.md` + `plan.md` + `tasks.md` on top
- [[Writing Conflict-Free Instructions]] — three-tier boundaries are the textbook fix for rule-conflict ambiguity
- [[CLI Tools Pattern]] — Mario Zechner's `README.md` for CLI tools is this idea applied to one tool
- [[Tool Design for Agent Harnesses]] — schema-level analogue
- [[Long-Running Agents - Initializer + Coding Pattern]] — `claude-progress.txt` + `feature_list.json` complement (don't replace) `AGENTS.md`
- [[Pi (Coding Agent)]] — Pi's minimal system prompt is the upstream of why repo-local `AGENTS.md` matters: project context belongs in the repo, not in the harness
- [[AGENTS.md as a Neural Net]] — Kun Chen's transcript-based backward pass for refining project instruction files within a fixed context budget

## Sources

- [Writing Effective Specs for AI Coding Agents](https://addyosmani.substack.com/) — Osmani's summary of the GitHub 2,500-file study; the six-area pattern; the three-tier boundary system; the *"never commit secrets"* finding
- Harness Engineering at OpenAI — Building a 1M-LOC Product with Codex — OpenAI's case study; the table-of-contents pattern; the ~100-line target; structured `docs/` as system of record; doc-gardening agent