wowprompt

Docstrings and code comments for a pasted module

Adds clear docstrings and comments to a file in the language's standard style, explaining what each function does and why, without changing any code. Use it before a pull request, a handover or open-sourcing a project.

The same module with docstrings for every public function and class and comments on non-obvious lines, plus a list of places where the code behaviour was unclear
The output this prompt produced, unedited.

The prompt

Goal

A file a new developer can understand without asking the author, with documentation fit for a public repository.

Inputs

  • Language and docstring style: [e.g. Python with Google style, TypeScript with TSDoc, Java with Javadoc, PHP with PHPDoc]
  • Code: [paste the module]
  • What the module is for: [one or two lines]
  • Audience: [team members, open-source contributors, or both]

Steps

  1. Write a module-level summary: what the file provides and how it fits in.
  2. For every public function, method and class, write a docstring with a summary, parameters, return value, errors raised and a short example where useful.
  3. Add inline comments only where the reason for the code is not obvious, such as a workaround, a performance choice or a business rule.
  4. Remove or rewrite comments that are wrong, outdated or that only repeat the code.

Output format

  • The full module with documentation added, in one code block.
  • | Function | What was documented | Notes |
  • Questions for the author: places where the intent is unclear or the behaviour looks like a bug.

Check before answering

  • Not a single character of executable code is changed, including formatting.
  • Comments explain what and why, never repeat the line ("increment i").
  • Comments contain no names of people, internal tickets, credentials, server names or private URLs.
  • Types and parameter names in docstrings match the code exactly.
code documentationdocstringscode commentsjsdocpython docstringdocument code

How to run this

Copy the prompt and paste it into Gemini, then set the aspect ratio to 3:4. No reference photo is needed for this one.

The prompt is written in Markdown with each part under its own heading, which is what the copy action hands over. Change one section at a time, keeping the rest intact, so you can tell which change did the work.

Related prompts

All productivity