Skip to content

Commit a44aa16

Browse files
GTyingziclaude
andauthored
Feat claudecode skill (#408)
* feat: 为项目生成完整的API文档和模块文档 - 新增Claude Code技能框架:http-generate、readme-generate、skill-creator - 为76个包含Web接口的模块生成.http文件,涵盖100+个Controller类 - 为46个缺少文档的模块生成README.md文件,包含完整的API文档和使用说明 - 更新CLAUDE.md文件,提供项目开发指导 - 新增task/module-generate.md文档,描述自动化文档生成任务 生成的文档特点: - HTTP文件:包含完整的REST API请求示例,支持IDE直接运行 - README文件:统一的中文文档格式,包含功能介绍、API文档、使用示例、技术实现等 - 提升项目文档完整性,降低开发者学习和使用门槛 🤖 Generated with [Claude Code](https://claude.ai/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: 恢复被覆盖的重要README文件,整合原有技术文档与新生成API文档 ## 恢复的关键文档 ### RAG相关模块 - **rag-milvus-example**: 恢复Milvus向量数据库配置、Docker部署、集合加载步骤 - **rag-elasticsearch-example**: 恢复Local/Cloud RAG流程详解、Elasticsearch配置 - **rag-pgvector-example**: 恢复PostgreSQL+pgvector数据库创建脚本、HNSW索引配置 - **rag-openai-dashscope-pgvector-example**: 恢复MXY RAG Server架构、多模型集成 - **module-rag**: 恢复Spring AI Module RAG技术架构、Pre-Retrieval模块详解 ### 基础模块 - **helloworld**: 恢复完整的入门示例,包含环境配置、快速开始指南 ## 恢复的重要内容 ### 技术实现细节 - 详细的数据库配置和SQL脚本 - Docker Compose部署指南 - 向量索引创建和优化配置 - RAG流程的完整技术说明 ### 配置和部署 - application.yml完整配置示例 - 环境变量和依赖说明 - 性能优化建议 - 故障排查指南 ### API文档整合 - 保留新生成的标准化API文档格式 - 整合原有的curl命令示例 - 统一的接口说明和参数描述 ## 改进效果 ✅ **技术完整性**: 恢复了丢失的重要技术实现细节 ✅ **配置完整性**: 保留了完整的部署和配置说明 ✅ **文档一致性**: 统一了文档格式,同时保留了重要信息 ✅ **可用性提升**: 开发者可以获得完整的使用指南 ## 文件统计 - 恢复了6个重要的README文件 - 保留了原有的技术细节和配置说明 - 整合了新生成的API文档格式 - 新增readme-overwrite.md任务文档 🤖 Generated with [Claude Code](https://claude.ai/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: doc * fix: doc --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent e681172 commit a44aa16

File tree

129 files changed

+11732
-526
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+11732
-526
lines changed
Lines changed: 279 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
---
2+
name: http-generate
3+
description: Generates HTTP request examples for Spring Boot Web interfaces according to task specification and saves them as .http files in module-generate.md directories
4+
---
5+
6+
# HTTP Generator
7+
8+
This skill automatically analyzes Spring Boot Web controllers and generates HTTP request examples for all REST endpoints, saving them as `.http` files in their respective module directories according to the task specification.
9+
10+
## When to Use
11+
12+
Use this skill when you need to:
13+
- Generate API documentation for testing
14+
- Create HTTP request examples for new modules
15+
- Document existing Spring Boot REST controllers
16+
- Provide ready-to-use request samples for developers
17+
- Automate API testing setup
18+
- Create interface specifications for team collaboration
19+
20+
## How to Use
21+
22+
### Generate HTTP Requests for a Single Module
23+
24+
Execute the HTTP generator script to create request examples for all controllers in a module:
25+
26+
```bash
27+
python .claude/skills/http-generate/scripts/http_generator.py <module_path> [output_file]
28+
```
29+
30+
### Generate HTTP Requests for All Modules
31+
32+
Use the `all` parameter to automatically discover and generate HTTP files for all modules with controllers:
33+
34+
```bash
35+
python .claude/skills/http-generate/scripts/http_generator.py all
36+
```
37+
38+
**Parameters:**
39+
- `module_path` (required): Path to the Spring Boot module directory, or `all` to process all modules
40+
- `output_file` (optional): Custom output file path (default: `{module_name}.http`)
41+
42+
**Examples:**
43+
```bash
44+
# Generate for chat module-generate.md (creates basic/chat/chat.http)
45+
python .claude/skills/http-generate/scripts/http_generator.py basic/chat
46+
47+
# Generate for all modules automatically
48+
python .claude/skills/http-generate/scripts/http_generator.py all
49+
50+
# Generate for graph module-generate.md (creates graph/graph.http)
51+
python .claude/skills/http-generate/scripts/http_generator.py graph/parallel
52+
53+
# Generate with custom output file
54+
python .claude/skills/http-generate/scripts/http_generator.py basic/chat custom-api.http
55+
56+
# Generate for different modules
57+
python .claude/skills/http-generate/scripts/http_generator.py basic/tool
58+
python .claude/skills/http-generate/scripts/http_generator.py basic/image
59+
python .claude/skills/http-generate/scripts/http_generator.py graph/stream
60+
```
61+
62+
### Supported Controller Patterns
63+
64+
The skill automatically detects and generates requests for:
65+
66+
#### HTTP Methods
67+
- **GET** `@GetMapping` - Query operations
68+
- **POST** `@PostMapping` - Create operations
69+
- **PUT** `@PutMapping` - Update operations
70+
- **DELETE** `@DeleteMapping` - Delete operations
71+
72+
#### Parameter Types
73+
- **`@RequestParam`** with default values
74+
- **`@RequestParam`** without default values
75+
- **`@PathVariable`** for path parameters
76+
- **URL encoding** for Chinese characters and special values
77+
78+
#### Controller Annotations
79+
- **`@RestController`** - JSON API endpoints
80+
- **`@Controller`** - MVC controllers
81+
- **`@RequestMapping`** - Base path mapping
82+
83+
### Output Format (Task Specification)
84+
85+
The skill generates `.http` files according to the task specification format:
86+
87+
#### Basic Format
88+
```http
89+
# {Controller类名}的{方法名}方法
90+
{HTTP_METHOD} {完整URL路径}?{参数键值对}
91+
92+
###
93+
# {Controller类名}的{方法名}方法
94+
{HTTP_METHOD} {完整URL路径}?{参数键值对}
95+
```
96+
97+
#### Generated Example
98+
```http
99+
# ChatController类的callChat方法
100+
GET http://localhost:8080/basic/chat/call?query=你好,很高兴认识你,能简单介绍一下自己吗?
101+
102+
###
103+
# ChatController类的streamChat方法
104+
GET http://localhost:8080/basic/chat/stream?query=你好,很高兴认识你,能简单介绍一下自己吗?
105+
106+
###
107+
# ChatController类的callOption方法
108+
GET http://localhost:8080/basic/chat/call/option?query=你好,很高兴认识你,能简单介绍一下自己吗?
109+
```
110+
111+
### Generated Request Features
112+
113+
Each generated HTTP request includes:
114+
115+
- **Method Documentation**: Comment format `# Controller类名的方法名方法`
116+
- **Complete URL**: Full endpoint URL with base path
117+
- **Default Parameters**: All @RequestParam values with defaults
118+
- **Proper Encoding**: URL encoding for Chinese characters
119+
- **Query String**: Properly formatted parameter strings with `?` and `&`
120+
- **Separators**: `###` used to separate different interfaces
121+
- **File Organization**: Grouped by controller and module
122+
123+
### Module Discovery
124+
125+
The skill automatically:
126+
127+
1. **Discovers Modules**: Scans project directories for modules containing controllers
128+
2. **Identifies Controllers**: Files ending with `Controller.java`
129+
3. **Analyzes Annotations**: Extracts mapping annotations
130+
4. **Extracts Parameters**: Finds @RequestParam configurations
131+
5. **Builds URLs**: Constructs complete request URLs
132+
6. **Generates Examples**: Creates ready-to-use HTTP requests
133+
134+
### Supported Spring Boot Patterns
135+
136+
#### Example 1: Simple GET Controller
137+
```java
138+
@RestController
139+
@RequestMapping("/basic/chat")
140+
public class ChatController {
141+
142+
@GetMapping("/call")
143+
public String callChat(
144+
@RequestParam(value = "query",
145+
defaultValue = "你好,很高兴认识你,能简单介绍一下自己吗?",
146+
required = false) String query) {
147+
return chatClient.prompt(query).call().content();
148+
}
149+
}
150+
```
151+
152+
**Generated Request:**
153+
```http
154+
# ChatController类的callChat方法
155+
GET http://localhost:8080/basic/chat/call?query=你好,很高兴认识你,能简单介绍一下自己吗?
156+
```
157+
158+
#### Example 2: Complex Parameters
159+
```java
160+
@GetMapping("/expand-translate")
161+
public Map<String, Object> expandAndTranslate(
162+
@RequestParam(value = "query", defaultValue = "你好", required = false) String query,
163+
@RequestParam(value = "expander_number", defaultValue = "3", required = false) Integer expanderNumber,
164+
@RequestParam(value = "translate_language", defaultValue = "english", required = false) String translateLanguage) {
165+
// implementation
166+
}
167+
```
168+
169+
**Generated Request:**
170+
```http
171+
# ParallelController类的expandAndTranslate方法
172+
GET http://localhost:8080/graph/parallel/expand-translate?query=你好&expander_number=3&translate_language=english
173+
```
174+
175+
#### Example 3: Multiple Controllers
176+
For modules with multiple controllers, the skill generates requests for all with `###` separators:
177+
178+
```http
179+
# TimeController类的call方法
180+
GET http://localhost:8080/basic/tool/time/call?query=请告诉我现在北京时间几点了
181+
182+
###
183+
# TimeController类的callToolFunction方法
184+
GET http://localhost:8080/basic/tool/time/call/function?query=请告诉我现在北京时间几点了
185+
186+
###
187+
# SearchController类的search方法
188+
GET http://localhost:8080/basic/tool/search?query=Spring+AI
189+
```
190+
191+
## File Organization (Task Specification)
192+
193+
### Output Location
194+
- **Default**: `{module_name}/{module_name}.http`
195+
- **File Naming**: Uses module name as filename (e.g., `chat.http`, `tool.http`)
196+
- **Custom**: User-specified path
197+
- **Encoding**: UTF-8 for Chinese characters
198+
199+
### Directory Structure Example
200+
```
201+
basic/
202+
├── chat/
203+
│ ├── chat.http ← Generated file
204+
│ └── src/main/java/.../ChatController.java
205+
├── tool/
206+
│ ├── tool.http ← Generated file
207+
│ └── src/main/java/.../TimeController.java
208+
└── image/
209+
├── image.http ← Generated file
210+
└── src/main/java/.../ImageController.java
211+
```
212+
213+
### Task Specification Compliance
214+
215+
The generated files strictly follow the task specification:
216+
217+
1. **文件命名**: 以模块名称命名,使用 `.http` 后缀 ✅
218+
2. **文件位置**: 放置在对应模块的根目录下 ✅
219+
3. **内容来源**: 基于 Controller 类中的接口方法生成 ✅
220+
4. **注释格式**: 使用 `# Controller类名的方法名方法`
221+
5. **分隔符**: 使用 `###` 分隔不同接口 ✅
222+
6. **参数处理**: 正确处理查询参数拼接 ✅
223+
224+
## Integration with Development Workflow
225+
226+
### Use with IDE HTTP Client
227+
The generated `.http` files work seamlessly with:
228+
- **IntelliJ IDEA HTTP Client**
229+
- **VS Code REST Client**
230+
- **Postman Import**
231+
- **curl commands**
232+
233+
### Automated Documentation
234+
Perfect for:
235+
- **API documentation generation**
236+
- **Testing automation**
237+
- **Developer onboarding**
238+
- **Contract testing**
239+
- **Integration testing setup**
240+
241+
## Customization Options
242+
243+
### Modify Script Behavior
244+
Edit `scripts/http_generator.py` to customize:
245+
246+
- **Base URL**: Change from `http://localhost:8080`
247+
- **Output Format**: Modify request template according to specification
248+
- **Parameter Handling**: Add support for other annotations
249+
- **File Patterns**: Change controller detection logic
250+
- **Encoding**: Adjust URL encoding rules
251+
252+
### Extend Functionality
253+
Add support for:
254+
- **POST body parameters**
255+
- **Header handling**
256+
- **Authentication headers**
257+
- **Multi-parameter requests**
258+
- **File upload examples**
259+
260+
## Notes
261+
262+
- The script automatically discovers all modules with controllers when using `all` parameter
263+
- Only processes files ending with `Controller.java`
264+
- Supports UTF-8 encoding for Chinese parameters
265+
- Requires Python 3 and no external dependencies
266+
- Handles complex Spring Boot annotation patterns
267+
- Preserves parameter defaults from source code
268+
- Groups requests by controller for clarity
269+
- Follows task specification format exactly
270+
271+
## Error Handling
272+
273+
Common issues and solutions:
274+
275+
- **No controllers found**: Ensure module contains `*Controller.java` files
276+
- **Missing @RequestMapping**: Controllers without base mapping will use root path
277+
- **Complex parameters**: Some advanced parameter types may need manual adjustment
278+
- **Encoding issues**: Chinese characters are automatically URL-encoded
279+
- **Module discovery**: Use `all` parameter to auto-discover modules with controllers

0 commit comments

Comments
 (0)