Agent-Native Documentation Engineering: Designing Documentation for AI Coding Agent-Driven Development

When your “team member” is an AI coding agent, documentation is no longer reference material written for people. It becomes the control interface for the entire system. Its quality directly determines the quality of the agent’s output.

Introduction: Why the Definition of “Good Documentation” Is Being Rewritten

Before 2025, project documentation was written for humans. Even with a weak README, an experienced engineer could often rely on intuition to get the project running.

In August 2025, OpenAI created the AGENTS.md convention for Codex CLI, a project-guidance file written specifically for AI coding agents. Within months, GitHub Copilot, Cursor, Windsurf, Google Jules, Gemini CLI, Aider, Block’s goose, and other major AI coding tools had adopted the format. Anthropic’s Claude Code used a similar idea in CLAUDE.md. By December 2025, the Linux Foundation had established the Agentic AI Foundation, or AAIF, with AGENTS.md, Anthropic’s MCP, and Block’s goose as its three founding projects.

By March 2026, more than 60,000 public repositories contained an AGENTS.md file. Projects with detailed AGENTS.md files saw an average 35–55% reduction in agent-generated bugs and cut the context-configuration time for AI coding tools from 20–40 minutes to under two minutes.

These figures reveal a fact: in AI agent-driven development, documentation is not an accessory; it is infrastructure.

Starting from first principles, this article explains which documents an AI coding agent-driven project should contain, how to write them, how to organize them, and why.


1. What Is Agent-Native Documentation?

1.1 From “Written for People” to “Written for an Agent to Execute”

Traditional documentation assumes that readers have background knowledge and judgment and can infer the correct behavior from ambiguous information.

Agent-native documentation makes a completely different assumption: the reader has no background knowledge and no ability to infer across documents, but will act strictly on the content it sees.

This gives agent-native documentation several defining characteristics:

Explicit beats implicit. A human engineer who reads “run the tests” knows whether to use npm test or pytest. An agent does not. Agent-native documentation must provide exact commands, including every flag and argument. The first principle repeatedly emphasized in AGENTS.md best practices is to provide precise commands rather than vague instructions.

Constraints beat suggestions. “Try to keep the code clean” is reasonable guidance for a person but meaningless noise to an agent. Agent-native documentation replaces soft advice with hard constraints: “all functions must have cyclomatic complexity of 10 or less,” “never commit a .env file,” and “use custom exception classes for error handling, not a bare Exception.”

Structure beats narrative. An agent consumes tokens, not “reading time.” A clearly layered list is more efficient for an agent than a flowing paragraph. This does not mean turning everything into lists; it means giving every layer of information an explicit location, format, and reference mechanism.

