Task Decomposition for AI Documentation

Table of content

AI can write documentation. But asking for a complete document in one prompt produces inconsistent quality, invented facts, and content that misses your audience. The fix: decompose documentation tasks into discrete steps.

Tom Johnson, a technical writer at Google who has doubled his output with AI, frames it this way: the more you break complex processes into discrete steps, the better the outcome.

The Five-Step Iterative Workflow

1. Gather Source Material

AI output quality depends on input quality. Before prompting, collect:

Load 100+ pages into large-context models (Gemini handles 700K+ tokens). The AI can’t document what it doesn’t know.

2. Distill with AI

Use AI to process raw material before writing. Ask for:

Summarize the key concepts from these engineering docs.
What are the main user-facing features?
What prerequisites does the reader need?
What gaps exist in this documentation?

You end up with extracted facts instead of hallucinations.

3. Generate Section by Section

Don’t ask for complete documents. Work through your outline one topic at a time.

Request TypeAI Effectiveness
“Write the full API reference”Low - misses context, invents endpoints
“Write the authentication section”Medium - may still drift
“Write a 3-paragraph explanation of OAuth flow for this API”High - focused, verifiable

Each section stays grounded in your source material.

4. Apply Chain of Thought

Separate evaluation from action. This prevents the AI from glossing over problems.

Pass 1: Identify issues

Review this section for:
- Technical accuracy against the source docs
- Missing prerequisites
- Unclear explanations
- Assumed knowledge that should be explicit

Pass 2: Fix issues

Based on the issues identified, rewrite the section.
Keep the same structure but address each problem.

Two passes catch errors one pass buries.

5. Review and Iterate

Multiple cycles for different concerns:

Review PassFocus
TechnicalFacts match source material
AccuracyCode examples run correctly
EditorialStyle guide compliance
AudienceAppropriate for skill level

Each pass adds a layer of quality. Skipping passes shows in the output.

Task Size and AI Effectiveness

The relationship between task scope and output quality:

Task ScopeQualityWhy
Full documentLowToo many decisions, too much context drift
Chapter/sectionMediumManageable but still accumulates errors
Single conceptHighFocused and verifiable
Code exampleHighestConcrete, testable, minimal interpretation

Start small. Assemble larger pieces from verified components.

Prompt Templates

Source Distillation

<task>Extract documentation requirements</task>
<sources>
[Paste engineer interview transcript]
[Paste design doc excerpts]
</sources>
<output>
- Key concepts to document
- Required prerequisites
- Code examples needed
- Questions to clarify with engineers
</output>

Section Generation

<task>Write documentation section</task>
<topic>User authentication flow</topic>
<audience>Backend developers familiar with REST APIs</audience>
<source-facts>
- OAuth 2.0 with PKCE
- Tokens expire in 1 hour
- Refresh tokens last 30 days
</source-facts>
<constraints>
- 3-4 paragraphs max
- Include one code example
- Link to full OAuth spec for details
</constraints>

Chain-of-Thought Review

<task>Review then improve</task>
<section>
[Paste draft section]
</section>
<step-1>
List specific problems with technical accuracy,
clarity, and completeness. Number each issue.
</step-1>
<step-2>
Rewrite the section addressing each numbered issue.
</step-2>

Common Mistakes

MistakeWhat HappensFix
One-shot full documentHallucinated facts, inconsistent toneDecompose into sections
No source materialAI invents plausible-sounding detailsLoad sources first
Skip evaluation passProblems get buriedSeparate identify from fix
Accept first draftRaw AI output needs editingMultiple review cycles
Wrong task sizeToo broad or too narrowMatch to verifiability

The Review Bottleneck

Decomposition creates more pieces to review. This is the trade-off: better quality requires more human attention per section, but each review is simpler.

Mitigation strategies:

The review bottleneck is real, but it beats publishing hallucinated documentation.

Tool Matching

Different AI tools excel at different documentation tasks:

TaskRecommended ToolWhy
Distilling large source setsGemini700K+ token context
Creative structuringClaudeStrong at organization
Grammar and styleChatGPTGood at polish
Code example generationClaude CodeCan verify code runs

Match the tool to the task. See Three-Layer Workflow for the broader principle.

Practical Workflow

A realistic documentation session:

  1. Load source docs into Gemini
  2. Ask for key concepts and gaps
  3. Create outline from distilled material
  4. Generate each section in Claude with structured prompts
  5. Chain-of-thought review each section
  6. Assemble and do editorial pass
  7. Technical review with engineers

Total time: longer than asking for a full doc in one prompt. Quality: noticeably better.

When This Doesn’t Apply

Some documentation benefits from full-document generation:

For anything requiring technical accuracy or audience awareness, decompose.


Next: Tom Johnson’s AI Technical Writing

Topics: workflow ai-agents prompting