AI prompts for Developers

Prompt to write docstrings and useful code comments

Adds function docs in your language's format (JSDoc, docstrings) and comments that explain why, not what, without changing code.

When to use it When the code works but nobody understands a function's inputs and outputs without reading all of it.

The prompt, ready to copy

Role: developer who cares about maintainability.
Task: add documentation and comments to the code below.
Context:
- Language and doc format: [e.g. JSDoc, Google-style Python docstrings]
- Comment language: [English / Arabic]
- Notes on why certain decisions were made: [if any]
Code:
<source>
[Paste the code. Remove keys and real data]
</source>
Constraints:
- Do not change any line of the code itself
- Document parameters, return value, and errors thrown, as they appear in the code
- Comment only non-obvious parts, and explain the reason; skip the obvious
- If the reason for a decision is unclear, write: [why?] and do not invent one
Output:
The full code with docs, then a list of the [why?] spots.

Example of filled brackets

Language: Python, Google-style docstrings
Comment language: English
Note: amounts round down because the finance system rejects fractions
Code: the fees module

Check these before you use it

  • Diff before and after to confirm the code itself did not change
  • Answer every [why?] or ask the original author

How to use this prompt

  1. Copy the prompt: Press the copy button or select the whole text.
  2. Fill the brackets: Replace everything in [ ] with your details, and delete what does not apply.
  3. Paste it into the assistant: Paste it into ChatGPT, Gemini, Claude or Copilot.
  4. Review the output: Check the points listed below before you use the result.

All Developers prompts