Documentation was one of the last areas where Claude Code assistance felt marginal to us. Tests, code review, refactoring — obvious wins. Docs — feels like the AI writes reasonable-sounding prose that misses the specific truths teams care about. Then we adopted the Diátaxis framework and specialized subagents for each doc type. Docs went from "we should do more of this" to "we're actually producing useful docs, consistently." This guide is the discipline.
The four kinds of docs (Diátaxis)
Diátaxis is a documentation framework that identifies four distinct kinds of docs, each serving different reader needs. Most doc problems come from mixing these; each fights the others.
Reference: comprehensive, factual. "What API endpoints exist? What parameters? What return types?" Read when someone knows what they need and wants specific details.
Tutorial: guided learning. "Follow these ordered steps to accomplish a specific outcome." Read when someone wants to learn something by doing.
How-to: task-oriented. "How do I do X?" Read when someone has a specific problem to solve and knows they want to solve it.
Explanation: understanding-oriented. "Why does this system work this way? What are the trade-offs?" Read when someone wants to understand the shape of something.
These four categories serve different needs; a doc that tries to be more than one usually fails at all. The discipline is knowing which type you're writing and staying in that lane.
The four docs and their subagents
Our team has four specialists, one per doc type:
- Reference: api-docs-writer for API references; /api-docs for OpenAPI spec generation.
- Tutorial: tutorial-writer for guided walkthroughs.
- How-to: Also tutorial-writer in how-to variant (different structure but same subagent).
- Explanation: technical-writer for conceptual and architectural explanations.
Each subagent has different discipline. Reference: comprehensive, factual, terse. Tutorial: guided, ordered, verifiable. How-to: focused, task-oriented. Explanation: conceptual, well-reasoned.
Reference docs with Claude
Reference is where automation adds the most value. Reference docs describe things that already exist in code; extraction is straightforward.
Our reference layer:
- API spec: auto-generated OpenAPI via /api-docs. Weekly scheduled regeneration + on-demand for API changes. Serves as source of truth for API details.
- Component reference: Storybook auto-generated from component code. Not Claude Code specifically; standard tooling.
- CLI reference: auto-generated from CLI definitions via similar command.
- Function reference: generated JSDoc/pydoc/rustdoc from source code annotations.
Reference discipline:
- Automate everything. Manual reference maintenance always drifts. Automation is the only sustainable answer.
- Preserve manual descriptions. Auto-generated types + manual prose descriptions is the right combination. Tools should preserve manual content across regenerations.
- Version reference. Every reference has a specific version it's accurate for. Users need to know if they're reading current or historical reference.
Tutorials with Claude
Tutorials are learning-oriented; someone wants to build something specific to gain understanding. Different from reference (comprehensive) or how-to (task-focused).
Tutorial discipline via tutorial-writer:
- Structured format. What you'll build, prerequisites, ordered steps, verification, what's next.
- Concrete over abstract. Specific commands, specific paths, specific expected output.
- Verifiable steps. After each step, tell reader how to verify. If they see something different, they know something went wrong.
- 20-30 minute target. Longer than 30 minutes: split into series. Shorter than 20: might be a how-to instead.
Tutorial maintenance is expensive. Steps that worked 6 months ago may not work now. Discipline: periodic verification (quarterly walkthrough by a fresh reader, or CI that runs tutorial steps against current code).
How-to guides with Claude
How-tos answer specific questions. "How do I add a new API endpoint?" "How do I set up local development?" "How do I add a database column?" Different from tutorials (which build to a specific outcome) — how-tos solve specific problems.
How-to discipline (via tutorial-writer in how-to mode):
- Assume some knowledge. How-tos are for people who know what they're trying to do. Tutorials teach; how-tos assume.
- Focused, not comprehensive. Answer the specific question; don't try to cover related topics.
- Multiple, not one big. Better to have 30 focused how-tos than one comprehensive "how to do things."
How-to maintenance is easier than tutorials (shorter, more targeted). Still requires periodic accuracy check.
Explanation docs with Claude
Explanations are the hardest kind for AI assistance because they require judgment. "Why does our team use CQRS for orders but not elsewhere?" involves specific team reasoning; Claude can produce reasonable-sounding answers but might miss the actual reasoning.
Explanation discipline (via technical-writer):
- Human-drafted, AI-polished. The reasoning has to come from humans; Claude helps with structure, prose quality, examples.
- Reference the ADRs. Explanations often reference specific decisions. ADRs (via /adr) provide the decision source; explanations connect them.
- Not-obvious-first. Explanation should start with the thing that isn't obvious. If you're explaining something obvious, it's probably reference or how-to instead.
Explanation is where the docs discipline compounds most. Good explanations transfer institutional knowledge that would otherwise stay in individual heads.
Keeping docs current
Three patterns that work:
1. Automation for drift-prone content. Reference docs regenerate automatically. API changes trigger spec regeneration. Component library docs regenerate on component changes.
2. Scheduled review for judgment-required content. Explanations and tutorials get quarterly review. Someone reads each; verifies still accurate; updates or archives.
3. Broken-window fixes. When someone notices a doc is wrong, they fix it (or file an issue). Team norm: broken docs get fixed, not tolerated.
The 15-minute rule: if fixing a doc issue would take <15 minutes, fix in the moment. Larger fixes: create an issue.
When to skip docs
Not everything needs documentation. Overdocumenting has costs too:
- Skip internal utilities. Small helper functions used only within one file don't need docs. The code is the documentation.
- Skip experimental code. Code being prototyped and might get thrown away isn't worth documenting. Wait until it stabilizes.
- Skip vanilla patterns. If your code is a standard implementation of a well-known pattern, docs explaining the pattern add nothing.
- Skip things nobody will read. Docs for developers who don't exist help no one. Consider actual audience.
Documentation debt is real. Trying to document everything produces docs that get out of date; nobody reads them; team gets exhausted. Focused documentation of high-value content is more sustainable.
Docs review discipline
PR review for docs is different from PR review for code:
- Read as target audience would. Reviewer reads the doc without the writer's context; catches assumptions that snuck in.
- Verify accuracy. Docs should match current code. Reviewer checks specific claims.
- Check the right type. Is this reference trying to be a tutorial? Is this explanation trying to be reference? Fix category confusion.
- Length calibration. Reference should be terse; tutorials should have proper depth; explanations should be as long as needed. Mismatch is a sign of category confusion.
For AI-generated docs specifically:
- Verify facts (Claude sometimes invents plausible-sounding but wrong details).
- Check for over-generalization (Claude sometimes broadens specific team practices into supposed universal truths).
- Verify voice matches team style.
Measuring docs quality
Three metrics that indicate docs health:
1. Time to answer. How long from "developer has question" to "developer has answer in docs"? Well-maintained docs cut this from 10-30 minutes (asking around, searching Slack) to seconds (finding the doc).
2. Doc-related support burden. Support tickets or Slack questions that could have been answered by docs. Rising: docs are getting worse. Falling: docs are improving.
3. Docs freshness. Percentage of docs updated within last 12 months. Should be >70% for actively-maintained docs.
What to do next
- Categorize existing docs by Diátaxis type. Note category confusion.
- Install the four subagents (api-docs-writer, tutorial-writer, technical-writer).
- Automate reference docs (spec generation, Storybook, JSDoc/pydoc).
- Schedule quarterly review for tutorials and explanations.
- Institute docs review discipline in PR process.
- Delete or archive docs that aren't earning their maintenance cost.
Docs discipline is where the compounding gains from AI assistance become most visible. Reference automation removes the boring maintenance burden; specialized subagents produce better-structured tutorials and explanations; team review discipline catches AI-generated drift. Six months in, your team can produce docs that stay current and actually help.