Documentation from Code
Copilot can read open files for context. Cursor's @codebase index finds real usage patterns across the project. The 'search for import statements' instruction produces documentation based on actual usage, not assumed usage.
Generate documentation for {{module_or_component}} by reading the source code. Files to read: {{source_files}} Documentation format: {{doc_format}} Audience: {{audience}} Generate: **1. Overview** (one paragraph) What this module does, when to use it, and what problem it solves. **2. Quick Start** Minimal working example with realistic data (not "foo" and "bar"). Show the import, basic usage, and expected output. **3. API Reference** For each exported function/component/type: - Signature with types - Description (what it does, not how — implementation details go in code comments) - Parameters table: name | type | required | default | description - Return value description - Example usage **4. Common Patterns** 3-5 real-world usage patterns with code examples, based on how the module is actually used in the codebase (search for import statements to find real usage). **5. Gotchas** Things that aren't obvious from the API — side effects, performance considerations, common mistakes. Do not document private/internal functions. If a function's purpose is unclear from its name and types, flag it as [NEEDS CLARIFICATION] rather than guessing.
Variables to customize
Why this prompt works
Copilot can read open files for context. Cursor's @codebase index finds real usage patterns across the project. The 'search for import statements' instruction produces documentation based on actual usage, not assumed usage.
Save this prompt to your library
Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.
Related prompts
Get thorough code reviews with actionable feedback tailored to your language, framework, and standards.
Context-Aware Code CompletionProviding the surrounding code and project context lets the model match existing patterns exactly. The constraint against modifying existing code prevents unwanted side effects.
Inline Code SuggestionConstraining suggestions to match existing style and scope produces insertions that feel native to the codebase. The 'no explanation' rule mimics real inline completion behavior.
Code ExplanationThe audience level parameter adjusts complexity automatically. Requiring a usage example ensures the explanation is practical, not just theoretical.