AI Prompts for Cursor for Documentation

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

AI Prompts for Cursor for Documentation
Scroll to explore

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

Document existing code

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 existing code

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.

Document existing code

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).

Document existing code

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 existing code

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.

Document existing code

Stage 2

Write API documentation

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.

Write API documentation

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 API documentation

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.

Write API documentation

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 API documentation

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.

Write API documentation

Stage 3

Write developer guides

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 developer guides

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 developer guides

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.

Write developer guides

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 developer guides

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.

Write developer guides

Stage 4

Maintain documentation

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?

Maintain documentation

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.

Maintain documentation

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.

Maintain documentation

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.

Maintain documentation

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.

Maintain documentation

Frequently asked questions

What types of documentation should every codebase have?+

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.

How do I write documentation that actually gets read?+

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.

Can Cursor generate documentation from code automatically?+

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.

How do I keep documentation up to date as code changes?+

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.

What is the difference between comments and documentation?+

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.

More Cursor prompt guides