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

Code Documentation

General Beginner
debt(d7/e5/b5/t5)
d7 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'only careful code review or runtime testing' (d7). While phpcs and phpmd are listed in detection_hints, they can only catch missing PHPDoc blocks or comment formatting issues — they cannot detect whether documentation explains 'why' vs 'what', whether it's accurate, or whether architectural decisions are recorded. The automated field explicitly says 'no'. Detecting documentation quality requires human code review or the painful experience of onboarding new team members who struggle.

e5 Effort Remediation debt — work required to fix once spotted

Closest to 'touches multiple files / significant refactor in one component' (e5). The quick_fix suggests a mindset shift ('document the why not the what'), but actually fixing documentation debt means reviewing and rewriting comments across multiple files, creating ADRs, updating README files, and establishing new documentation practices. It's not architectural rework, but it's more than a localized fix — it touches many touchpoints where decisions were made without context.

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

Closest to 'persistent productivity tax' (b5). Poor documentation applies across web and cli contexts per applies_to, and creates ongoing friction: new team members take longer to onboard, developers re-debate solved problems (per common_mistakes about missing ADRs), and everyone spends extra time reverse-engineering intent. It doesn't define the system's shape, but it persistently slows down many work streams.

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

Closest to 'notable trap' (t5). The misconception explicitly states 'Good code does not need documentation' — this is a documented gotcha that most developers eventually learn is false. Many developers believe self-documenting code eliminates the need for comments, failing to distinguish between 'how' (readable from code) and 'why' (architectural decisions, constraints, external dependencies). This trap is well-known but still catches people.

About DEBT scoring →

Also Known As

code documentation software docs README

TL;DR

Written explanations of code intent, architecture decisions, APIs, and operational concerns — distinct from comments in source files.

Explanation

Good documentation exists at multiple levels: inline comments for non-obvious why decisions, PHPDoc for API contracts, README files for setup and usage, Architecture Decision Records (ADRs) for significant design choices, and runbooks for operational procedures. The best documentation is up-to-date, co-located with the code it describes (or linked from it), and treats clarity as a design goal. Documentation that explains what rather than why is usually a sign the code itself should be made clearer.

Common Misconception

Good code does not need documentation. Self-documenting code explains the how; documentation explains the why — architectural decisions, non-obvious constraints, external system interactions, and operational runbooks cannot be inferred from code alone regardless of quality.

Why It Matters

Good documentation reduces the time for new team members to become productive, preserves architectural decisions, and prevents rediscovery of solved problems — it is an investment in future velocity.

Common Mistakes

  • Documentation that explains what (readable from code) instead of why (not readable from code).
  • Docs that are out of date because they live separately from the code they describe.
  • No ADRs (Architecture Decision Records) — future developers re-debate the same decisions without context.
  • Over-documenting obvious code and under-documenting complex or non-obvious decisions.

Code Examples

✗ Vulnerable
// Documentation of what — useless:
// Increments the counter by 1
$counter++;

// Documentation of why — valuable:
// Counter starts at 1, not 0, because downstream billing system
// uses 1-based page numbers and we cannot change that API contract.
// See ADR-0042 for context.
✓ Fixed
// PHPDoc — inline API documentation

/**
 * Place an order for the authenticated user.
 *
 * Validates cart contents, applies loyalty discounts, charges payment method,
 * and dispatches OrderPlaced event. The cart is cleared on success.
 *
 * @param  Cart           $cart    Validated cart (must not be empty)
 * @param  PaymentMethod  $payment Tokenised payment method
 * @return Order          The persisted order with status 'pending'
 *
 * @throws CartEmptyException      If the cart has no items
 * @throws PaymentFailedException  If the charge is declined
 */
public function place(Cart $cart, PaymentMethod $payment): Order {}

// README structure:
// 1. What this project does (1 paragraph)
// 2. Quick start (copy-paste to get running)
// 3. Environment variables (.env.example documented)
// 4. Architecture overview
// 5. Contributing guide

Added 15 Mar 2026
Edited 22 Mar 2026
Views 77
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings T 0 pings W 1 ping T 1 ping F 1 ping S 0 pings S 1 ping M 0 pings T 1 ping W 1 ping T 3 pings F 3 pings S 3 pings S 1 ping M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 1 ping F 0 pings S 0 pings S 1 ping M 1 ping T 0 pings W
No pings yet today
SEMrush 1
Amazonbot 16 Perplexity 10 Scrapy 9 Ahrefs 7 Google 5 SEMrush 3 Meta AI 2 Unknown AI 2 ChatGPT 2 Claude 2 Bing 2 Majestic 1 PetalBot 1
crawler 57 crawler_json 3 pre-tracking 2
DEV INTEL Tools & Severity
🟢 Low ⚙ Fix effort: Low
⚡ Quick Fix
Document the why not the what — code shows what it does; comments should explain why a decision was made, what constraint it satisfies, or what would break if this code were changed
📦 Applies To
any web cli
🔗 Prerequisites
🔍 Detection Hints
Comments restating code in English; no explanation of non-obvious business rules; PHPDoc on private methods that add no information
Auto-detectable: ✗ No phpcs phpmd
⚠ Related Problems
🤖 AI Agent
Confidence: Low False Positives: High ✗ Manual fix Fix: Low Context: File


✓ schema.org compliant