Write Clear Technical Documentation
Generate complete Markdown technical docs with params, examples, and error handling.
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.
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]
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.
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.
Adapt it for your case
For an endpoint, ask it to add request/response JSON schemas, status codes, and an example curl command.
Reframe the request as a 5-minute getting-started doc that wires the module into a fresh project end to end.
Paste the old docs plus a diff and ask it to update only what changed, preserving existing prose.
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.
You may also need
Refactor a long, tangled function into smaller, testable units
Breaks an overgrown function into smaller, single-responsibility units while preserving behavior and the public signature.
Write clear API reference docs straight from source code
Generates accurate API reference documentation from source code without inventing behavior, flagging ambiguities.
Explain Complex Code in Simple Terms
Turn confusing code into a clear, junior-friendly explanation with edge-case notes.
Translate Code From One Language to Another
Convert code between programming languages while using idiomatic patterns in the target language.