← IndexEntry № 030·coding

Write Clear Technical Documentation

Generate complete Markdown technical docs with params, examples, and error handling.

Optimized for
ClaudeChatGPT
§ When to use this

This prompt turns a function, module, or API into reference documentation that an engineer can actually use without reading the source. It enforces the parts developers reach for first — an overview that says when to use it, a typed parameters table, return semantics, runnable examples, and a troubleshooting section. Pasting the actual code (rather than describing it) lets the model infer types, defaults, and error paths instead of guessing.

§ The Prompt— fill in the fields, then copy or open in a tool
§ Customize0/2 fields filled
your prompt — fill the fields above
You are a technical writer embedded in an engineering team. Write documentation for [FUNCTION / MODULE / API]. Include: (1) a one-paragraph overview of what it does and when to use it, (2) parameters table with name, type, required/optional, and description, (3) return value description, (4) at least 2 usage examples with code, (5) common errors and how to resolve them. Use Markdown format.

CODE OR DESCRIPTION:
[PASTE CODE OR DESCRIPTION]
Open with your prompt →ChatGPTClaudeSends your filled-in prompt straight into a new chat.
§ Example Output

What you can expect back

## parseInvoice()

Parses a raw invoice string into a structured `Invoice` object. Use it when ingesting invoices from email or upload before persisting them. It is synchronous and validates currency against the supported list.

### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `raw` | string | Yes | The raw invoice text to parse. |
| `opts.currency` | string | No | ISO 4217 code; defaults to `USD`. |
| `opts.strict` | boolean | No | When true, rejects unknown line-item fields. |

### Returns
An `Invoice` object with `id`, `total`, `lineItems[]`, and `currency`.

### Examples
```ts
const inv = parseInvoice(rawText);
const strictInv = parseInvoice(rawText, { currency: 'EUR', strict: true });
```

### Common errors
- `InvoiceParseError`: malformed input — verify the raw string isn't truncated.
- `CurrencyError`: pass a supported ISO 4217 code in `opts.currency`.

Illustrative example — your results will vary by tool and inputs.

§ Pro Tips

Get sharper results

  • 01Paste the real signature and any thrown-error types so the params table and troubleshooting reflect the actual contract rather than plausible-sounding fiction.
  • 02Tell it your audience level ('internal team familiar with our stack' vs 'public API consumers') so it calibrates how much it explains.
  • 03Ask for one example covering the happy path and one covering an edge case or optional parameter, so the docs show range rather than two near-identical snippets.
  • 04Have it mark anything it inferred but couldn't verify with a 'TODO: confirm' note, so you don't ship a confidently wrong default value.
  • 05Request the examples in your project's exact language and import style so engineers can copy-paste without rewriting.
§ Variations

Adapt it for your case

OpenAPI-flavored REST docs

For an endpoint, ask it to add request/response JSON schemas, status codes, and an example curl command.

Quickstart guide

Reframe the request as a 5-minute getting-started doc that wires the module into a fresh project end to end.

Changelog-aware update

Paste the old docs plus a diff and ask it to update only what changed, preserving existing prose.

Best For — Roles
Use For — Tasks
Tags#docs#technical-writing#engineering
§ FAQ

Common questions

Should I paste code or just describe it?

Paste code whenever you can — the model derives accurate types, defaults, and error cases from it. Use a description only when the code is unavailable or proprietary.

Will the usage examples actually run?

They're illustrative and should be tested before publishing; ask the model to use only the parameters present in the signature to reduce drift.

Can it match our existing docs style?

Yes — paste one or two existing doc pages as a style reference and ask it to mirror the headings, voice, and formatting conventions.

§ Related Entries

You may also need