Documentation That Scales: Constitution, Contracts, and Runbooks

documentation markdown nodejs javascript
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

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

Recommended

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