Back to guide/Developer Tools

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.

github-copilot-vs-cursormodule_or_componentsource_filesdoc_format
Edit View
Prompt
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

{{module_or_component}}{{source_files}}{{doc_format}}{{audience}}

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.