api-doc-generator
npx skills add https://github.com/partme-ai/full-stack-skills --skill api-doc-generator
Agent 安装分布
Skill 文档
When to use this skill
CRITICAL: This skill should ONLY be triggered when the user explicitly mentions generating API documentation, creating API docs, scanning interfaces, or documenting APIs.
ALWAYS use this skill when the user mentions:
- Generating API documentation (explicitly mentions “API documentation” or “API docs”)
- Creating API documentation from code
- Scanning interfaces to generate documentation
- Documenting REST APIs
- çææ¥å£ææ¡£ (explicitly mentions “æ¥å£ææ¡£”)
- æ«ææ¥å£çæææ¡£ (scan interfaces to generate documentation)
- å建APIææ¡£ (create API documentation)
Trigger phrases include:
- “çææ¥å£ææ¡£” (generate API documentation) – must include “æ¥å£ææ¡£”
- “æ«ææ¥å£çæææ¡£” (scan interfaces to generate documentation)
- “å建APIææ¡£” (create API documentation)
- “为æ¥å£çæææ¡£” (generate documentation for interfaces)
- “æ¥å£ææ¡£çæ” (API documentation generation)
DO NOT trigger this skill for:
- Generic documentation requests without mentioning API/interfaces
- Code comments generation
- README file generation
- Other types of documentation (user guides, technical specs, etc.)
- “çæææ¡£” without “æ¥å£” or “API” (too generic)
How to use this skill
CRITICAL: This skill should ONLY be triggered when the user explicitly mentions generating API documentation. Do NOT trigger for generic documentation requests without API context.
Workflow Overview
This skill follows a systematic 4-step workflow:
- Scan Code – Check current project or specified objects for Controller classes and API interfaces
- Extract Information – Scan interfaces to collect request URL, method, parameters, and response information
- Generate Documentation – Create API documentation following the standard template
- Save Output – Save documentation to
./docsdirectory in the current project
Step-by-Step Process
Step 1: Scan Code for Interfaces
CRITICAL: Before generating any documentation, you MUST scan the code to find API interfaces.
-
Identify Target:
- Ask user if they want to scan the entire project or specific Controller classes
- If no target specified, scan the entire project for Controller classes
- Common Controller patterns:
- Java:
@RestController,@Controllerwith@RequestMapping - Spring Boot: Classes in
controllerorwebpackage - Files ending with
Controller.javaorController.kt
- Java:
-
Scan for Controllers:
- Search for Controller classes in the project
- Identify all classes annotated with
@RestControlleror@Controller - List all found Controller classes
-
Check for Interfaces:
- For each Controller class, scan for methods annotated with:
@GetMapping,@PostMapping,@PutMapping,@DeleteMapping@RequestMappingwith method specification
- Count total number of API interfaces found
- For each Controller class, scan for methods annotated with:
-
Validation:
- If no interfaces found, STOP and inform user:
æªæ¾å°ä»»ä½æ¥å£ï¼æ æ³çææ¥å£ææ¡£ãè¯·ç¡®è®¤ï¼ 1. 项ç®ä¸æ¯å¦åå¨ Controller ç±» 2. Controller ç±»ä¸æ¯å¦æ @GetMappingã@PostMapping çæ³¨è§£çæ¹æ³ 3. æ¯å¦æå®äºæ£ç¡®çæ«æè·¯å¾ - If interfaces found, proceed to Step 2
- If no interfaces found, STOP and inform user:
Output: List of Controller classes and total number of interfaces found.
Step 2: Extract Interface Information
CRITICAL: For each interface, extract complete information including URL, method, parameters, and response.
For each API interface found, extract:
-
Basic Information:
- Interface Name: Method name or description from annotation
- Request Method: GET, POST, PUT, DELETE, PATCH
- Request URL: Full path including class-level and method-level mappings
- Controller Class: Full class name with package
- Method Name: Java/Kotlin method name
-
Request Information:
- Path Parameters: Parameters in URL path (e.g.,
/user/{id})- Parameter name, type, required flag, description
- Query Parameters: Parameters in query string
- Parameter name, type, required flag, default value, description
- Request Body (for POST/PUT):
- Body type (JSON, Form-data, etc.)
- Field definitions: name, type, required flag, description
- Nested object structures
- Request Headers:
- Common headers: Authorization, Shop-Id, Tenant-Id
- Custom headers if any
- Path Parameters: Parameters in URL path (e.g.,
-
Response Information:
- Response Type: Return type of the method
- Response Structure:
- Standard response wrapper (e.g.,
R<T>,ApiResponse<T>) - Data object structure
- Standard response wrapper (e.g.,
- Response Fields:
- Field name, type, description
- Nested object fields
- Response Examples: Generate example JSON responses
- Error Responses: Common error codes and messages
-
Additional Information:
- Description: From
@ApiOperation,@Operation, or method comments - Tags: From
@Api,@Tagannotations - Deprecated: Check for
@Deprecatedannotation - Security: Authentication/authorization requirements
- Description: From
Output: Structured data for each interface with all extracted information.
Step 3: Generate Documentation
CRITICAL: Generate documentation following the standard template format.
-
Select Template Language:
- Ask user for preferred language: Chinese or English
- If not specified, detect from project context (code comments, package names, etc.)
- Available templates:
- Chinese:
templates/æ¥å£ææ¡£æ¨¡æ¿.md - English:
templates/api-documentation-template-en.md
- Chinese:
-
Load Template:
- Load the appropriate template based on language selection
- Use it as the base structure
-
Organize by Module:
- Group interfaces by Controller class or business module
- Create sections for each module
-
Generate Interface List Table:
- For Chinese template: Create “æ¥å£ä¸è§è¡¨” with columns:
- åºå· (Sequence number)
- æ¥å£å°å (Interface URL)
- è¯·æ±æ¹å¼ (Request Method)
- 说æ (Description)
- 宿æ åµ (Status)
- For English template: Create “API Interface List” with columns:
- No. (Sequence number)
- Interface URL
- Method
- Description
- Status
- For Chinese template: Create “æ¥å£ä¸è§è¡¨” with columns:
-
Generate Interface Definitions: For each interface, generate:
- Interface Name: Clear, descriptive name
- Interface Address: Full URL with method
- Description:
- Corresponding Controller class and method
- Business functionality description
- Business rules if any
- Request Section:
- Method and URL
- Headers table
- Path Parameters table
- Query Parameters table
- Request Body (if applicable) with field definitions
- Response Section:
- Response structure description
- Response fields table
- Response example (JSON)
- Error response examples
-
Add Standard Sections:
- For Chinese template:
- ç»ä¸ååºç»æ: Standard response format
- å页ååºæ ¼å¼: Pagination response format
- é误ç 约å®: Error code conventions
- 请æ±å¤´è§è: Request header specifications
- 注æäºé¡¹: Important notes
- For English template:
- Standard Response Structure: Standard response format
- Pagination Response Format: Pagination response format
- Error Code Conventions: Error code conventions
- Request Header Specifications: Request header specifications
- Important Notes: Important notes
- For Chinese template:
-
Format Documentation:
- Use proper Markdown formatting
- Ensure tables are properly formatted
- Include code blocks for JSON examples
- Add proper headings hierarchy
Output: Complete API documentation in Markdown format.
Step 4: Save Documentation
CRITICAL: Save documentation to the ./docs directory in the current project.
-
Determine Output Path:
- Default:
./docs/api-documentation.md - If multiple modules:
./docs/{module-name}-api-documentation.md - Ask user if they want a custom filename
- Default:
-
Create Directory:
- Check if
./docsdirectory exists - If not, create it automatically
- Check if
-
Save File:
- Write the generated documentation to the file
- Use UTF-8 encoding
- Ensure proper line endings
-
Inform User:
- Tell user where the file was saved
- Show the file path
- Optionally display a preview of the documentation
Output: Documentation file saved to ./docs/api-documentation.md (or custom path).
Code Scanning Guidelines
Java/Spring Boot Projects
Controller Identification:
- Look for classes annotated with
@RestControlleror@Controller - Check for
@RequestMappingat class level - Common package patterns:
*.controller.*,*.web.*,*.api.*
Method Identification:
- Methods annotated with:
@GetMapping,@PostMapping,@PutMapping,@DeleteMapping,@PatchMapping@RequestMapping(method = RequestMethod.GET)etc.
Parameter Extraction:
@PathVariable: Path parameters@RequestParam: Query parameters@RequestBody: Request body@RequestHeader: Request headers- Parameter types from method signature
Response Extraction:
- Return type from method signature
@ResponseBodyannotation- Generic types (e.g.,
R<T>,Page<T>) - Response entity structure
Kotlin/Spring Boot Projects
Similar to Java, but check for:
- Kotlin data classes for request/response
- Nullable types (
String?,Int?) - Kotlin-specific annotations
Documentation Template Structure
The generated documentation follows this structure (available in both Chinese and English):
Chinese Template (templates/æ¥å£ææ¡£æ¨¡æ¿.md):
-
ææ¡£æ¦è§ (Document Overview)
- Version history table
- Responsibility table
-
æ¥å£ä¸è§è¡¨ (Interface List Table)
- Summary table of all interfaces
-
æ¥å£å®ä¹ (Interface Definitions)
- Detailed definition for each interface
- Request and Response sections
- Field definitions and examples
-
ç»ä¸ååºç»æ (Standard Response Structure)
- Standard response format
- Pagination format
- Error codes
-
请æ±å¤´è§è (Request Header Specifications)
-
注æäºé¡¹ (Important Notes)
English Template (templates/api-documentation-template-en.md):
-
Document Overview
- Version history table
- Responsibility table
-
API Interface List
- Summary table of all interfaces
-
Interface Definitions
- Detailed definition for each interface
- Request and Response sections
- Field definitions and examples
-
Standard Response Structure
- Standard response format
- Pagination format
- Error codes
-
Request Header Specifications
-
Important Notes
Template Selection:
- Ask user for preferred language (Chinese/English)
- If not specified, detect from project context
- Both templates follow the same structure, only language differs
Best Practices
- Complete Information: Extract all available information from code, including annotations and comments
- Standard Format: Follow the template structure strictly
- Clear Descriptions: Use meaningful descriptions from code comments or annotations
- Examples: Include realistic response examples
- Error Handling: Document common error scenarios
- Grouping: Organize interfaces by module or Controller class
- Validation: Verify all extracted information is accurate
Reference Documentation
- Templates:
templates/æ¥å£ææ¡£æ¨¡æ¿.md– Standard API documentation template (Chinese)templates/api-documentation-template-en.md– Standard API documentation template (English)
- Example:
examples/scan-and-generate-example.md– Complete workflow example showing how to scan and generate API documentation
Keywords
English keywords: api documentation, api docs, generate api documentation, create api docs, scan interfaces, document apis, rest api documentation, interface documentation, api doc generator, scan controllers, extract api information
Chinese keywords (ä¸æå ³é®è¯): æ¥å£ææ¡£, APIææ¡£, çææ¥å£ææ¡£, å建æ¥å£ææ¡£, æ«ææ¥å£, æ¥å£ææ¡£çæ, APIææ¡£çæ, æ¥å£ææ¡£çæå¨, æ«æController, æåæ¥å£ä¿¡æ¯, æ¥å£ææ¡£æ¨¡æ¿
IMPORTANT: All keywords must include “æ¥å£ææ¡£” (API documentation) or “API” to avoid false triggers. Generic terms like “çæææ¡£” (generate documentation) without “æ¥å£” or “API” should NOT trigger this skill.