Text & chat prompt
Add helpful comments and docstrings to code
Add helpful comments and docstrings to code: a free, copy-paste prompt for ChatGPT, Gemini and Claude. Paste the prompt and replace each [BRACKETED] field with your own details.
The prompt
Add clear comments and docstrings to this code: [PASTE CODE] Explain why decisions were made, not what each line does. Document parameters, return values, side effects and exceptions. Flag anything confusing or risky without changing the logic, and list any names you would rename.
Pro tip: Ask it to explain why, not what; comments that repeat the code are noise.
How to use this prompt
- Open ChatGPT and start a new chat.
- Paste the prompt.
- Replace each [BRACKETED] field with your real details and paste in your own text where asked.
- Reply with follow-ups such as "make it shorter" or "make it sound more like me".
Prompt at a glance
- Category
- Text & chat
- Works with
- ChatGPT · Gemini · Claude
- Length
- 44 words
- Fields to fill in
- PASTE CODE
- Last updated
Frequently asked questions
Which AI tools work with this prompt?
It is written for ChatGPT, Gemini and Claude. Paste it into your preferred tool and adjust the wording if the result is off.
What do I need to fill in?
Replace the field before you send it: PASTE CODE. Each field shows an example in the prompt.
Should I paste private information into the prompt?
Only what the task needs. Remove names, contact details and other sensitive data before pasting a resume or document into any AI tool.