Generate precise documentation for an undocumented function
Undocumented functions slow down every engineer who touches them later. This prompt generates accurate, specific documentation — not boilerplate — by reasoning through what the code actually does before writing a single word.
You are a technical writer with strong engineering skills. I have a function with no documentation and I need you to produce accurate inline documentation for it.
Language and doc format: {{LANGUAGE_AND_DOC_FORMAT}} (e.g. TypeScript + JSDoc, Python + Google docstring style, Java + Javadoc)
Function code:
```
{{FUNCTION_CODE}}
```
Caller context (optional — paste a usage example if you have one):
{{CALLER_CONTEXT}}
Follow these steps:
1. Read the function and describe in plain English what it does, in two sentences maximum. Focus on what it produces, not how.
2. Identify every parameter: its name, type, what values are valid, and what happens if an invalid value is passed.
3. Identify the return value: its type and what it represents. If it can return different types or shapes depending on input, document each case.
4. Identify all side effects: network calls, file I/O, mutations to external state, thrown exceptions.
5. Note any non-obvious behavior: magic numbers, special-case inputs, ordering dependencies.
6. Write the final documentation block in the specified format. Every parameter and return value must be documented. Do not write vague descriptions like 'the input value' — be specific about what the value represents.
If the function's behavior is genuinely ambiguous from reading the code alone, flag the ambiguity rather than guessing. {{LANGUAGE_AND_DOC_FORMAT}}{{FUNCTION_CODE}}{{CALLER_CONTEXT}}
How to use this prompt
- Copy the prompt above (Copy button on the top-right).
- Replace each
{{VAR}}with your own value. Variables:{{LANGUAGE_AND_DOC_FORMAT}}{{FUNCTION_CODE}}{{CALLER_CONTEXT}}. - Paste it into one of the recommended tools below.
- Iterate: tighten constraints in the prompt if the output is generic.
Why this prompt is structured this way
The prompt is split into explicit steps because LLMs do better when the path is named, not implied. Each variable forces specificity at the input layer — vague inputs get vague outputs.
Pair this prompt with a tool
Grammarly
$12/moGrammar, tone, and clarity across every app.
Grammarly remains the default for grammar + tone checking. The 'Grammarly Go' generative features are catching up but are not the main reason to subscribe.
Cursor
$20/moAI-first code editor forked from VS Code.
Cursor is VS Code with first-class LLM integration. Multi-file edits, codebase Q&A, autocomplete that's actually useful. The default IDE for many shipping engineers in 2026.
Claude (Anthropic)
$0/mo (Pro at $20)Frontier model with long context and strong reasoning.
Claude (Opus / Sonnet / Haiku tiers) is the assistant favored by writers and engineers who care about reasoning quality and tone. 1M token context on Opus.
ChatGPT (OpenAI)
$0/mo (Plus at $20)The category-defining general-purpose AI assistant.
ChatGPT has the broadest feature surface: image gen, voice, custom GPTs, web browsing, code execution. Often the right default; sometimes beaten on specific tasks by Claude or Perplexity.
The PlaybookPrompts weekly
One short email per week. The five sharpest prompts we found, one tool worth your attention, one anti-pattern to avoid. Unsubscribe in one click.
Newsletter signup is not configured. Set PUBLIC_NEWSLETTER_USERNAME in the build env.