← ~/pillars / context-engineering / ai-legible-documentation

AI-legible documentation

Structured MADR ADRs with YAML frontmatter, llms.txt for internal platforms, and OpenAPI specs written as agent interfaces: documentation agents can filter, not just read.

updated 2026-06-12 ~4 min read pattern 03/05 Context Engineering

on this page

Context. Agents consume documentation differently from humans: they filter before they read, match intent against descriptions, and treat directory structure as a claim about where things live. Documentation that only works as a narrative read end-to-end is effectively invisible to them.

Forces. Prose ADRs carry rationale an agent needs (why the team chose PostgreSQL, so it doesn’t helpfully migrate you to DynamoDB), but prose can’t be queried by status or topic. Documentation rots faster than code. And every token of documentation loaded eagerly competes with the task itself, so the format must support loading selectively.

Resolution. Four surfaces, each machine-navigable: ADRs in structured MADR format co-located with the code they govern; llms.txt on internal platforms; OpenAPI specs written for intent-matching; and repo structure that documents itself. CLAUDE.md remains the always-loaded layer (its design is the CLAUDE.md architecture pattern), and these surfaces are what it points at.

ADRs: structured MADR with YAML frontmatter

MADR (adr.github.io/madr) is the most machine-navigable ADR standard, and as of March 2026 it has an official YAML variant. The structured-madr extension adds YAML frontmatter that lets agents filter without parsing prose (by status, category, tags, project), map relationships via related, track freshness via created/updated, and validate in CI against a JSON Schema:

---
title: "Use PostgreSQL for primary storage"
description: "Chose PostgreSQL over DynamoDB for ACID requirements in order service"
status: accepted # proposed | accepted | deprecated | superseded
created: 2025-03-15
updated: 2026-01-10
category: persistence
tags: [database, orders, aws]
project: order-service
related: [0012-use-aurora-serverless]
---

Co-locate decisions with the code they govern: docs/decisions/ per service for service-specific decisions, repo root for cross-cutting ones, plus an overview.md index table. The division of labour with CLAUDE.md: ADRs record what was decided and why (past tense, rationale that stops an agent reverting a deliberate choice); CLAUDE.md states what must hold now (present tense, constraints). You need both.

Agents are also good at writing ADRs: Equal Experts reports AI excels at expanding a one-line “kernel of truth” into a full draft, with the firm caveat that outputs are persuasive and need human verification before acceptance (Equal Experts, adolfi.dev). The ADR author command packages this with the guardrails built in: drafts land as proposed, never accepted.

llms.txt for internal platforms

The llms.txt convention is a Markdown index at a documentation root: an H1, a blockquote summary, then sections of annotated links (quickstart, core concepts, API reference, error codes), ideally under 5KB (spec guide). Adoption among developer-facing SaaS is near-mainstream: Anthropic, Stripe, Cloudflare, Vercel, Supabase among confirmed adopters, and IDE agents and MCP documentation servers consume it directly (state of llms.txt 2026).

Two honest caveats from the same report. Google does not support llms.txt, and citation-rate uplift on supporting platforms (Anthropic, Perplexity) is reported as modest; Google shows no response to llms.txt and the broad public-SEO case is unproven. The internal case is different but the evidence is anecdotal: a “small but growing” number of enterprises run llms.txt files on internal platforms. Our call: ship one at the root of every internal developer portal and library doc site anyway. The cost is an afternoon, it is the cheapest way for an agent to onboard to an internal library without reading its source, and the downside is nil.

OpenAPI as the agent interface

Zuplo’s API-readiness analysis is the strongest source on agent-callable API design (Zuplo). Four rules:

  1. Intent-revealing descriptions. Agents match user intent to operations through summaries: “Place an order” beats “POST /orders”.
  2. Business-capability endpoints over CRUD chains. Offer POST /orders/place rather than requiring the agent to orchestrate three calls; chains accumulate context and errors.
  3. Structured errors as recovery mechanisms. RFC 9457 Problem Details with field-level errors and correction suggestions let an agent fix its own request.
  4. Idempotency keys on every state-changing operation. Agents retry on failure; without keys, retries duplicate state.

Agents read descriptions more diligently than humans ever did. Treat the spec’s prose fields as load-bearing interface, not garnish.

Worked example

An internal payments platform is consumed by six teams whose agents keep re-deriving its behaviour from source. The platform team adds: llms.txt at the doc-site root linking quickstart, domain model, OpenAPI spec, and error reference; intent-revealing operation summaries plus RFC 9457 errors and idempotency keys on the two state-changing endpoints; and docs/decisions/ in structured MADR, including the ADR for why settlement is eventually consistent. A consuming team’s agent, asked to integrate refunds, now loads the llms.txt index, follows two links, matches “refund a captured payment” to the right operation, and, crucially, does not “fix” the eventual consistency it would previously have flagged as a bug, because the ADR’s frontmatter surfaced in its search for settlement.

// sources