PromptDev

Write docstrings for code

A prompt for writing docstrings that document real behaviour and edge cases instead of just restating parameter names as prose.

Last updated

Fill in the blanks

Assembled in your browser — nothing you type is stored or sent anywhere.

Your prompt

Write docstrings for the code below in JSDoc style. For each function or class, document: what it does (behaviour, not implementation), the edge cases and error conditions it handles or explicitly doesn't, and any non-obvious side effect. Do not write a docstring that just restates the parameter names as prose — every parameter line must add information the signature doesn't already give: units, valid ranges, what an empty or null value means, or what happens if it's wrong. Skip any function that's already self-explanatory instead of padding it with a docstring that adds nothing. If a function's behaviour is ambiguous from the code alone, say what's unclear rather than guessing. Code: [paste the module or file here]

Model-agnostic — works in Claude, ChatGPT, Gemini or any AI chat.

Why this prompt works

  • Banning parameter-restating docstrings targets the default LLM failure directly: verbose, technically complete docstrings that add zero information over the function signature.
  • Asking specifically for edge cases and error conditions gets the part of a docstring that's genuinely hard to infer from a casual read — what happens at the boundaries.
  • Permission to skip self-explanatory functions keeps the output honest — blanket docstring coverage otherwise turns into noise that buries the functions that actually needed it.

Related in Prompts