PlaybookPrompts

Generate precise documentation for an undocumented function

Coding & Development documentationcode-qualitydeveloper-experience

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.

Prompt
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.
Variables to fill in
  • {{LANGUAGE_AND_DOC_FORMAT}}
  • {{FUNCTION_CODE}}
  • {{CALLER_CONTEXT}}

How to use this prompt

  1. Copy the prompt above (Copy button on the top-right).
  2. Replace each {{VAR}} with your own value. Variables: {{LANGUAGE_AND_DOC_FORMAT}}{{FUNCTION_CODE}}{{CALLER_CONTEXT}}.
  3. Paste it into one of the recommended tools below.
  4. 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.

Heads up: some of the links on this page are affiliate links — meaning we may earn a commission if you sign up after clicking, at no extra cost to you. We only recommend tools we'd put on our own stack. You can see our full affiliate disclosure here.

Pair this prompt with a tool

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.