20 tested prompts across 4 stages. Works with ChatGPT, Claude, and Gemini.

Write clear, comprehensive documentation for your code — from inline comments to full API docs — using Cursor. This guide walks you through every stage of Cursor for Documentation, from Document existing code all the way through Maintain documentation, with a tested, copy-ready prompt at each step. Each stage targets a specific phase of the process so you always know exactly what to ask and what output to expect. Works with ChatGPT, Claude, and Gemini and any other major AI tool.
Stage 1
Start here to add clear, useful documentation to code that currently has none.
Add function documentation
Write documentation for this function using [JSDOC / PYTHON DOCSTRINGS / YOUR DOC FORMAT]: [PASTE FUNCTION]. Include: what it does, each parameter, the return value, and any exceptions it throws.
Document a class or module
Write comprehensive documentation for this [CLASS / MODULE]: [PASTE CODE]. Include: purpose, when to use it, key methods with their signatures, and a usage example.
Add inline comments
Add inline comments to the non-obvious parts of this code: [PASTE CODE]. Only comment the WHY (business logic, workarounds, non-obvious decisions) — not the WHAT (which the code already expresses).
Write a README section
Write a README section documenting how to use this module/API: [PASTE CODE OR DESCRIBE IT]. Include: purpose, quick start example, all available options, and a full example.
Document configuration options
Document all configuration options for this code: [PASTE CONFIG SCHEMA OR CODE]. For each option: name, type, default value, what it controls, and an example value.
Stage 2
These prompts help you write API docs that developers actually want to read and use.
Document REST endpoints
Write API documentation for these endpoints: [PASTE ROUTE DEFINITIONS]. For each endpoint: HTTP method, URL, description, request parameters, request body schema, response schema, and example request/response.
Document error responses
Document all error responses for this API: [PASTE ERROR HANDLING CODE]. For each error: HTTP status code, error code, error message, and what the caller should do in response.
Write authentication docs
Write documentation explaining how to authenticate with this API: [PASTE AUTH CODE OR DESCRIBE IT]. Cover: how to get credentials, how to include them in requests, and how to handle token expiry.
Generate OpenAPI schema
Generate an OpenAPI 3.0 schema (YAML format) for this API: [PASTE ROUTE DEFINITIONS AND TYPES]. Cover all endpoints, request/response schemas, and authentication.
Write SDK documentation
Write documentation for this SDK client: [PASTE SDK CODE]. Include: installation, initialization, all available methods with parameters and return types, and complete code examples.
Stage 3
Use these prompts to write guides that help developers get up to speed quickly.
Write a getting started guide
Write a "Getting Started" guide for this project/library: [PASTE README OR DESCRIBE THE PROJECT]. Walk a new developer from installation to their first working example in under 10 minutes.
Write a tutorial
Write a step-by-step tutorial for [SPECIFIC TASK] using this code: [PASTE RELEVANT CODE]. Target audience: [BEGINNER / INTERMEDIATE DEVELOPER]. Include code snippets at each step.
Write architecture docs
Write an architecture overview for this codebase: [DESCRIBE OR PASTE KEY FILES]. Explain: the main components, how they interact, key design decisions, and where to start when contributing.
Document the data model
Write documentation for this data model: [PASTE SCHEMA OR TYPES]. For each entity: what it represents, its fields with types and meanings, its relationships to other entities, and constraints.
Write a migration guide
Write a migration guide for upgrading from [VERSION A] to [VERSION B]. Cover: breaking changes, what needs to be updated in user code, new features to take advantage of, and a migration checklist.
Stage 4
These prompts help you keep docs accurate and useful as the codebase evolves.
Update docs after a change
I changed this function: [PASTE BEFORE AND AFTER CODE]. Update the documentation to reflect the change: [PASTE CURRENT DOCS]. What else might need updating elsewhere?
Audit docs accuracy
Compare this documentation to the actual code implementation and find any discrepancies: [PASTE DOCS AND CODE]. Flag anything outdated, missing, or incorrect.
Improve existing docs
Rewrite this documentation to be clearer and more useful: [PASTE CURRENT DOCS]. Add missing examples, clarify ambiguous descriptions, and remove unnecessary information.
Generate a changelog
Generate a user-facing changelog for these code changes: [PASTE DIFF OR DESCRIBE CHANGES]. Write it from the user's perspective: what they can now do, what broke, and what was fixed.
Write deprecation notices
Write deprecation notices for these APIs or features: [DESCRIBE WHAT IS BEING DEPRECATED]. Include: what is deprecated, why, when it will be removed, and what to use instead.
At minimum: a README with setup and usage instructions, inline documentation for public APIs, and a CHANGELOG. Good codebases also have architecture overviews, tutorials for common tasks, and documented decision records for major choices.
Lead with examples, not explanations. Show what the code does in 5 lines of working code before explaining how it works. Use headings so developers can scan. Keep the getting started path short and clearly marked.
Yes. Open a file in Cursor and use Composer or Cmd+K to generate documentation for selected functions, classes, or modules. It reads the implementation and produces accurate docstrings, README sections, or API docs.
Add documentation review to your code review process. When a PR changes a public API or module, require updated docs as part of the PR. Cursor can quickly update existing docs when you paste the changed code alongside them.
Comments explain why code does something surprising or non-obvious (for future maintainers). Documentation explains what an API does and how to use it (for consumers). Both are necessary; most code needs more of both.
AI Prompts for Cursor for Code Review
Code review is where most developers either speed through too fast or get lost in line-by-line nitpicking that misses bigger structural problems.
See promptsAI Prompts for Claude for SEO
SEO content that reads like it was written for search engines rather than humans ranks poorly and converts worse.
See promptsAI Prompts for ChatGPT for Technical Writing
Write clearer, more effective technical documentation, reports, and communications using ChatGPT..
See prompts