Back to Blog
ai documentation best-practices llm

How to use AI to write your first documentation draft (and what to fix after)

AI solves the blank page problem in documentation. Here's the prompt framework and 5-pass editing checklist to turn AI drafts into accurate, useful docs.

Yorjander Hernandez
Yorjander Hernandez
Co-founder & CTO · · 6 min read
How to use AI to write your first documentation draft (and what to fix after)

The documentation for the feature you shipped two weeks ago still doesn’t exist. Not because nobody had time. Because nobody could figure out how to start.

That’s the blank page problem. It’s not a motivation problem or a priority problem. It’s a cold-start problem. Writing the first sentence of a doc page is a different cognitive task from writing code, and most engineers never build the reflex for it. The result: features ship without docs, docs ship weeks late, and technical writers inherit a guessing game about what the feature actually does.

AI doesn’t write great documentation. But it does solve the cold-start problem — which means teams that know how to use it right are shipping first drafts in minutes instead of days.

Here’s what that actually looks like.

What AI is actually good at in documentation

AI handles the scaffolding work better than most humans do voluntarily:

  • Structure — it defaults to logical page structure (overview, prerequisites, steps, reference) so you don’t start from scratch
  • Consistency — same terminology, same tone, same section shape across every page it generates in a session
  • Coverage breadth — it won’t forget to add a “What’s next” section or skip the error-handling paragraph
  • First-draft prose — it writes fluently enough that you’re editing, not composing

These are the parts of documentation that feel like overhead when you’re doing them manually. AI takes them off the table so you can focus on the one thing it genuinely can’t do: know whether the content is correct.

What AI gets wrong

This is not a minor caveat. AI gets documentation wrong in ways that are specifically dangerous:

Accuracy. AI will hallucinate parameter names, invent default values, and describe behavior that sounds plausible but doesn’t match your implementation. An AI-generated doc that says a function returns { success: true, data: [...] } when your actual response shape is { ok: true, result: [...] } is worse than no doc — it sends developers on a debugging chase.

Code examples. Generated snippets are often syntactically correct and semantically wrong. They’ll use your library’s general patterns but miss the version-specific behavior, the mandatory options, or the auth flow that’s required before calling the function they’re showing.

Context-specific details. AI doesn’t know your rate limits, your deprecation timeline, the gotcha in your OAuth implementation, or why you made an unusual design decision. It fills those gaps with generic boilerplate.

The failure mode to watch for: an AI-generated page that reads confidently and completely but contains 4 errors per hundred lines. Confident prose makes errors harder to catch, not easier.

The prompt framework for getting useful doc drafts

The quality gap between a bad AI doc prompt and a good one is roughly the difference between a blank page and a 70%-done draft. Here’s the framework:

Include: what the thing does, not just its name. AI doesn’t have access to your codebase. Give it the behavior.

Include: the audience and their goal. “A backend engineer setting up webhooks for the first time” produces different output than “a developer reading the reference.”

Include: the structure you want. If you have a format convention, state it explicitly.

Include: real signatures and response shapes. Paste the actual function signature or API schema. This is the single biggest quality lever.

You are writing developer documentation for a SaaS product.

Write a guide page for the following function:

  createWebhook(url: string, events: string[], options?: { secret?: string, retries?: number }): Promise<{ id: string, status: "active" | "inactive" }>

Audience: backend engineers integrating our API for the first time.

Page structure:
  1. Overview (2–3 sentences, what this does and when to use it)
  2. Prerequisites (bullet list)
  3. Basic usage (code example in Node.js)
  4. Parameters (table with name, type, required, description)
  5. Response shape (table)
  6. Error handling (what the function throws and when)
  7. Next steps (links as placeholders)

Do not invent behavior. Use only what is described above. Mark any information
you're uncertain about with [VERIFY].

That last instruction — Mark any information you're uncertain about with [VERIFY] — is the most important line in the prompt. It surfaces the gaps you need to fill instead of hiding them in confident prose.

For reference pages generated from code, pass the actual source or the OpenAPI spec directly in the prompt rather than describing it. The fewer inferences the model has to make, the fewer errors land in the draft.

The 5-pass editing checklist for AI-generated docs

Don’t read the draft once and call it done. Work through these passes in order — each one has a different focus, and doing them sequentially catches more than doing them all at once.

  1. Accuracy pass — compare every parameter name, type, default, and response field against the actual implementation. Check code examples by running them. Fix every [VERIFY] flag.
  2. Context pass — add the things only you know: rate limits, known edge cases, deprecation warnings, design rationale, version-specific behavior.
  3. Audience pass — read the page as your target user. Does it assume too much prior knowledge? Too little? Cut or expand accordingly.
  4. Tone and terminology pass — align to your style guide. Replace generic terms with your product’s actual terminology. Strip filler phrases (“it’s worth noting that,” “in order to”).
  5. Links and cross-references pass — replace placeholder links, add links to related concepts, confirm that every internal reference resolves.

This process typically takes 20–40 minutes for a medium-length guide page. That’s still significantly faster than writing from scratch, and you end up with a page you’ve actually reviewed rather than one nobody re-read after the AI spit it out.

Before/after: what editing actually changes

Here’s what an unedited AI draft looks like versus the finished version for a short error-handling section:

Raw AI output:

## Error handling

The createWebhook function may throw errors in certain situations. You should
wrap the function call in a try-catch block to handle these cases gracefully.
Common errors include network issues, authentication failures, and invalid
parameters.

After editing:

// Error handling

// createWebhook throws WebhookValidationError if `url` is not a valid
// HTTPS endpoint or if `events` contains an unrecognized event type.
// It throws AuthenticationError if your API key is missing or expired.

try {
  const webhook = await createWebhook(url, events);
} catch (err) {
  if (err instanceof WebhookValidationError) {
    // check err.field to see which parameter failed
  }
  if (err instanceof WebhookRequestError) {
    // err.statusCode: 429 = rate limited, 500+ = server error
  }
}

The raw version is prose that sounds like documentation but contains zero actionable information. The edited version names the actual error classes, describes the actual triggering conditions, and shows how to branch on them. That difference is 100% human knowledge — the AI had no way to supply it.

This is why the editing pass isn’t optional. AI generates the structure and the first-draft prose. The technical substance has to come from you.

How GitDocAI generates context-aware drafts

The problem with using a general-purpose AI for docs is that it doesn’t know your codebase. You have to paste in the context every time, and even then it’s generating from what you gave it, not from what your code actually does.

GitDocAI reads your actual repository — function signatures, type definitions, OpenAPI specs, code comments — and uses that as the source of truth for the draft. The generated content is grounded in real implementation, not inference. That doesn’t eliminate the accuracy and context passes from your checklist, but it cuts the number of [VERIFY] flags substantially and means the code examples are based on how your library actually behaves, not how a library like it typically behaves.

The result is a first draft that’s closer to 80% done than 60% done — which, compounded across a backlog of unwritten pages, is a meaningful difference.

If you’re sitting on a backlog of undocumented features and a blank page is still the thing stopping you from starting, try GitDocAI. Connect your repo, generate a first draft from your actual code, and run the five editing passes. First page done in under an hour.

Keep reading