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
./docs directory 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, @Controller with @RequestMapping
- Spring Boot: Classes in
controller or web package
- Files ending with
Controller.java or Controller.kt
Scan for Controllers:
- Search for Controller classes in the project
- Identify all classes annotated with
@RestController or @Controller
- List all found Controller classes
Check for Interfaces:
- For each Controller class, scan for methods annotated with:
@GetMapping, @PostMapping, @PutMapping, @DeleteMapping
@RequestMapping with method specification
- Count total number of API interfaces found
Validation:
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
Response Information:
- Response Type: Return type of the method
- Response Structure:
- Standard response wrapper (e.g.,
R<T>, ApiResponse<T>)
- Data object structure
- 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, @Tag annotations
- Deprecated: Check for
@Deprecated annotation
- Security: Authentication/authorization requirements
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
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
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
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
Create Directory:
- Check if
./docs directory exists
- If not, create it automatically
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
@RestController or @Controller
- Check for
@RequestMapping at 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
@ResponseBody annotation
- 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.
1---2name: api-doc-generator3description: Provides comprehensive guidance for generating API documentation by scanning code interfaces, extracting request/response information, and creating standardized API documentation. Use ONLY when the user explicitly mentions generating API documentation, creating API docs, scanning interfaces, or documenting APIs. The skill scans Controller classes, extracts interface information (URL, method, parameters, response), and generates documentation following standard templates. Do NOT trigger for generic documentation requests without explicit API documentation mention.4license: Complete terms in LICENSE.txt5---6
7## When to use this skill
8
9**CRITICAL: This skill should ONLY be triggered when the user explicitly mentions generating API documentation, creating API docs, scanning interfaces, or documenting APIs.**
10
11**ALWAYS use this skill when the user mentions:**
12- Generating API documentation (explicitly mentions "API documentation" or "API docs")
13- Creating API documentation from code
14- Scanning interfaces to generate documentation
15- Documenting REST APIs
16- 生成接口文档 (explicitly mentions "接口文档")
17- 扫描接口生成文档 (scan interfaces to generate documentation)
18- 创建API文档 (create API documentation)
19
20**Trigger phrases include:**
21- "生成接口文档" (generate API documentation) - **must include "接口文档"**
22- "扫描接口生成文档" (scan interfaces to generate documentation)
23- "创建API文档" (create API documentation)
24- "为接口生成文档" (generate documentation for interfaces)
25- "接口文档生成" (API documentation generation)
26
27**DO NOT trigger this skill for:**
28- Generic documentation requests without mentioning API/interfaces
29- Code comments generation
30- README file generation
31- Other types of documentation (user guides, technical specs, etc.)
32- "生成文档" without "接口" or "API" (too generic)
33
34## How to use this skill
35
36**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.**
37
38### Workflow Overview
39
40This skill follows a systematic 4-step workflow:
41
421. **Scan Code** - Check current project or specified objects for Controller classes and API interfaces
432. **Extract Information** - Scan interfaces to collect request URL, method, parameters, and response information
443. **Generate Documentation** - Create API documentation following the standard template
454. **Save Output** - Save documentation to `./docs` directory in the current project
46
47### Step-by-Step Process
48
49#### Step 1: Scan Code for Interfaces
50
51**CRITICAL: Before generating any documentation, you MUST scan the code to find API interfaces.**
52
531. **Identify Target**:
54 - Ask user if they want to scan the entire project or specific Controller classes
55 - If no target specified, scan the entire project for Controller classes
56 - Common Controller patterns:
57 - Java: `@RestController`, `@Controller` with `@RequestMapping`
58 - Spring Boot: Classes in `controller` or `web` package
59 - Files ending with `Controller.java` or `Controller.kt`
60
612. **Scan for Controllers**:
62 - Search for Controller classes in the project
63 - Identify all classes annotated with `@RestController` or `@Controller`
64 - List all found Controller classes
65
663. **Check for Interfaces**:
67 - For each Controller class, scan for methods annotated with:
68 - `@GetMapping`, `@PostMapping`, `@PutMapping`, `@DeleteMapping`
69 - `@RequestMapping` with method specification
70 - Count total number of API interfaces found
71
724. **Validation**:
73 - If no interfaces found, **STOP** and inform user:
74 ```
75 未找到任何接口,无法生成接口文档。请确认:
76 1. 项目中是否存在 Controller 类
77 2. Controller 类中是否有 @GetMapping、@PostMapping 等注解的方法
78 3. 是否指定了正确的扫描路径
79 ```
80 - If interfaces found, proceed to Step 2
81
82**Output**: List of Controller classes and total number of interfaces found.
83
84#### Step 2: Extract Interface Information
85
86**CRITICAL: For each interface, extract complete information including URL, method, parameters, and response.**
87
88For each API interface found, extract:
89
901. **Basic Information**:
91 - **Interface Name**: Method name or description from annotation
92 - **Request Method**: GET, POST, PUT, DELETE, PATCH
93 - **Request URL**: Full path including class-level and method-level mappings
94 - **Controller Class**: Full class name with package
95 - **Method Name**: Java/Kotlin method name
96
972. **Request Information**:
98 - **Path Parameters**: Parameters in URL path (e.g., `/user/{id}`)
99 - Parameter name, type, required flag, description
100 - **Query Parameters**: Parameters in query string
101 - Parameter name, type, required flag, default value, description
102 - **Request Body** (for POST/PUT):
103 - Body type (JSON, Form-data, etc.)
104 - Field definitions: name, type, required flag, description
105 - Nested object structures
106 - **Request Headers**:
107 - Common headers: Authorization, Shop-Id, Tenant-Id
108 - Custom headers if any
109
1103. **Response Information**:
111 - **Response Type**: Return type of the method
112 - **Response Structure**:
113 - Standard response wrapper (e.g., `R<T>`, `ApiResponse<T>`)
114 - Data object structure
115 - **Response Fields**:
116 - Field name, type, description
117 - Nested object fields
118 - **Response Examples**: Generate example JSON responses
119 - **Error Responses**: Common error codes and messages
120
1214. **Additional Information**:
122 - **Description**: From `@ApiOperation`, `@Operation`, or method comments
123 - **Tags**: From `@Api`, `@Tag` annotations
124 - **Deprecated**: Check for `@Deprecated` annotation
125 - **Security**: Authentication/authorization requirements
126
127**Output**: Structured data for each interface with all extracted information.
128
129#### Step 3: Generate Documentation
130
131**CRITICAL: Generate documentation following the standard template format.**
132
1331. **Select Template Language**:
134 - Ask user for preferred language: Chinese or English
135 - If not specified, detect from project context (code comments, package names, etc.)
136 - Available templates:
137 - Chinese: `templates/接口文档模板.md`
138 - English: `templates/api-documentation-template-en.md`
139
1402. **Load Template**:
141 - Load the appropriate template based on language selection
142 - Use it as the base structure
143
1442. **Organize by Module**:
145 - Group interfaces by Controller class or business module
146 - Create sections for each module
147
1483. **Generate Interface List Table**:
149 - For Chinese template: Create "接口一览表" with columns:
150 - 序号 (Sequence number)
151 - 接口地址 (Interface URL)
152 - 请求方式 (Request Method)
153 - 说明 (Description)
154 - 完成情况 (Status)
155 - For English template: Create "API Interface List" with columns:
156 - No. (Sequence number)
157 - Interface URL
158 - Method
159 - Description
160 - Status
161
1624. **Generate Interface Definitions**:
163 For each interface, generate:
164 - **Interface Name**: Clear, descriptive name
165 - **Interface Address**: Full URL with method
166 - **Description**:
167 - Corresponding Controller class and method
168 - Business functionality description
169 - Business rules if any
170 - **Request Section**:
171 - Method and URL
172 - Headers table
173 - Path Parameters table
174 - Query Parameters table
175 - Request Body (if applicable) with field definitions
176 - **Response Section**:
177 - Response structure description
178 - Response fields table
179 - Response example (JSON)
180 - Error response examples
181
1825. **Add Standard Sections**:
183 - For Chinese template:
184 - **统一响应结构**: Standard response format
185 - **分页响应格式**: Pagination response format
186 - **错误码约定**: Error code conventions
187 - **请求头规范**: Request header specifications
188 - **注意事项**: Important notes
189 - For English template:
190 - **Standard Response Structure**: Standard response format
191 - **Pagination Response Format**: Pagination response format
192 - **Error Code Conventions**: Error code conventions
193 - **Request Header Specifications**: Request header specifications
194 - **Important Notes**: Important notes
195
1966. **Format Documentation**:
197 - Use proper Markdown formatting
198 - Ensure tables are properly formatted
199 - Include code blocks for JSON examples
200 - Add proper headings hierarchy
201
202**Output**: Complete API documentation in Markdown format.
203
204#### Step 4: Save Documentation
205
206**CRITICAL: Save documentation to the `./docs` directory in the current project.**
207
2081. **Determine Output Path**:
209 - Default: `./docs/api-documentation.md`
210 - If multiple modules: `./docs/{module-name}-api-documentation.md`
211 - Ask user if they want a custom filename
212
2132. **Create Directory**:
214 - Check if `./docs` directory exists
215 - If not, create it automatically
216
2173. **Save File**:
218 - Write the generated documentation to the file
219 - Use UTF-8 encoding
220 - Ensure proper line endings
221
2224. **Inform User**:
223 - Tell user where the file was saved
224 - Show the file path
225 - Optionally display a preview of the documentation
226
227**Output**: Documentation file saved to `./docs/api-documentation.md` (or custom path).
228
229### Code Scanning Guidelines
230
231#### Java/Spring Boot Projects
232
233**Controller Identification**:
234- Look for classes annotated with `@RestController` or `@Controller`
235- Check for `@RequestMapping` at class level
236- Common package patterns: `*.controller.*`, `*.web.*`, `*.api.*`
237
238**Method Identification**:
239- Methods annotated with:
240 - `@GetMapping`, `@PostMapping`, `@PutMapping`, `@DeleteMapping`, `@PatchMapping`
241 - `@RequestMapping(method = RequestMethod.GET)` etc.
242
243**Parameter Extraction**:
244- `@PathVariable`: Path parameters
245- `@RequestParam`: Query parameters
246- `@RequestBody`: Request body
247- `@RequestHeader`: Request headers
248- Parameter types from method signature
249
250**Response Extraction**:
251- Return type from method signature
252- `@ResponseBody` annotation
253- Generic types (e.g., `R<T>`, `Page<T>`)
254- Response entity structure
255
256#### Kotlin/Spring Boot Projects
257
258Similar to Java, but check for:
259- Kotlin data classes for request/response
260- Nullable types (`String?`, `Int?`)
261- Kotlin-specific annotations
262
263### Documentation Template Structure
264
265The generated documentation follows this structure (available in both Chinese and English):
266
267**Chinese Template** (`templates/接口文档模板.md`):
2681. **文档概览** (Document Overview)
269 - Version history table
270 - Responsibility table
271
2722. **接口一览表** (Interface List Table)
273 - Summary table of all interfaces
274
2753. **接口定义** (Interface Definitions)
276 - Detailed definition for each interface
277 - Request and Response sections
278 - Field definitions and examples
279
2804. **统一响应结构** (Standard Response Structure)
281 - Standard response format
282 - Pagination format
283 - Error codes
284
2855. **请求头规范** (Request Header Specifications)
286
2876. **注意事项** (Important Notes)
288
289**English Template** (`templates/api-documentation-template-en.md`):
2901. **Document Overview**
291 - Version history table
292 - Responsibility table
293
2942. **API Interface List**
295 - Summary table of all interfaces
296
2973. **Interface Definitions**
298 - Detailed definition for each interface
299 - Request and Response sections
300 - Field definitions and examples
301
3024. **Standard Response Structure**
303 - Standard response format
304 - Pagination format
305 - Error codes
306
3075. **Request Header Specifications**
308
3096. **Important Notes**
310
311**Template Selection**:
312- Ask user for preferred language (Chinese/English)
313- If not specified, detect from project context
314- Both templates follow the same structure, only language differs
315
316### Best Practices
317
3181. **Complete Information**: Extract all available information from code, including annotations and comments
3192. **Standard Format**: Follow the template structure strictly
3203. **Clear Descriptions**: Use meaningful descriptions from code comments or annotations
3214. **Examples**: Include realistic response examples
3225. **Error Handling**: Document common error scenarios
3236. **Grouping**: Organize interfaces by module or Controller class
3247. **Validation**: Verify all extracted information is accurate
325
326### Reference Documentation
327
328- **Templates**:
329 - `templates/接口文档模板.md` - Standard API documentation template (Chinese)
330 - `templates/api-documentation-template-en.md` - Standard API documentation template (English)
331- **Example**: `examples/scan-and-generate-example.md` - Complete workflow example showing how to scan and generate API documentation
332
333## Keywords
334
335**English keywords:**
336api 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
337
338**Chinese keywords (中文关键词):**
339接口文档, API文档, 生成接口文档, 创建接口文档, 扫描接口, 接口文档生成, API文档生成, 接口文档生成器, 扫描Controller, 提取接口信息, 接口文档模板
340
341**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.