NestJS API Endpoint Extractor & Documentation Generator Prompt#
If you are working with a medium or large NestJS backend, endpoint visibility becomes difficult very quickly. Teams need a reliable way to extract explicitly defined APIs from controllers and present them in a clean, audit-friendly format.
This guide gives you a copy-ready prompt to generate structured module-wise API documentation using Cursor AI, with strong accuracy rules for real-world codebases.
Draft, improve, and version your prompt templates in CreateMarkdown.xyz Editor.
Why This Prompt Is Useful for NestJS Teams#
This prompt focuses on what matters for API governance and delivery:
- explicit route handlers only
- module-level grouping
- guard-aware access classification
- method and access breakdown summaries
It is useful for onboarding, security review, QA test planning, and stakeholder documentation.
Prompt Quality Tips for Better Documentation Output#
Before running the prompt, keep these best practices in mind:
- Ask the model to scan only controller decorators, not services.
- Require merged guard detection across controller and method levels.
- Enforce "no assumptions" to avoid invented routes.
- Request standardized markdown tables for each module.
- Include final summary metrics for tracking and review.
Copy-Ready Prompt: NestJS API Endpoint Extractor & Documentation Generator#
Use this prompt exactly, then adapt naming or constraints if needed.
# NestJS API Endpoint Extractor & Documentation Generator
## Role & Context
You are a senior NestJS code analyst working inside a Cursor IDE environment with access to the full codebase. Your task is to analyze the project and generate structured API documentation by extracting all explicitly defined endpoints from the code.
## Task
Scan the entire NestJS project and extract all API endpoints defined using NestJS decorators. Organize them module-wise and present them in a structured Markdown format along with metadata such as method, route, guards, and access level.
## Instructions
1. **Scan the Codebase**
- Traverse all modules and locate files containing `@Controller()` decorators.
- Within each controller, identify all route handlers using:
- `@Get()`, `@Post()`, `@Put()`, `@Patch()`, `@Delete()`, `@Options()`, `@Head()`
- Ignore any dynamically generated or inherited endpoints - only include explicitly defined ones.
2. **Extract Endpoint Details**
For each endpoint, extract:
- **HTTP Method** (GET, POST, etc.)
- **Route Path**
- Combine controller-level path (`@Controller('...')`) with method-level path
- Preserve dynamic params like `:id`
- **Module Name**
- Determine based on the module where the controller is declared
- **Guards Applied**
- Extract from `@UseGuards(...)` at both controller and method level
- **Description (if available)**
- From decorators like `@ApiOperation`, comments, or JSDoc
3. **Determine Access Level**
- If **no guards are applied** -> mark as `Public`
- If **any guard is applied** -> mark as `Private`
- If both controller-level and method-level guards exist -> merge them
4. **Group Data**
- Group endpoints **module-wise**
- Within each module, list endpoints in a table
5. **Generate Output Tables**
For each module, create a Markdown table:
| Method | Route | Guards | Access | Description |
|--------|-------|--------|--------|-------------|
6. **Final Summary Section**
At the end of the document, include:
- **Total API Count**
- **Module-wise API Count**
- **Method-wise Count** (GET, POST, etc.)
- **Access Breakdown**
- Public APIs count
- Private APIs count
7. **Accuracy Rules**
- Do NOT assume or infer endpoints
- Do NOT include commented-out code
- Do NOT include Swagger-generated or implicit routes
- Only include endpoints explicitly declared in controllers
## Output Format
- Use **Markdown format only**
- Structure:
- `## Module: <Module Name>`
- Followed by table
- Repeat for all modules
- End with `## Summary`
## Tone & Style
- Technical and concise
- Clean, readable Markdown
- No unnecessary explanations
- Focus on structured documentation output
## Constraints & Exclusions
- Do NOT include inferred or auto-generated endpoints
- Do NOT include services, providers, or non-controller logic
- Do NOT guess missing metadata
- Do NOT include duplicate endpoints
- Do NOT include internal NestJS routes
- Do NOT modify or rewrite any code
- Only analyze what is explicitly present in the codebase
## Example (Optional)
### Module: User
| Method | Route | Guards | Access | Description |
|--------|-------------|--------------|--------|----------------------|
| GET | /users | AuthGuard | Private | Get all users |
| POST | /users | None | Public | Create new user |
| GET | /users/:id | AuthGuard | Private | Get user by ID |
## Summary
- Total APIs: 3
- Module-wise Count:
- User: 3
- Method-wise Count:
- GET: 2
- POST: 1
- Access Breakdown:
- Public: 1
- Private: 2SEO and Publishing Notes#
When publishing this as an internal or external documentation guide:
- include "NestJS API documentation" and "endpoint extractor" in headings naturally
- keep table format consistent across modules for quick scanning
- cross-link related backend and architecture content
- keep slugs concise and intent-focused
- update sitemap whenever new prompt guides are added
For quick markdown formatting and clean exports, use CreateMarkdown.xyz Editor.
Related Guides#
Related posts

Business Documentation Prompt for Next.js Projects (Stakeholder-Ready)
Create stakeholder-ready documentation from a Next.js codebase using a business documentation prompt. Learn how to map modules, routes, features, and access flows with SEO-friendly output.

Next.js Project Analyzer Prompt: Generate Business-Oriented Documentation Fast
Use this Next.js project analyzer prompt to generate domain-focused documentation from your codebase. Includes a copy-ready prompt for Cursor AI and SEO-focused best practices.