Machine-parseable. Agent-native documentation should contain metadata the agent can use to make decisions: frontmatter such as status: active, standardized references such as [SOURCE: architecture-v0.1.md#data-model], and status markers such as superseded_by: architecture-v0.2.md.

1.2 It Does Not Replace the README; It Supplements It in Layers

A common misconception is that AGENTS.md replaces README.md. In reality, they serve different readers:

  • README.md — for humans: project introduction, quick start, and contribution guide.
  • AGENTS.md / CLAUDE.md — for AI agents: behavioral constraints, build commands, coding rules, and workflow requirements.
  • Project documentation, including PRD, Architecture, and Spec — for humans and agents together: product decisions, technical sources of truth, and design proposals.

All three layers have distinct responsibilities and are indispensable.


2. What Documentation Actually Does While a Coding Agent Runs

To understand why documentation matters, first understand how an AI coding agent works.

2.1 The Agent Execution Loop

Using OpenAI Codex as an example, a typical agent flow is:

  1. Read AGENTS.md at startup — Codex begins at the project root, searches down the directory tree for AGENTS.md files, and combines them into an instruction chain that remains active throughout the session.
  2. Receive the task instruction — the user’s prompt.
  3. Plan — based on the instruction chain and task description, the agent decides which files to read and which operations to perform.
  4. Tool-call loop — read files, write files, execute commands, inspect results, and repeat until the task is complete.
  5. Return the result — submit code, generate a report, and so on.

Documentation influences every step in this loop.

2.2 The Specific Role of Documentation at Each Stage

An extension of the System Prompt. AGENTS.md content is effectively injected into the agent’s system prompt. It defines who the agent is in the project, how it works, and which actions are absolutely prohibited. Anthropic’s Claude Code best practices recommend putting persistent context in AGENTS.md or CLAUDE.md when it cannot be inferred from the code itself.

A boundary on the task. When an agent receives an ambiguous instruction such as “implement user authentication,” without a PRD defining business scope, an Architecture document defining technology choices, and a Spec defining interface details, it can only guess. This is Addy Osmani’s “mind reading” problem. The central insight of Spec-Driven Development is that agents are good at pattern completion but poor at guessing unstated requirements.

A memory bridge across sessions. Agents have no memory across sessions. Yesterday’s conversation context is gone today. Repository documents such as the PRD, Architecture, and Spec are the agent’s “long-term memory.” Reading them at the beginning of a new session effectively restores that memory. This is why Claude Code best practices recommend using one session to generate SPEC.md and opening a clean new session for implementation: the new context is uncluttered, and the written spec remains available.

An arbiter of the source of truth. If a code comment says “use PostgreSQL” but the Architecture document says “use SQLite,” how should the agent decide? Without a clear single-source-of-truth rule, it may choose arbitrarily. This is the root cause of inconsistent agent behavior created by documentation drift.


3. Why “Writing the Right Documentation” Matters More Than “Writing Good Code”

3.1 Through the Lens of Context Engineering

In 2025, Anthropic formally described Context Engineering as the natural evolution of Prompt Engineering. Prompt engineering optimizes the wording of instructions; context engineering optimizes the complete set of information a model sees during inference.

After rebuilding its agent framework four times, the Manus team concluded that KV-cache hit rate is the single most important metric for a production AI agent. It directly affects latency and cost. The way documentation is organized—putting everything into one large file or loading layers on demand—directly influences this metric.

The LangChain team summarizes context engineering as four operations: Write, storing information outside the context window; Select, bringing relevant information into the window; Compress, retaining only the tokens required for the task; and Isolate, separating context among different agents or subtasks.

Each operation relates directly to documentation design:

  • Write — record design decisions in Architecture and feature designs in a Spec rather than leaving them in chat history
  • Select — use document layering and references so the agent loads only documents relevant to the current task
  • Compress — keep documentation concise; a 150-line AGENTS.md is more effective than a 500-line one
  • Isolate — split documents so each sub-agent sees only the context it needs

3.2 A Warning from Stanford Research

Research from Stanford and UC Berkeley found that even when a model claims to support a large context window, accuracy begins to decline after roughly 32,000 tokens. This is the “lost in the middle” effect: models focus on the beginning and end of context and more easily overlook the middle.

Therefore, putting every document into one enormous AGENTS.md is an anti-pattern. Information should be exposed in layers, on demand, and progressively.

3.3 Progressive Disclosure

The HumanLayer team proposes a key principle in its CLAUDE.md best practices: Progressive Disclosure.

The central idea is not to tell the agent everything it might ever need inside AGENTS.md, but to tell it how to find that information, so it reads it only when needed.

# In AGENTS.md
## Documentation Index
- Build and test process: see agent_docs/building_the_project.md
- Coding conventions: see agent_docs/code_conventions.md
- Database schema: see agent_docs/database_schema.md
- Inter-service communication patterns: see agent_docs/service_communication_patterns.md

Before beginning any task, determine which documents above are relevant and read them before making changes.

This pattern provides all of the following:

  • Lower token use — unrelated documents are not loaded
  • Minimal context-window occupation — only information needed for the current task enters context
  • Precise agent action — the agent begins work with sufficient context
  • Human maintainability — every document has one responsibility, and changing it does not affect unrelated documents

4. Which Documents Does a Project Driven Entirely by AI Coding Agents Need?

Based on practices from Spec-Driven Development systems such as GitHub Spec Kit, Amazon Kiro, and BMAD-METHOD; Anthropic’s context-engineering guidance; and broad community consensus, an agent-native project should contain the following document layers.

4.1 AGENTS.md: The Agent’s Behavioral Operating System

Responsibility: define the agent’s identity, behavioral constraints, and working rules. It is the first file an agent reads when entering the project.

It should contain:

  • Exact build, test, and lint commands, including every flag
  • Coding-style rules, preferably code examples rather than prose
  • Hard constraints expressed as “never” and “must”
  • A documentation index with paths and descriptions of other documents
  • Commit conventions
  • Security boundaries

It should not contain:

  • Product requirements, which belong in the PRD
  • System-architecture details, which belong in Architecture
  • Feature designs, which belong in a Spec

Best practice: keep it under 150 lines. Beyond that, split content into supporting documents and leave only an index in AGENTS.md. Research shows that frontier reasoning models can reliably follow roughly 150–200 instructions; compliance begins to fall beyond that range.

4.2 PRD: Product Requirements Document

Responsibility: define what to build and why.

Its role for the agent: when deciding whether a feature is in scope or whether an edge case must be handled, the PRD is the final arbiter. Without one, the agent improvises product decisions, which is usually not what you want.

It should contain:

  • Product goals and target users
  • Business scope and non-goals; non-goals are especially important to agents because they stop the agent from adding features on its own
  • Page and feature scope
  • Business rules and acceptance criteria

It should not contain: class names, table structures, API signatures, or any other technical implementation detail.

4.3 Architecture: System Architecture Document

Responsibility: define the system-level technical source of truth: technology choices, system boundaries, data models, and core protocols.

Its role for the agent: the anchor for technical decisions. When choosing a database, deciding an API style, or determining a module boundary, Architecture is authoritative.

It should contain:

  • Technology stack and rationale
  • System boundaries and module divisions
  • Core data models
  • Global constraints, such as “all APIs must be idempotent”
  • Implementation status for the current phase: implemented, required in this phase, or deferred

It should not contain: a step-by-step implementation plan for a specific feature.

4.4 Execution Spec: Feature Design Document

Responsibility: answer how a specific feature should be designed within the constraints of the PRD and Architecture.

Its role for the agent: the blueprint used before implementing a feature. Addy Osmani of the Google Chrome team emphasizes in an O’Reilly article that a spec drives implementation, testing, and task decomposition in a spec-driven workflow; coding should not begin until the spec has been validated.

Thoughtworks’ Technology Radar team further notes that a specification is not merely a PRD. It should explicitly define the target software’s external behavior, including input-output mappings, preconditions and postconditions, invariants, constraints, interface types, integration contracts, and state machines.

It should contain:

  • Feature goals and acceptance criteria
  • Data flow, state machines, and error-handling strategy
  • Interfaces with other modules
  • Non-goals: what the feature will not do

It should not contain: a file-by-file change list, which belongs in the Plan.

4.5 Execution Plan: Implementation Plan

Responsibility: break a validated Spec into an executable sequence of steps.

Its role for the agent: the task list—what files to change, in which order, and how to verify each step. GitHub Spec Kit’s /tasks command essentially generates this layer of documentation.

It should contain:

  • Ordered implementation steps
  • Files involved in each step
  • Verification for each step: test commands and expected output
  • Parallelization recommendations
  • Suggested commit boundaries

It should not contain: the reasoning behind design decisions, which belongs in the Spec.

4.6 Runbook: Operations Manual

Responsibility: answer how to respond to a problem or connect a dependency.

Its role for the agent: the operational guide when configuring an environment, connecting an external service, or diagnosing deployment problems.

4.7 Archive

Responsibility: preserve completed or superseded documents and keep decision history traceable.

Its role for the agent: archived documents must be explicitly marked status: archived. Otherwise, an agent may execute an outdated design as if it were the current source of truth.


5. How to Organize Documentation Efficiently

In an agent-native setting, efficiency has five dimensions: precise action, low token use, minimal context-window occupation, human readability, and maintainability. Every organizational principle below balances these dimensions.

5.1 Single Source of Truth

Rule: each category of information may have only one authoritative source at one layer.

Information categoryAuthoritative layer
Product scope and business goalsPRD
Global technical constraints and system boundariesArchitecture
Design and acceptance of one featureExecution Spec
Task decomposition and implementation orderExecution Plan
Environment configuration and troubleshootingRunbook

Why this matters especially to an agent: an agent does not have a human’s implicit judgment that one location overrides another. If Architecture and a Spec repeat the same fact with different wording, the agent cannot know which is newer.

Method: link across layers; do not copy. Use a standardized reference:

[SOURCE: architecture-v0.1.md#data-model]

5.2 Information Flow and Conflict Resolution

PRD → Architecture → Spec → Plan → Code
  • Downstream artifacts must obey upstream ones.
  • If implementation reveals an error in an upstream document, update the upstream document before continuing.
  • Conflict priority: PRD > Architecture > Spec > Plan

Why “write back first, then continue” is critical: if an agent discovers that a Spec’s interface cannot work and simply works around it in code, the Spec becomes an outdated lie. The next agent or human who reads it will make a wrong decision. Updating documentation before implementation continues is the only way to preserve consistency.

5.3 Frontmatter Metadata

Every document must begin with machine-parseable metadata:

---
status: active       # active | superseded | archived
version: "0.1"       # PRD/Architecture only
superseded_by: ""    # document that replaces this one
date: "2026-03-29"
---

Contribution to the five dimensions:

  • Precise action: when the agent encounters status: superseded, it follows superseded_by to the new document
  • Lower token use: the agent can determine whether a document is valid without reading it all
  • Human readability: the document status is visible immediately
  • Maintainability: archiving requires changing only two fields

5.4 Naming Conventions

PRD:           prd-v{major.minor}.md
Architecture:  architecture-v{major.minor}.md
Spec:          YYYY-MM-DD-<topic>-design.md
Plan:          YYYY-MM-DD-<topic>-plan.md
Runbook:       <topic>-setup.md / <topic>-runbook.md

Important detail: a Spec ends in -design.md and a Plan ends in -plan.md. This is not decoration; it lets an agent distinguish document types from filenames alone.

5.5 Directory Structure

project-root/
├── AGENTS.md                          # Agent entry point
├── docs/
│   ├── DOCUMENT-STANDARD.md           # Documentation standard
│   ├── prd-v0.1.md
│   ├── architecture-v0.1.md
│   ├── execution/
│   │   ├── specs/                     # Active feature designs
│   │   └── plans/                     # Active implementation plans
│   ├── runbooks/                      # Operations manuals
│   └── archive/                       # Archived documents

Design rationale:

  • Specs and Plans live under execution/ and are physically separated from stable documents such as the PRD and Architecture.
  • An agent can infer lifecycle characteristics from directory location.
  • Archived documents are concentrated under archive/ instead of scattered throughout the repository.

5.6 Writing Boundaries: Actively Resist Duplication

While writing…Do not include…
PRDDatabase tables, class names, or API implementation details
ArchitectureFile-by-file change steps or task ordering
SpecThe full product goal; link to the PRD
PlanDesign-decision reasoning; link to the Spec
RunbookDebate over whether a feature should exist

Duplication test: before writing each paragraph, ask, “Does this information already exist in another document?” If so, link to it instead of copying it.


6. Practical Recommendations

6.1 A Minimal Spec-Driven Development Workflow

During 2025–2026, engineers at GitHub, Thoughtworks, and Google converged on a common agent-collaboration workflow:

  1. Specify — write the Spec under PRD and Architecture constraints
  2. Plan — have the agent generate an implementation plan from the Spec, then review it as a human
  3. Implement — have the agent follow the Plan step by step, with each step independently testable
  4. Verify — verify after every step instead of waiting until all work is finished

The key is: do not enter the coding stage until the Spec has been validated. This gate is the most effective way to prevent “house-of-cards code”—code that appears to run but does not withstand scrutiny.

6.2 Golden Rules for AGENTS.md

Based on the official AGENTS.md documentation, Anthropic’s CLAUDE.md guidance, and community practice:

One code example beats three paragraphs of prose. Show the correct pattern and an anti-pattern, and let the agent infer the rule from examples. This is more effective than describing code style in English.

Use a three-tier constraint system:

  • MUST / NEVER — a hard constraint; violation is an error
  • SHOULD / PREFER — a strong recommendation that may be departed from for a sound reason
  • MAY / CONSIDER — an optional recommendation

For every line, ask: would the agent make a mistake without it? If the agent can already do the right thing by itself, putting the line in AGENTS.md adds noise. Every unnecessary instruction dilutes the instructions that truly matter.

6.3 A Realistic Documentation-Maintenance Strategy

The greatest enemy of documentation is not failure to write it but gradual documentation rot after it is written. Several practical strategies help.

Manage documentation as code. Commit it to Git, review it as code, and modify it in pull requests. Versioning lets you use git diff to see how documentation evolves.

Archive when a feature is complete. Whenever a feature finishes, check whether its Spec and Plan should be archived. Without this discipline, the next agent scanning docs/execution/specs/ sees a pile of old completed designs, wastes tokens, and faces more ambiguity.

Audit periodically. Have an agent scan docs/ at intervals and produce an audit report: which documents lack frontmatter, which status values may need updates, and where content has leaked across layers. This itself is a task well suited to an agent.


7. Closing Thought: Documentation Is “Infrastructure as Code” for the Agent Era

Every paradigm shift in software engineering has redefined the core artifact:

  • In the waterfall era, the core artifact was the requirements specification.
  • In the agile era, it was working software.
  • In the DevOps era, it was infrastructure as code.
  • In the agent era, the core artifact is becoming the specification itself.

When examining Spec-Driven Development, Thoughtworks’ Technology Radar team raised an open question: which is the ultimate artifact of software development, the specification or the code? The two answers lead to entirely different workflows and development practices.

Whatever the eventual answer, one point is already clear: in agent-driven development, the quality ceiling of the documentation determines the quality ceiling of the code. An agent can generate only what it understands, and its understanding comes entirely from the documents you give it.

Writing good documentation is a prerequisite for writing good code.


References:

  • Official AGENTS.md specification (agents.md)
  • OpenAI Codex documentation — Custom instructions with AGENTS.md
  • Anthropic — Effective context engineering for AI agents
  • Anthropic — Claude Code Best Practices
  • Addy Osmani — How to write a good spec for AI agents (O’Reilly Radar, 2026)
  • Thoughtworks — Spec-driven development: Unpacking one of 2025’s key new practices
  • GitHub Blog — Spec-driven development with AI
  • Manus — Context Engineering for AI Agents: Lessons from Building Manus
  • LangChain — Context Engineering for Agents
  • Martin Fowler / Thoughtworks — Context Engineering for Coding Agents
  • HumanLayer — Writing a good CLAUDE.md
  • Particula Tech — AGENTS.md Explained: The File That Makes AI Coding Agents Useful