Perplexity Documentation Prompt Template
You get documentation a newcomer can follow on the first try: what it is, how to install it, how to use it, with working examples. This version is set up for Perplexity: state the time frame, region and kind of sources you trust, since Perplexity searches the web for each answer. Below you'll find the prompt, how to run it in Perplexity, a worked example and answers to common questions.
Write documentation for the code or tool below. ## What it is Name: [project or module name] What it does: [one or two sentences] Who reads this: [e.g. developers new to the project, external API users] ## Source material [paste the code, CLI help output, config options, or function signatures] ## Document type [README, API reference, docstrings, or a how-to guide] ## Instructions - Start with what it does and why someone would use it, in two sentences. - Show a working example before explaining every option. - Every command and code sample must match the source material exactly. Do not invent flags, options or defaults. - Use short sections and plain language. - If something important is unclear from the source, list it as a question at the end instead of guessing. ## Output format Markdown with: overview, install, quick start, options or API, examples, and open questions. Context - Time frame and region: [e.g. 2024 onward, United States] - Sources to prefer: [e.g. official docs, peer-reviewed studies]
How to use this prompt
- 1
Open Perplexity
Paste the prompt into Perplexity's search box.
- 2
Give it context
State the time frame, region and kind of sources you trust, since Perplexity searches the web for each answer.
- 3
Review and iterate
Use follow-up questions in the same thread and open the cited sources to check key claims.
- 4
Save what you repeat
Group related research in a Space so follow-ups stay together.
Working in Perplexity
- •Answers come with citations. Click through on any number or claim you plan to reuse.
- •Perplexity is search-first, so phrase the main request as a clear question and keep formatting rules short.
- •Name sources to prefer or avoid (for example official docs, peer-reviewed papers) to steer what it finds.
Worked example
What you give it
Name: csvtidy What it does: a command line tool that trims whitespace from every cell in a CSV and removes empty rows. Readers: developers on my team. CLI help: csvtidy <input> [-o output] [--keep-empty] -o, --output write to a file instead of stdout --keep-empty do not remove empty rows Install: npm install -g csvtidy Type: README
What a good answer looks like (shortened)
# csvtidy csvtidy cleans CSV files by trimming whitespace in every cell and removing empty rows. Use it before importing exported spreadsheets. ## Install npm install -g csvtidy ## Quick start csvtidy contacts.csv -o contacts-clean.csv ## Options - -o, --output: write to a file instead of printing to stdout - --keep-empty: keep empty rows instead of removing them ## Examples Print the cleaned file to the terminal: csvtidy contacts.csv ## Open questions - What happens if the output file already exists? - Does it handle quoted cells that contain commas?
Tips for better results
- •Paste the actual help output or signatures into Source material. Documentation that drifts from the code is worse than none.
- •Read the open questions at the end. They are usually the gaps a new user would hit, so answer them in the doc.
- •Name sources to prefer or avoid (for example official docs, peer-reviewed papers) to steer what it finds.
- •Avoid this: Asking for documentation without naming the reader, which produces text that is too basic for maintainers or too dense for new users.
Get the free prompt pack
Our best coding prompts in one Markdown file, delivered by email. The templates here stay free either way — the pack just saves you the copying.
Variations
Docstrings
Change Document type to docstrings and add: Use [Google, NumPy or JSDoc] style, with params, return value and raised errors for each function.
API reference
Replace Source material with your route handlers and add: For each endpoint, show method, path, parameters, an example request and an example response.
Changelog entry
Replace Document type with: A changelog entry for version [x.y.z] from this diff [paste], grouped as Added, Changed, Fixed.
Save it as a Retext snippet
Retext is a free text expander for Mac. Save this prompt once, then type ;writedocs in any app (ChatGPT, Claude, your editor, a browser tab) and the full prompt is pasted in.
- Click Add to Retext. The prompt installs as a snippet with the trigger ;writedocs.
- Change the trigger in Retext if you prefer a different one.
- Type the trigger wherever you want the prompt, then fill in the brackets.
Frequently asked questions
How do I keep AI-written docs accurate?
Give it the real source, help text or signatures and tell it not to invent options. Then run every example yourself before publishing.
How do I check the answer?
Open the cited sources for each claim you plan to use. If a claim has no citation, ask a follow-up for one.
Should documentation explain every option?
Lead with a working quick start, then list options. Most readers want to run one example first and come back to the full reference only when they need it.
How do I reuse this prompt without copying it every time?
Click Add to Retext to save it as a snippet. Then type ;writedocs in any Mac app, including your AI tool, and the full prompt is pasted in.
Related Templates
Get the free prompt pack
Our best coding prompts in one Markdown file, delivered by email. The templates here stay free either way — the pack just saves you the copying.