Coding · Free prompt
AI prompt for documenting code
Bad code comments just restate the code. Good ones explain why it exists and what to watch out for. This prompt documents your code the useful way, capturing intent and edge cases, not just the obvious.
Copy this prompt
You are a senior engineer who writes documentation other developers actually thank you for.
Document the code below.
CODE:
[PASTE YOUR CODE]
LANGUAGE / STYLE: [e.g. Python docstrings, JSDoc, plain comments]
Do this:
- Add a summary that explains what this does and, more importantly, why it exists.
- Document parameters, return values, and anything that can throw or fail.
- Add short inline comments only where the logic is non-obvious. Do not comment the obvious.
- Note any edge cases, assumptions, or gotchas a future reader should know.
Rules:
- Do not restate the code in words ("increment i by 1"). Explain intent.
- Do not change the code itself. Only add documentation.
Return the fully documented code.Paste it into ChatGPT, Claude, or Gemini and replace the text in [SQUARE BRACKETS] with your own details.
Why this prompt works
- 01
It targets the "why", which is the part that actually saves the next developer time.
- 02
Telling it not to comment the obvious avoids the noise that makes people ignore comments entirely.
- 03
"Do not change the code" keeps it a documentation task, so nothing breaks silently.
How to adapt it
- -Name your doc style (JSDoc, docstrings) so the output drops straight into your codebase.
- -Check the "gotchas" it lists. Sometimes it spots a real edge case you had not considered.
- -For a whole file, do the trickiest function first. That is where good docs matter most.
Frequently asked questions
Why does this document code prompt work better than a basic one?
It targets the "why", which is the part that actually saves the next developer time.
How do I adapt this prompt for my own situation?
Name your doc style (JSDoc, docstrings) so the output drops straight into your codebase.
Is this prompt free, and does it work with Claude and Gemini as well as ChatGPT?
Yes on both. The prompt is completely free to copy, and it is model-agnostic - it produces strong results in ChatGPT, Claude, and Gemini. Paste it into any of them.
Want this tuned to your exact situation?
A template gets you started. Deepclario takes your version of a prompt, scores it, asks what is missing, and rewrites it for your specific task. Free, no account needed.
Improve my prompt freeMore coding prompts