Generating Documentation with Cursor
Cursor reads your code and generates documentation that reflects what the code does: READMEs, API docs, design documents, and architecture overviews. Codebase search helps it capture how components interact across your project, not only within open files.
READMEs and project documentation
Cursor can generate READMEs for new projects, update stale READMEs to match current code, or fill in gaps where documentation never existed. The generated docs pull from actual code paths, configuration files, and package dependencies rather than assumptions about how things should work.
For existing projects, ask Cursor to compare your README against the current codebase and identify what is out of date. This is often faster than reading through docs trying to spot inaccuracies.
Onboarding documentation
New developers spend significant time figuring out how things work: what services exist, how to run them locally, what the common workflows are. Cursor can generate onboarding docs that answer these questions directly from the codebase.
New developers can get up to speed faster when accurate documentation exists. See also Understanding Unfamiliar Code for how team members can use Cursor to explore the codebase directly.
Design documents from code
Sometimes you need to document the design of a system that was never formally designed. The implementation exists, but there is no spec explaining why it works the way it does.
This is useful when onboarding new team members, preparing for audits, or creating handoff documentation for enterprise customers. The design document captures the intent that is implicit in the code but not written down anywhere.
PRDs and specs for handoffs
Product documentation often needs to be generated from existing implementations, especially when handing off to other teams or creating customer-facing specs.
This works well when you need to document what was built for product managers, create Confluence pages for stakeholders, or generate Jira tickets that accurately reflect implementation details. See MCP integrations below for connecting Cursor to these external systems.
API documentation
API documentation drifts from implementation faster than almost any other docs. Cursor can compare your API docs against actual route handlers and flag discrepancies: endpoints that exist but are not documented, documented endpoints that no longer exist, and parameter mismatches.
For internal APIs, this comparison catches breaking changes before they surprise consumers. For external APIs, it ensures your public documentation matches what customers actually experience.
Keeping documentation current
Documentation drifts from code over time. Cursor can compare your docs against current implementation and flag what needs updating.
The most effective way to keep docs current is to make documentation part of your code review process. Add documentation checks to your Bugbot rules so missing or outdated docs get flagged automatically:
# Documentation checksWhen reviewing PRs:- If public API changes, require API docs update- If new features are added, require README updates- Flag outdated code comments that reference changed behavior- Require JSDoc on new exported functionsThis catches documentation debt at the source rather than letting it accumulate.
MCP integrations for documentation workflows
MCP integrations connect Cursor to external documentation systems. If your team uses Confluence, Notion, or similar tools, you can generate documentation and push it directly to where your team expects to find it.
Browse the Marketplace for integrations with Confluence, Jira, Notion, and other documentation platforms. With these connected, you can:
- Generate a design doc and create a Confluence page in one workflow
- Create Jira tickets from implementation details
- Keep external documentation in sync with code changes
This is especially valuable for enterprise teams where documentation lives outside the repository.
Documentation for compliance and audits
Enterprise customers and regulated industries often require formal documentation of systems: how data flows, what security controls exist, how access is managed.
Cursor can trace through your actual implementation to generate documentation that auditors need, grounded in what the code does rather than what a policy document claims it does.
Setting up documentation conventions
Use rules files to ensure consistent documentation across your project.
Create a .cursor/rules/documentation.mdc file:
# Documentation Conventions## READMEs- Use sentence case for headings- Include a "Quick Start" section that gets someone running in 5 minutes- Code examples should be complete and runnable## Code comments- Use JSDoc for all exported functions- Document "why" not "what" in inline comments- Don't comment obvious code## API documentation- Use OpenAPI 3.0 format- Include example requests and responses- Document error responses, not just success casesGetting started
-
Start with what is missing. Ask Cursor what documentation your project needs. It will identify gaps based on the code.
-
Generate from code, then edit. The first draft will be accurate but may lack context only you have. Add the "why" that is not obvious from implementation.
-
Set up documentation rules. Specify your conventions so generated docs are consistent.
-
Connect external systems. Use MCP integrations to push documentation to Confluence, Notion, or wherever your team reads docs.
-
Make docs part of code review. Add Bugbot rules so documentation updates are flagged when code changes.