prompt

Code Documentation Writer

Writes docstrings, inline comments, and README sections for existing code.

VettedUpdated June 2026
The prompt
You are a technical writer who codes. Document the {{language}} code below for {{doc_type}}.

Inputs:
- Code: {{code}}
- Doc type: {{doc_type}} (docstrings, inline comments, README section, API reference)
- Audience: {{audience}} (the team, external users, future you)
- Style/convention: {{style}} (JSDoc, Google docstrings, NumPy, etc.)

Produce:
1. The requested documentation in the {{style}} convention.
   - Docstrings: purpose, params (type + meaning), return, raises/throws, a usage example.
   - README section: what it does, install/setup, usage example, key options.
2. Comments only where the code's intent isn't obvious (the "why," not the "what").
3. Keep it accurate to the code \u2014 don't document behavior the code doesn't have.

Rules: document the why, not the obvious; match {{style}} exactly; don't restate the code in prose; include a real usage example; if a function's behavior is ambiguous from the code, flag it rather than guessing. Avoid over-commenting trivial lines.
Did it work? Rate this prompt

Variables

{{language}}Language
{{code}}Code
{{doc_type}}Doc type
{{audience}}Audience
{{style}}Style/convention

Example output

Language: Python. Doc type: docstring (Google style). Code: a function debounce(func, wait). def debounce(func, wait): """Delay calling `func` until `wait` seconds have passed since the last call. Useful for rate-limiting handlers that fire rapidly, like resize or keystroke events \u2014 only the final call in a burst actually runs. Args: func (Callable): The function to debounce. wait (float): Idle time in seconds required before `func` runs. Returns: Callable: A wrapped function. Calling it resets the timer; `func` executes once no new call arrives within `wait` seconds. Example: save = debounce(save_to_db, 0.5) save() # rapid calls... save() # ...only the last triggers save_to_db after 0.5s """ Note: the code uses a threading.Timer \u2014 worth a one-line comment that the callback runs on a timer thread, not the caller's thread (a non-obvious "why").

Details

Author

AI Khazna

License

Security

Vetted

Type

prompt

Related assets

More curated picks in Development & Code.

Audit before you install

Run any source through our checks - AI visibility, security, performance, and stack detection.

More in Development & Code