prompt
Code Documentation Writer
Writes docstrings, inline comments, and README sections for existing code.
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.
Variables
{{language}}Language{{code}}Code{{doc_type}}Doc type{{audience}}Audience{{style}}Style/conventionExample 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
Frequently asked questions
What is the Code Documentation Writer prompt?
Writes docstrings, inline comments, and README sections for existing code.
Is Code Documentation Writer free?
Yes, it is free to use.
Related assets
More curated picks in Development & Code.
Refactors code for readability and structure while preserving behavior, with rationale.
Turns a bug report into a structured debugging plan with hypotheses and checks to isolate the cause.
Reviews a code diff or snippet for bugs, security, readability, and edge cases.
Generates unit tests for a function, including edge cases and failure paths.
Writes a clear PR description with summary, changes, testing, and review notes from a diff or change list.
Generates a production-ready, optimized Dockerfile for a given stack.
Audit before you install
Run any source through our checks - AI visibility, security, performance, and stack detection.
AI Agent / MCP Server Tester
ai testing
Automated Web Security Scan
security
AI Content Quality Test
arabic content
Site Stack Detector
migration
PageSpeed Analyzer
performance
AI SEO / AEO / GEO Audit
ai visibility
llms.txt Generator
ai visibility
Schema / JSON-LD Builder
ai visibility
Readability Score
arabic content
AI Cost Calculator
ai testing
Headline Analyzer
arabic content