Documentation That Scales: Constitution, Contracts, and Runbooks

Created: • Updated: • 3 min read
Structuring documentation as constitution, contracts, and runbooks

Documentation drift looks harmless until you try to ship a change at 1 a.m. and spend fifteen minutes deciding which conflicting note deserved to be true. I hit that wall after handing more work to AI agents. They read every doc literally, so contradictions turned into slowdowns and risk.

The fix was not "write more documentation." The fix was deciding that every word falls into one of three roles and lives in a known place in the repo. Anything else gets deleted.

Documentation drift wastes time

Before this system, I had:

Every edit meant chasing references across /docs hoping nothing contradicted production. That overhead compounds the moment someone else, human or agent, needs clarity.

Three files, three jobs

All documentation now lives as Markdown in /docs. Each file declares its own role in the frontmatter so agents and humans can filter quickly. The buckets:

  1. Constitution (docs/constitution.md). The non-negotiables: dual-output rule for HAL, no em dashes, router invariants. Any change requires explicit approval.
  2. Contracts (docs/contracts/*.md). Each file mirrors one subsystem such as navigation, analytics, brand tokens, or content schema. It states what exists today and the interface another system can rely on. No future tense, no runbook steps.
  3. Runbooks (docs/runbooks/*.md). Markdown checklists paired with the relevant contract. They capture cadence ("roll analytics 05:00 UTC"), commands, verification steps, and rollback notes.

If a note does not clearly belong to one of those files, it either moves into the backlog or the trash. That ruthless scoping keeps the doc tree small enough to read end-to-end when onboarding someone new.

How it fits into the repo workflow

Why AI work gets faster

Agents fail in two predictable ways: assuming generic conventions or optimizing locally while breaking an invariant. The constitution tells them what never moves, the contract tells them what exists now, and the runbook tells them how to operate it. That structure took PR review cycles from three passes to one because there are no hidden rules.

What’s next

Now that the doc system behaves, I can safely extract a multi-brand token layer, wire a CMS, and expose more automation to collaborators without turning documentation into sludge. The guardrails are simple: keep each Markdown file in its lane, link to the canonical source instead of copying, and never merge a behavior change without updating the doc that defines it.

Recommended

Fixing Navigation and Analytics: When Your Data Lies About User Behavior htmx analytics ux architecture behind-the-scenes
Why I Built My Own Analytics Pipeline (And What It Actually Costs) analytics automation behind-the-scenes
OpenClaw 2026.2.23: The Agent Browser Upgrade openclaw ai automation tools
OpenClaw: What It Is and How to Get the Most Out of It ai automation ops tools
Why I Skipped the CMS architecture content tools
HAL: Build-Time Link Rewriting That Makes Navigation Feel Instant htmx performance architecture
Web Components + HTMX: A Lean Architecture for Content Sites That Ship architecture web-components htmx performance
The Static Site Playbook: Shipping a Content Product on a Near-Zero Budget jamstack architecture static-site-generation performance
How This Site Works: Architecture for a One-Person Team web development architecture performance JAMstack
Less JavaScript, More Leverage: Why I Ship With a 35KB Budget web development performance architecture
Anthropic Trained Its Replacement ai startups founders
Pydantic: The Open Source Layer Quietly Running the AI Economy ai open-source python pydantic anthropic tools
Karpathy Was Wrong: OpenClaw Still Outruns Its 5 Real Alternatives openclaw ai tools security
The YC S26 Deadline Just Closed. Here's What Separates the 1.5% From Everyone Else. startups yc founders
HAL: Cutting 100-300KB of JavaScript by Moving Routing to Build Time performance jamstack htmx
Zero-Server Analytics: How I Replaced a SaaS Bill with Netlify Functions and GitHub analytics serverless netlify github
Mobile-First Layout That Ships: How PrimaryLayout Solves Real UX Problems ux css layout htmx
Progressive Enhancement with HTMX: Ship Fast, Degrade Gracefully web development htmx progressive enhancement
Web Components as a Business Decision web development web components javascript
Static Site Generation: The Business Case for Pre-Rendered HTML web development JAMstack performance SEO

Recommended

Fixing Navigation and Analytics: When Your Data Lies About User Behavior htmx analytics ux architecture behind-the-scenes
Why I Built My Own Analytics Pipeline (And What It Actually Costs) analytics automation behind-the-scenes
OpenClaw 2026.2.23: The Agent Browser Upgrade openclaw ai automation tools
OpenClaw: What It Is and How to Get the Most Out of It ai automation ops tools
Why I Skipped the CMS architecture content tools
HAL: Build-Time Link Rewriting That Makes Navigation Feel Instant htmx performance architecture
Web Components + HTMX: A Lean Architecture for Content Sites That Ship architecture web-components htmx performance
The Static Site Playbook: Shipping a Content Product on a Near-Zero Budget jamstack architecture static-site-generation performance
How This Site Works: Architecture for a One-Person Team web development architecture performance JAMstack
Less JavaScript, More Leverage: Why I Ship With a 35KB Budget web development performance architecture
Anthropic Trained Its Replacement ai startups founders
Pydantic: The Open Source Layer Quietly Running the AI Economy ai open-source python pydantic anthropic tools
Karpathy Was Wrong: OpenClaw Still Outruns Its 5 Real Alternatives openclaw ai tools security
The YC S26 Deadline Just Closed. Here's What Separates the 1.5% From Everyone Else. startups yc founders
HAL: Cutting 100-300KB of JavaScript by Moving Routing to Build Time performance jamstack htmx
Zero-Server Analytics: How I Replaced a SaaS Bill with Netlify Functions and GitHub analytics serverless netlify github
Mobile-First Layout That Ships: How PrimaryLayout Solves Real UX Problems ux css layout htmx
Progressive Enhancement with HTMX: Ship Fast, Degrade Gracefully web development htmx progressive enhancement
Web Components as a Business Decision web development web components javascript
Static Site Generation: The Business Case for Pre-Rendered HTML web development JAMstack performance SEO