📚

Technical Documentation Writer

Writes reference or how-to documentation from code, keeping the two kinds of document separate.

✍️ Writing Intermediate Claude ChatGPT Cursor

The prompt

Write documentation for the code below. First decide which kind of document is needed, because mixing them is why most documentation is hard to use:

- **Reference** — complete, precise, organised by the shape of the code. Read when you know what you want.
- **How-to** — a single task start to finish, organised by the user goal. Read when you have a problem.
- **Explanation** — why it works this way. Read when the behaviour is surprising.

Say which you are writing and why, then write only that one.

For **reference**, per function or endpoint:
- One sentence on what it does. Not a restatement of the name.
- Every parameter: type, whether required, default, valid range, and what an invalid value does.
- Return value, including the shape on both success and failure.
- Every error it can raise, and what the caller should do about each.
- One runnable example with realistic values, not foo and bar.
- Preconditions and side effects.

For **how-to**:
- The goal, stated as the reader would state it.
- Prerequisites, including anything that must already exist.
- Numbered steps, each one action with its expected result.
- How to tell it worked.
- The two or three ways this commonly fails, and the fix for each.

Rules throughout: document behaviour you can see in the code, not behaviour you expect. Where the code and its name or comments disagree, document the code and flag the discrepancy separately. If something is unclear from the source, write TODO and the question rather than inventing an answer.

---
Document type wanted (or let me choose): [reference / how-to / explanation]
Code:
[PASTE YOUR CODE HERE]

Replace everything in [SQUARE BRACKETS] before you run it. The bracketed fields are not optional — they are what the output is built from.

Why this prompt is built this way

The opening move — decide which kind of document is needed, then write only that one — is the most useful idea in the prompt, and it is lifted from a well-established four-way split in documentation practice. Reference, how-to and explanation answer different questions, are read in different states of mind, and are organised on different principles: reference by the shape of the code, how-to by the user's goal.

Mixing them is why most README files are frustrating. A reader hunting one parameter default has to wade through a getting-started tutorial, and a beginner following the tutorial keeps hitting exhaustive parameter tables. Neither reader is served, and both think the documentation is bad without being able to say why.

The reference checklist is deliberately exhaustive on the parts people omit: what an invalid value does, the shape on failure as well as success, and what the caller should do about each error. Those three are the difference between documentation that answers questions and documentation that restates signatures.

"One runnable example with realistic values, not foo and bar" is a small instruction with outsized effect — a realistic example often teaches the parameter semantics faster than the parameter table does.

The closing rules are what make the output trustworthy: document the code rather than your expectation of it, flag disagreements between code and name, and write TODO instead of inventing an answer.

What to use it for

  • API reference pages
  • README files
  • Onboarding guides
  • Documenting inherited code

Adapting it to your situation

  • Choose the document type yourself when you already know. Letting it choose is useful when you are unsure why the existing docs are not working.
  • Paste the type definitions or schema alongside the code. Parameter documentation is only as precise as the types available.
  • Add your documentation site's conventions — heading levels, admonition syntax, code-fence language tags — so the output drops in without reformatting.
  • Run it per module, not per repository. Reference quality falls off sharply with breadth.

Where this goes wrong

Every TODO must be resolved before publishing. They are the honest markers of what the model could not determine, and shipping them is worse than shipping nothing, because they look like oversights rather than open questions.

Treat the flagged discrepancies between code and comments as bugs to investigate, not as text to tidy. If a function's name and behaviour disagree, documenting the behaviour is correct and fixing the disagreement is better.

Which model to run it on

Cursor is the strongest here because it can read the actual call sites and type definitions rather than relying on what you pasted. Claude handles long reference output without drifting; ChatGPT is fine for a single function.

Practical tips

The split between reference and how-to is the whole value here. Most README files fail because they try to be both, so the reader hunting a parameter wades through a tutorial. The instruction to flag rather than invent is what keeps the output trustworthy.