← CodeClarityLab Home
Browse by Category
+ added · updated 7d
← Back to glossary

Documentation as Code

general Beginner
debt(d9/e5/b7/t5)
d9 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'silent in production until users hit it' (d9). The detection_hints note automated=no, and the listed tools (mkdocs, docusaurus, hugo, adrs) are doc-generation tools, not detectors of drift. Documentation diverging from code is invisible — there is no compiler or linter that flags a stale README or missing ADR. The gap only surfaces when an engineer follows outdated guidance, during an incident when a runbook is missing, or in an onboarding failure.

e5 Effort Remediation debt — work required to fix once spotted

Closest to 'touches multiple files / significant refactor in one component' (e5). The quick_fix requires migrating docs from an external wiki into the repo, creating ADRs in docs/adr/, adding runbooks in docs/runbooks/, wiring OpenAPI annotations for API docs, and establishing a PR review convention for docs. This is not a single-line patch; it involves multiple files, directory structure decisions, and a team process change, but doesn't require rearchitecting the code itself.

b7 Burden Structural debt — long-term weight of choosing wrong

Closest to 'strong gravitational pull' (b7). The choice of where documentation lives (repo vs. external wiki) shapes every future PR workflow, every incident response, every onboarding path, and every architectural decision record process. The applies_to covers both web and cli contexts, meaning it affects all contributors across the codebase continuously. Once the pattern is established (or anti-pattern entrenched), every new doc, runbook, and ADR is pulled toward the existing convention.

t5 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'notable trap (a documented gotcha most devs eventually learn)' (t5). The misconception is explicit: developers assume a wiki is sufficient and equivalent to docs-as-code. This is a common and widely documented pitfall — wikis feel like a reasonable solution until the inevitable drift becomes painful. It's a trap most teams learn after experiencing stale documentation in an incident or during onboarding, making it a t5 rather than a catastrophic or obscure surprise.

About DEBT scoring →

Also Known As

docs-as-code documentation Markdown docs ADR

TL;DR

Treating documentation with the same discipline as code — version controlled, reviewed in pull requests, tested for accuracy, and kept close to the code it describes.

Explanation

Documentation as Code (Docs-as-Code) means writing docs in plain text formats (Markdown, AsciiDoc, reStructuredText), storing them in the same repository as the code, reviewing them in pull requests, and generating publishable sites via CI (MkDocs, Docusaurus, Sphinx). Benefits: docs are versioned with the code they describe, changes require review, and docs never drift to a separate wiki that falls out of date. OpenAPI specs generated from code are an example of docs-as-code taken to its logical conclusion.

Common Misconception

A wiki is sufficient for technical documentation — wikis are disconnected from code, never reviewed alongside changes, and inevitably fall out of date; docs in the repo stay honest.

Why It Matters

Documentation stored outside the repo is almost always wrong — it describes the system as it was when written, not as it is now. Docs next to code get updated when the code changes.

Common Mistakes

  • Documentation in a separate wiki — never reviewed with code changes, guaranteed to drift.
  • README that only covers installation but not architecture decisions or common workflows.
  • Not including runbooks alongside the code that requires them — ops team cannot find them in an incident.
  • Documentation written once and never maintained — schedule periodic doc reviews as part of sprint planning.

Code Examples

✗ Vulnerable
# Docs in Confluence — disconnected from code:
# PR: 'Refactor payment gateway to use Stripe v3'
# No documentation update required in PR
# Confluence page: still describes Stripe v2 API
# New developer follows outdated docs
# 2 hours debugging why the old endpoints dont work
✓ Fixed
# Docs in repo — reviewed with code:
# PR: 'Refactor payment gateway to use Stripe v3'
# Required: update docs/payments.md alongside code changes
# CI check: markdownlint, link checker
# Reviewer sees doc changes alongside code changes
# docs/adr/0012-stripe-v3-migration.md explains the why
# New developer reads accurate, current documentation

Added 15 Mar 2026
Edited 22 Mar 2026
Views 27
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings F 0 pings S 1 ping S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 1 ping S 0 pings S 0 pings M 0 pings T 1 ping W 2 pings T 0 pings F 2 pings S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 1 ping F 1 ping S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 2 pings S
Amazonbot 1
No pings yesterday
Amazonbot 8 Perplexity 4 Unknown AI 3 Ahrefs 2 SEMrush 2 ChatGPT 2 Majestic 1 Google 1
crawler 21 crawler_json 1 pre-tracking 1
DEV INTEL Tools & Severity
🟡 Medium ⚙ Fix effort: Medium
⚡ Quick Fix
Store all documentation in the same repository as the code — ADRs in docs/adr/, runbooks in docs/runbooks/, and API docs generated from OpenAPI annotations; review docs changes in the same PR as code changes
📦 Applies To
any web cli
🔗 Prerequisites
🔍 Detection Hints
Documentation in Confluence/Notion diverging from code; no ADRs for architectural decisions; README not updated with code changes
Auto-detectable: ✗ No mkdocs docusaurus hugo adrs
⚠ Related Problems
🤖 AI Agent
Confidence: Low False Positives: High ✗ Manual fix Fix: Low Context: File

✓ schema.org compliant