ai-engineering-init 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/hooks/skill-forced-eval.js +46 -62
- package/.claude/settings.json +10 -1
- package/.claude/skills/api-development/SKILL.md +179 -130
- package/.claude/skills/architecture-design/SKILL.md +102 -212
- package/.claude/skills/backend-annotations/SKILL.md +166 -220
- package/.claude/skills/bug-detective/SKILL.md +225 -186
- package/.claude/skills/code-patterns/SKILL.md +127 -244
- package/.claude/skills/collaborating-with-codex/SKILL.md +96 -113
- package/.claude/skills/crud-development/SKILL.md +226 -307
- package/.claude/skills/data-permission/SKILL.md +131 -202
- package/.claude/skills/database-ops/SKILL.md +158 -355
- package/.claude/skills/error-handler/SKILL.md +224 -285
- package/.claude/skills/file-oss-management/SKILL.md +174 -169
- package/.claude/skills/git-workflow/SKILL.md +123 -341
- package/.claude/skills/json-serialization/SKILL.md +121 -137
- package/.claude/skills/performance-doctor/SKILL.md +83 -89
- package/.claude/skills/redis-cache/SKILL.md +134 -185
- package/.claude/skills/scheduled-jobs/SKILL.md +187 -224
- package/.claude/skills/security-guard/SKILL.md +168 -276
- package/.claude/skills/sms-mail/SKILL.md +266 -228
- package/.claude/skills/social-login/SKILL.md +257 -195
- package/.claude/skills/tenant-management/SKILL.md +172 -188
- package/.claude/skills/utils-toolkit/SKILL.md +214 -222
- package/.claude/skills/websocket-sse/SKILL.md +251 -172
- package/.claude/skills/workflow-engine/SKILL.md +178 -250
- package/.codex/skills/api-development/SKILL.md +179 -130
- package/.codex/skills/architecture-design/SKILL.md +102 -212
- package/.codex/skills/backend-annotations/SKILL.md +166 -220
- package/.codex/skills/bug-detective/SKILL.md +225 -186
- package/.codex/skills/code-patterns/SKILL.md +127 -244
- package/.codex/skills/collaborating-with-codex/SKILL.md +96 -113
- package/.codex/skills/crud-development/SKILL.md +226 -307
- package/.codex/skills/data-permission/SKILL.md +131 -202
- package/.codex/skills/database-ops/SKILL.md +158 -355
- package/.codex/skills/error-handler/SKILL.md +224 -285
- package/.codex/skills/file-oss-management/SKILL.md +174 -169
- package/.codex/skills/git-workflow/SKILL.md +123 -341
- package/.codex/skills/json-serialization/SKILL.md +121 -137
- package/.codex/skills/performance-doctor/SKILL.md +83 -89
- package/.codex/skills/redis-cache/SKILL.md +134 -185
- package/.codex/skills/scheduled-jobs/SKILL.md +187 -224
- package/.codex/skills/security-guard/SKILL.md +168 -276
- package/.codex/skills/sms-mail/SKILL.md +266 -228
- package/.codex/skills/social-login/SKILL.md +257 -195
- package/.codex/skills/tenant-management/SKILL.md +172 -188
- package/.codex/skills/utils-toolkit/SKILL.md +214 -222
- package/.codex/skills/websocket-sse/SKILL.md +251 -172
- package/.codex/skills/workflow-engine/SKILL.md +178 -250
- package/.cursor/hooks/cursor-skill-eval.js +66 -6
- package/.cursor/skills/api-development/SKILL.md +179 -130
- package/.cursor/skills/architecture-design/SKILL.md +102 -212
- package/.cursor/skills/backend-annotations/SKILL.md +166 -220
- package/.cursor/skills/bug-detective/SKILL.md +225 -186
- package/.cursor/skills/code-patterns/SKILL.md +127 -244
- package/.cursor/skills/collaborating-with-codex/SKILL.md +96 -113
- package/.cursor/skills/crud-development/SKILL.md +226 -307
- package/.cursor/skills/data-permission/SKILL.md +131 -202
- package/.cursor/skills/database-ops/SKILL.md +158 -355
- package/.cursor/skills/error-handler/SKILL.md +224 -285
- package/.cursor/skills/file-oss-management/SKILL.md +174 -169
- package/.cursor/skills/git-workflow/SKILL.md +123 -341
- package/.cursor/skills/json-serialization/SKILL.md +121 -137
- package/.cursor/skills/performance-doctor/SKILL.md +83 -89
- package/.cursor/skills/redis-cache/SKILL.md +134 -185
- package/.cursor/skills/scheduled-jobs/SKILL.md +187 -224
- package/.cursor/skills/security-guard/SKILL.md +168 -276
- package/.cursor/skills/sms-mail/SKILL.md +266 -228
- package/.cursor/skills/social-login/SKILL.md +257 -195
- package/.cursor/skills/tenant-management/SKILL.md +172 -188
- package/.cursor/skills/utils-toolkit/SKILL.md +214 -222
- package/.cursor/skills/websocket-sse/SKILL.md +251 -172
- package/.cursor/skills/workflow-engine/SKILL.md +178 -250
- package/AGENTS.md +49 -540
- package/CLAUDE.md +73 -119
- package/README.md +37 -6
- package/bin/index.js +5 -1
- package/package.json +1 -1
- package/src/skills/api-development/SKILL.md +179 -130
- package/src/skills/architecture-design/SKILL.md +102 -212
- package/src/skills/backend-annotations/SKILL.md +166 -220
- package/src/skills/bug-detective/SKILL.md +225 -186
- package/src/skills/code-patterns/SKILL.md +127 -244
- package/src/skills/collaborating-with-codex/SKILL.md +96 -113
- package/src/skills/crud-development/SKILL.md +226 -307
- package/src/skills/data-permission/SKILL.md +131 -202
- package/src/skills/database-ops/SKILL.md +158 -355
- package/src/skills/error-handler/SKILL.md +224 -285
- package/src/skills/file-oss-management/SKILL.md +174 -169
- package/src/skills/git-workflow/SKILL.md +123 -341
- package/src/skills/json-serialization/SKILL.md +121 -137
- package/src/skills/performance-doctor/SKILL.md +83 -89
- package/src/skills/redis-cache/SKILL.md +134 -185
- package/src/skills/scheduled-jobs/SKILL.md +187 -224
- package/src/skills/security-guard/SKILL.md +168 -276
- package/src/skills/sms-mail/SKILL.md +266 -228
- package/src/skills/social-login/SKILL.md +257 -195
- package/src/skills/tenant-management/SKILL.md +172 -188
- package/src/skills/utils-toolkit/SKILL.md +214 -222
- package/src/skills/websocket-sse/SKILL.md +251 -172
- package/src/skills/workflow-engine/SKILL.md +178 -250
- package/.claude/skills/skill-creator/LICENSE.txt +0 -202
- package/.claude/skills/skill-creator/SKILL.md +0 -479
- package/.claude/skills/skill-creator/agents/analyzer.md +0 -274
- package/.claude/skills/skill-creator/agents/comparator.md +0 -202
- package/.claude/skills/skill-creator/agents/grader.md +0 -223
- package/.claude/skills/skill-creator/assets/eval_review.html +0 -146
- package/.claude/skills/skill-creator/eval-viewer/generate_review.py +0 -471
- package/.claude/skills/skill-creator/eval-viewer/viewer.html +0 -1325
- package/.claude/skills/skill-creator/references/schemas.md +0 -430
- package/.claude/skills/skill-creator/scripts/__init__.py +0 -0
- package/.claude/skills/skill-creator/scripts/aggregate_benchmark.py +0 -401
- package/.claude/skills/skill-creator/scripts/generate_report.py +0 -326
- package/.claude/skills/skill-creator/scripts/improve_description.py +0 -248
- package/.claude/skills/skill-creator/scripts/package_skill.py +0 -136
- package/.claude/skills/skill-creator/scripts/quick_validate.py +0 -103
- package/.claude/skills/skill-creator/scripts/run_eval.py +0 -310
- package/.claude/skills/skill-creator/scripts/run_loop.py +0 -332
- package/.claude/skills/skill-creator/scripts/utils.py +0 -47
|
@@ -1,280 +1,163 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: code-patterns
|
|
3
3
|
description: |
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
- 命名规范速查
|
|
9
|
-
- Git 提交规范
|
|
10
|
-
- 代码风格检查
|
|
11
|
-
- 避免过度工程
|
|
12
|
-
|
|
13
|
-
触发词:规范、禁止、命名、Git提交、代码风格、不能用、不允许、包名、架构
|
|
14
|
-
|
|
15
|
-
注意:后端 CRUD 开发规范请激活 crud-development,API 开发规范请激活 api-development,数据库设计规范请激活 database-ops。
|
|
4
|
+
通用编码规范指南。涵盖 RESTful API 设计、命名规范、Git 提交规范、代码风格等。
|
|
5
|
+
触发场景:代码审查、规范检查、命名讨论、API 设计。
|
|
6
|
+
触发词:编码规范、代码风格、命名规范、RESTful、Git 提交。
|
|
7
|
+
注意:如果项目有专属技能(如 `leniu-code-patterns`),优先使用专属版本。
|
|
16
8
|
---
|
|
17
9
|
|
|
18
|
-
#
|
|
19
|
-
|
|
20
|
-
## 后端禁令速查表
|
|
21
|
-
|
|
22
|
-
| # | 禁止项 | 错误写法 | 正确写法 |
|
|
23
|
-
|---|--------|---------|---------|
|
|
24
|
-
| 1 | 包名 | `com.ruoyi.*` / `plus.ruoyi.*` | `org.dromara.*` |
|
|
25
|
-
| 2 | 完整引用 | `org.dromara.xxx.Xxx` 内联 | `import` + 短类名 |
|
|
26
|
-
| 3 | 数据返回 | `Map<String, Object>` | 创建 VO 类 |
|
|
27
|
-
| 4 | Service设计 | `extends ServiceImpl<>` | `implements IXxxService` |
|
|
28
|
-
| 5 | 查询构建 | Controller 层 | **Service 层** `buildQueryWrapper()` |
|
|
29
|
-
| 6 | 接口路径 | `/pageXxxs`, `/getXxx/{id}` | `/list`, `/{id}`, `/` |
|
|
30
|
-
| 7 | 对象转换 | `BeanUtil.copyProperties()` | `MapstructUtils.convert()` |
|
|
31
|
-
| 8 | 主键 | `AUTO_INCREMENT` | 雪花ID(不指定type) |
|
|
32
|
-
| 9 | R.ok(string) | `R.ok(token)` | `R.ok(null, token)` |
|
|
33
|
-
| 10 | Entity基类 | 无基类 | `extends TenantEntity` / `BaseEntity` |
|
|
34
|
-
| 11 | @Cacheable | 返回 `List.of()`/`Set.of()` | `new ArrayList<>(List.of())` |
|
|
35
|
-
| 12 | Mapper注解 | 单目标用 `@AutoMappers` | 单目标用 `@AutoMapper` |
|
|
36
|
-
| 13 | 注释语言 | 英文注释 | **中文注释** |
|
|
37
|
-
| 14 | SQL COMMENT | `COMMENT 'user name'` | `COMMENT '用户名'` |
|
|
38
|
-
|
|
39
|
-
---
|
|
40
|
-
|
|
41
|
-
## 禁令详解
|
|
42
|
-
|
|
43
|
-
### 1-2. 包名与引用
|
|
44
|
-
|
|
45
|
-
```java
|
|
46
|
-
// ✅
|
|
47
|
-
package org.dromara.system.service;
|
|
48
|
-
import org.dromara.common.core.domain.R;
|
|
49
|
-
public R<XxxVo> getXxx(Long id) { ... }
|
|
50
|
-
|
|
51
|
-
// ❌
|
|
52
|
-
package com.ruoyi.system.service;
|
|
53
|
-
public org.dromara.common.core.domain.R<XxxVo> getXxx(Long id) { ... }
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### 3. 禁止 Map 传业务数据
|
|
10
|
+
# 编码规范指南
|
|
57
11
|
|
|
58
|
-
|
|
59
|
-
// ✅ 创建 VO 类
|
|
60
|
-
public XxxVo getXxx(Long id) {
|
|
61
|
-
return MapstructUtils.convert(entity, XxxVo.class);
|
|
62
|
-
}
|
|
12
|
+
> 通用模板。如果项目有专属技能(如 `leniu-code-patterns`),优先使用。
|
|
63
13
|
|
|
64
|
-
|
|
65
|
-
public Map<String, Object> getXxx(Long id) { ... }
|
|
66
|
-
```
|
|
14
|
+
## 核心规范
|
|
67
15
|
|
|
68
|
-
###
|
|
16
|
+
### RESTful API 设计
|
|
69
17
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
lqw.eq(bo.getStatus() != null, Xxx::getStatus, bo.getStatus());
|
|
79
|
-
lqw.like(StringUtils.isNotBlank(bo.getName()), Xxx::getName, bo.getName());
|
|
80
|
-
return lqw;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
18
|
+
| 操作 | HTTP 方法 | URL 示例 | 说明 |
|
|
19
|
+
|------|----------|---------|------|
|
|
20
|
+
| 创建 | POST | `/api/v1/orders` | 请求体传参 |
|
|
21
|
+
| 查询列表 | GET | `/api/v1/orders` | Query 参数分页 |
|
|
22
|
+
| 查询详情 | GET | `/api/v1/orders/{id}` | 路径参数 |
|
|
23
|
+
| 全量更新 | PUT | `/api/v1/orders/{id}` | 请求体传参 |
|
|
24
|
+
| 部分更新 | PATCH | `/api/v1/orders/{id}` | 请求体传参 |
|
|
25
|
+
| 删除 | DELETE | `/api/v1/orders/{id}` | 路径参数 |
|
|
83
26
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
27
|
+
**URL 规范**:
|
|
28
|
+
- 使用名词复数:`/orders` 而非 `/order`
|
|
29
|
+
- 使用小写连字符:`/order-items` 而非 `/orderItems`
|
|
30
|
+
- 版本号放 URL 前缀:`/api/v1/`
|
|
31
|
+
- 嵌套资源不超过两层:`/orders/{id}/items`
|
|
87
32
|
|
|
88
|
-
###
|
|
33
|
+
### 命名规范
|
|
89
34
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
@PostMapping("/addAd") @PutMapping("/updateAd")
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
### 7. 对象转换
|
|
102
|
-
|
|
103
|
-
```java
|
|
104
|
-
// ✅ MapstructUtils
|
|
105
|
-
XxxVo vo = MapstructUtils.convert(entity, XxxVo.class);
|
|
106
|
-
List<XxxVo> voList = MapstructUtils.convert(entityList, XxxVo.class);
|
|
107
|
-
|
|
108
|
-
// ❌ BeanUtil
|
|
109
|
-
BeanUtil.copyProperties(entity, vo);
|
|
110
|
-
```
|
|
35
|
+
| 类型 | 风格 | 示例 |
|
|
36
|
+
|------|------|------|
|
|
37
|
+
| 类名 | UpperCamelCase | `OrderService`, `UserController` |
|
|
38
|
+
| 方法名 | lowerCamelCase | `createOrder()`, `getUserById()` |
|
|
39
|
+
| 变量名 | lowerCamelCase | `orderNo`, `userName` |
|
|
40
|
+
| 常量 | UPPER_SNAKE_CASE | `MAX_RETRY_COUNT`, `DEFAULT_PAGE_SIZE` |
|
|
41
|
+
| 包名 | 全小写 | `com.example.order` |
|
|
42
|
+
| 数据库表/字段 | lower_snake_case | `t_order`, `order_no` |
|
|
111
43
|
|
|
112
|
-
|
|
44
|
+
**类命名约定**:
|
|
113
45
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
46
|
+
| 后缀 | 用途 | 示例 |
|
|
47
|
+
|------|------|------|
|
|
48
|
+
| `Controller` | 控制器 | `OrderController` |
|
|
49
|
+
| `Service` / `ServiceImpl` | 服务层 | `OrderServiceImpl` |
|
|
50
|
+
| `Mapper` / `Repository` | 数据访问 | `OrderMapper` |
|
|
51
|
+
| `DTO` | 请求参数 | `OrderCreateDTO` |
|
|
52
|
+
| `VO` | 响应对象 | `OrderVO` |
|
|
53
|
+
| `Enum` | 枚举 | `OrderStatusEnum` |
|
|
54
|
+
| `Config` | 配置类 | `RedisConfig` |
|
|
55
|
+
| `Handler` | 处理器 | `GlobalExceptionHandler` |
|
|
56
|
+
| `Interceptor` | 拦截器 | `AuthInterceptor` |
|
|
57
|
+
| `Utils` / `Helper` | 工具类 | `DateUtils` |
|
|
58
|
+
|
|
59
|
+
### 方法命名约定
|
|
60
|
+
|
|
61
|
+
| 前缀 | 含义 | 示例 |
|
|
62
|
+
|------|------|------|
|
|
63
|
+
| `create` / `add` | 创建 | `createOrder()` |
|
|
64
|
+
| `update` / `modify` | 更新 | `updateStatus()` |
|
|
65
|
+
| `delete` / `remove` | 删除 | `deleteById()` |
|
|
66
|
+
| `get` / `find` / `query` | 查询 | `getById()`, `findByName()` |
|
|
67
|
+
| `list` | 查询列表 | `listByStatus()` |
|
|
68
|
+
| `page` | 分页查询 | `pageQuery()` |
|
|
69
|
+
| `count` | 计数 | `countByStatus()` |
|
|
70
|
+
| `is` / `has` / `can` | 布尔判断 | `isValid()`, `hasPermission()` |
|
|
71
|
+
| `check` / `validate` | 校验 | `checkDuplicate()` |
|
|
72
|
+
| `convert` / `to` | 转换 | `convertToVO()`, `toDTO()` |
|
|
73
|
+
|
|
74
|
+
### Git 提交规范(Conventional Commits)
|
|
117
75
|
|
|
118
|
-
-- ❌
|
|
119
|
-
id BIGINT(20) AUTO_INCREMENT
|
|
120
76
|
```
|
|
77
|
+
<type>(<scope>): <subject>
|
|
121
78
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
```java
|
|
125
|
-
// ❌ 匹配 R.ok(String msg),字符串进入 msg 而非 data
|
|
126
|
-
return R.ok(token); // {code:200, msg:"xxx", data:null}
|
|
79
|
+
<body>
|
|
127
80
|
|
|
128
|
-
|
|
129
|
-
return R.ok(null, token); // data=token, msg=null
|
|
130
|
-
return R.ok("获取成功", token); // 都有值
|
|
81
|
+
<footer>
|
|
131
82
|
```
|
|
132
83
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
// ❌ 不继承基类
|
|
146
|
-
public class Xxx { }
|
|
84
|
+
| type | 说明 |
|
|
85
|
+
|------|------|
|
|
86
|
+
| `feat` | 新功能 |
|
|
87
|
+
| `fix` | 修复 Bug |
|
|
88
|
+
| `docs` | 文档变更 |
|
|
89
|
+
| `style` | 代码格式(不影响逻辑) |
|
|
90
|
+
| `refactor` | 重构(非新功能、非修复) |
|
|
91
|
+
| `perf` | 性能优化 |
|
|
92
|
+
| `test` | 测试相关 |
|
|
93
|
+
| `chore` | 构建/工具变更 |
|
|
94
|
+
|
|
95
|
+
**示例**:
|
|
147
96
|
```
|
|
97
|
+
feat(order): 新增订单导出功能
|
|
148
98
|
|
|
149
|
-
|
|
99
|
+
支持按时间范围导出订单数据为 Excel 格式。
|
|
150
100
|
|
|
151
|
-
|
|
152
|
-
// ❌ Redis 反序列化失败
|
|
153
|
-
@Cacheable(value = "xxx")
|
|
154
|
-
public List<String> listXxx() { return List.of("1", "2"); }
|
|
155
|
-
|
|
156
|
-
// ✅ 可变集合包装
|
|
157
|
-
@Cacheable(value = "xxx")
|
|
158
|
-
public List<String> listXxx() { return new ArrayList<>(List.of("1", "2")); }
|
|
101
|
+
Closes #123
|
|
159
102
|
```
|
|
160
103
|
|
|
161
|
-
|
|
104
|
+
## 代码示例
|
|
162
105
|
|
|
163
|
-
###
|
|
106
|
+
### 统一响应格式
|
|
164
107
|
|
|
165
108
|
```java
|
|
166
|
-
|
|
167
|
-
@
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
### 13-14. 中文注释与 SQL COMMENT
|
|
109
|
+
@Data
|
|
110
|
+
@AllArgsConstructor
|
|
111
|
+
@NoArgsConstructor
|
|
112
|
+
public class Result<T> {
|
|
113
|
+
private int code;
|
|
114
|
+
private String message;
|
|
115
|
+
private T data;
|
|
116
|
+
|
|
117
|
+
public static <T> Result<T> ok(T data) {
|
|
118
|
+
return new Result<>(200, "success", data);
|
|
119
|
+
}
|
|
179
120
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
public SysUserVo queryById(Long id) {
|
|
184
|
-
// 查询用户基本信息
|
|
185
|
-
return baseMapper.selectVoById(id);
|
|
121
|
+
public static <T> Result<T> fail(int code, String message) {
|
|
122
|
+
return new Result<>(code, message, null);
|
|
123
|
+
}
|
|
186
124
|
}
|
|
187
|
-
|
|
188
|
-
// ❌ 英文注释
|
|
189
|
-
/** Query user info by ID */
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
```sql
|
|
193
|
-
-- ✅
|
|
194
|
-
`user_name` VARCHAR(50) NOT NULL COMMENT '用户名',
|
|
195
|
-
) ENGINE=InnoDB COMMENT='用户信息表';
|
|
196
|
-
|
|
197
|
-
-- ❌
|
|
198
|
-
`user_name` VARCHAR(50) NOT NULL COMMENT 'user name',
|
|
199
125
|
```
|
|
200
126
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
## 命名后缀规范
|
|
204
|
-
|
|
205
|
-
| 类型 | 后缀 | 示例 |
|
|
206
|
-
|------|------|------|
|
|
207
|
-
| 实体类 | 无/Sys前缀 | `SysUser`, `TestDemo` |
|
|
208
|
-
| 业务对象 | Bo | `SysUserBo` |
|
|
209
|
-
| 视图对象 | Vo | `SysUserVo` |
|
|
210
|
-
| 服务接口 | IXxxService | `ISysUserService` |
|
|
211
|
-
| 服务实现 | XxxServiceImpl | `SysUserServiceImpl` |
|
|
212
|
-
| 控制器 | XxxController | `SysUserController` |
|
|
213
|
-
| Mapper | XxxMapper | `SysUserMapper` |
|
|
214
|
-
|
|
215
|
-
> 本项目是三层架构,没有 DAO 层。Service 直接注入 Mapper。
|
|
216
|
-
|
|
217
|
-
## 方法命名
|
|
218
|
-
|
|
219
|
-
| 操作 | Service 方法 | Controller URL |
|
|
220
|
-
|------|-------------|----------------|
|
|
221
|
-
| 分页查询 | `queryPageList(bo, pageQuery)` | `GET /list` |
|
|
222
|
-
| 查询单个 | `queryById(id)` | `GET /{id}` |
|
|
223
|
-
| 新增 | `insertByBo(bo)` | `POST /` |
|
|
224
|
-
| 修改 | `updateByBo(bo)` | `PUT /` |
|
|
225
|
-
| 删除 | `deleteWithValidByIds(ids)` | `DELETE /{ids}` |
|
|
226
|
-
| 导出 | `queryList(bo)` + ExcelUtil | `POST /export` |
|
|
227
|
-
|
|
228
|
-
---
|
|
229
|
-
|
|
230
|
-
## Git 提交规范
|
|
231
|
-
|
|
232
|
-
```
|
|
233
|
-
<type>(<scope>): <description>
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
| type | 说明 | 示例 |
|
|
237
|
-
|------|------|------|
|
|
238
|
-
| `feat` | 新功能 | `feat(system): 新增用户反馈功能` |
|
|
239
|
-
| `fix` | 修复 | `fix(demo): 修复订单状态显示错误` |
|
|
240
|
-
| `refactor` | 重构 | `refactor(common): 重构分页查询工具类` |
|
|
241
|
-
| `perf` | 性能 | `perf(system): 优化用户列表查询性能` |
|
|
242
|
-
| `docs` | 文档 | `docs(readme): 更新安装说明` |
|
|
243
|
-
| `style` | 格式 | `chore` 构建/工具 | `test` 测试 |
|
|
244
|
-
|
|
245
|
-
---
|
|
246
|
-
|
|
247
|
-
## 多项目适配
|
|
248
|
-
|
|
249
|
-
| 特征 | RuoYi-Vue-Plus | leniu-tengyun-core |
|
|
250
|
-
|------|----------------|-------------------|
|
|
251
|
-
| 包名 | `org.dromara.*` | `net.xnzn.core.*` |
|
|
252
|
-
| JDK | 17 | 21 |
|
|
253
|
-
| 对象转换 | `MapstructUtils.convert()` | `BeanUtil.copyProperties()` |
|
|
254
|
-
| 分页 | `TableDataInfo<T>` | `Page<T>` |
|
|
255
|
-
| 异常 | `ServiceException` | `LeException` |
|
|
256
|
-
| 工具库 | 自定义工具类 | Hutool |
|
|
257
|
-
|
|
258
|
-
### leniu-tengyun-core 专用
|
|
127
|
+
### 枚举定义规范
|
|
259
128
|
|
|
260
129
|
```java
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
130
|
+
@Getter
|
|
131
|
+
@AllArgsConstructor
|
|
132
|
+
public enum OrderStatusEnum {
|
|
133
|
+
|
|
134
|
+
PENDING(0, "待处理"),
|
|
135
|
+
COMPLETED(1, "已完成"),
|
|
136
|
+
CANCELLED(2, "已取消");
|
|
137
|
+
|
|
138
|
+
private final int code;
|
|
139
|
+
private final String desc;
|
|
140
|
+
|
|
141
|
+
public static OrderStatusEnum of(int code) {
|
|
142
|
+
for (OrderStatusEnum status : values()) {
|
|
143
|
+
if (status.code == code) {
|
|
144
|
+
return status;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
throw new IllegalArgumentException("未知状态码: " + code);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
269
150
|
```
|
|
270
151
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
|
276
|
-
|
|
277
|
-
|
|
|
278
|
-
|
|
|
279
|
-
|
|
|
280
|
-
|
|
|
152
|
+
## 常见错误
|
|
153
|
+
|
|
154
|
+
| 错误 | 正确做法 |
|
|
155
|
+
|------|---------|
|
|
156
|
+
| URL 用动词:`/getOrder` | 用名词 + HTTP 方法:`GET /orders/{id}` |
|
|
157
|
+
| 方法名含义不清:`process()` | 明确动作:`calculateTotalAmount()` |
|
|
158
|
+
| 魔法数字:`if (status == 1)` | 用枚举或常量 |
|
|
159
|
+
| 一个方法超过 80 行 | 拆分为多个私有方法 |
|
|
160
|
+
| 注释描述"做了什么" | 注释描述"为什么这样做" |
|
|
161
|
+
| Git 提交信息写"fix bug" | 写清楚修了什么:`fix(order): 修复金额计算精度丢失` |
|
|
162
|
+
| Boolean 变量名:`flag` | 有意义的名字:`isActive`, `hasPermission` |
|
|
163
|
+
| 缩写命名:`usr`, `mgr` | 完整命名:`user`, `manager` |
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: collaborating-with-codex
|
|
3
3
|
description: |
|
|
4
|
-
与 OpenAI Codex CLI
|
|
4
|
+
与 OpenAI Codex CLI 协同开发。支持 MCP 原生集成和桥接脚本两种模式。
|
|
5
|
+
默认模型:gpt-5.3-codex
|
|
5
6
|
|
|
6
7
|
触发场景:
|
|
7
8
|
- 需要算法实现或复杂逻辑分析
|
|
@@ -14,161 +15,143 @@ description: |
|
|
|
14
15
|
|
|
15
16
|
前置要求:
|
|
16
17
|
- 已安装 Codex CLI (npm install -g @openai/codex)
|
|
17
|
-
- 已配置 OpenAI API Key
|
|
18
|
+
- 已配置 OpenAI API Key (codex auth login)
|
|
18
19
|
---
|
|
19
20
|
|
|
20
21
|
# 与 Codex CLI 协同开发
|
|
21
22
|
|
|
22
|
-
>
|
|
23
|
+
> 两种调用方式:**MCP 原生集成**(推荐)和桥接脚本。默认模型 `gpt-5.3-codex`。
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
---
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
## 方式一:MCP 原生集成(推荐)
|
|
28
|
+
|
|
29
|
+
已通过 `codex-mcp-server` 注册为 Claude Code 的 MCP 工具,可直接在对话中使用。
|
|
30
|
+
|
|
31
|
+
### MCP 工具列表
|
|
32
|
+
|
|
33
|
+
| 工具 | 用途 | 示例指令 |
|
|
34
|
+
|------|------|---------|
|
|
35
|
+
| `codex` | AI 编码助手,支持会话、模型选择 | "用 codex 分析这个函数" |
|
|
36
|
+
| `review` | 代码审查(未提交代码、分支、提交) | "用 codex review 检查 main 分支差异" |
|
|
37
|
+
| `listSessions` | 查看活跃会话 | "列出 codex 会话" |
|
|
38
|
+
| `ping` | 测试连接 | "ping codex" |
|
|
39
|
+
|
|
40
|
+
### MCP 使用示例
|
|
41
|
+
|
|
42
|
+
**基础调用**:直接在 Claude Code 对话中说:
|
|
43
|
+
- "用 codex 工具分析 OrderInfoService 的业务逻辑"
|
|
44
|
+
- "用 codex review 检查当前未提交的代码变更"
|
|
45
|
+
- "用 codex 生成这个方法的单元测试,模型用 gpt-5.3-codex"
|
|
46
|
+
|
|
47
|
+
**多轮会话**:codex 工具支持 `sessionId` 参数,自动维持上下文。
|
|
48
|
+
|
|
49
|
+
**模型指定**:调用时传入 `model: "gpt-5.3-codex"` 参数(已配置为默认)。
|
|
50
|
+
|
|
51
|
+
### MCP 配置位置
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
~/.claude.json → projects → mcpServers → codex-cli
|
|
55
|
+
~/.codex/config.toml → profiles(review/analyze/prototype)
|
|
29
56
|
```
|
|
30
57
|
|
|
31
|
-
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 方式二:桥接脚本
|
|
61
|
+
|
|
62
|
+
适用于需要精细控制参数或后台批量执行的场景。
|
|
63
|
+
|
|
64
|
+
### 快速开始
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
|
|
68
|
+
--cd . --model gpt-5.3-codex --PROMPT "Your task"
|
|
69
|
+
```
|
|
32
70
|
|
|
33
|
-
|
|
71
|
+
### 参数说明
|
|
34
72
|
|
|
35
73
|
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|
|
36
74
|
|------|------|------|--------|------|
|
|
37
75
|
| `--PROMPT` | str | ✅ | - | 发送给 Codex 的任务指令(使用英语) |
|
|
38
76
|
| `--cd` | Path | ✅ | - | 工作目录根路径 |
|
|
39
|
-
| `--
|
|
77
|
+
| `--model` | str | ❌ | `gpt-5.3-codex` | 指定模型 |
|
|
78
|
+
| `--sandbox` | Literal | ❌ | `read-only` | 沙箱策略 |
|
|
40
79
|
| `--SESSION_ID` | UUID | ❌ | `None` | 会话 ID(继续之前的对话) |
|
|
41
|
-
| `--
|
|
80
|
+
| `--profile` | str | ❌ | `None` | Codex profile(review/analyze/prototype) |
|
|
42
81
|
| `--return-all-messages` | bool | ❌ | `False` | 返回完整推理信息 |
|
|
43
|
-
| `--image` | List[Path] | ❌ | `None` |
|
|
44
|
-
| `--
|
|
45
|
-
| `--yolo` | bool | ❌ | `False` | 跳过所有审批与沙箱限制(危险) |
|
|
82
|
+
| `--image` | List[Path] | ❌ | `None` | 附加图片 |
|
|
83
|
+
| `--yolo` | bool | ❌ | `False` | 跳过审批(危险) |
|
|
46
84
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
### 1. 基础调用(只读模式)
|
|
85
|
+
### 使用示例
|
|
50
86
|
|
|
51
87
|
```bash
|
|
88
|
+
# 代码分析(只读)
|
|
52
89
|
python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
|
|
53
|
-
--cd . \
|
|
54
|
-
--PROMPT "Analyze the
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
### 2. 多轮会话
|
|
90
|
+
--cd . --model gpt-5.3-codex --profile analyze \
|
|
91
|
+
--PROMPT "Analyze the four-layer architecture in OrderInfoWebController"
|
|
58
92
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
# 第一轮:分析代码
|
|
93
|
+
# 代码审查
|
|
63
94
|
python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
|
|
64
|
-
--cd
|
|
65
|
-
--PROMPT "
|
|
95
|
+
--cd . --model gpt-5.3-codex --profile review \
|
|
96
|
+
--PROMPT "Review OrderWebBusiness.java for bugs. OUTPUT: Review with line numbers."
|
|
66
97
|
|
|
67
|
-
#
|
|
98
|
+
# 生成 Diff 补丁
|
|
68
99
|
python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
|
|
69
|
-
--cd
|
|
70
|
-
--
|
|
71
|
-
--PROMPT "Now write unit tests for the add method"
|
|
72
|
-
```
|
|
100
|
+
--cd . --model gpt-5.3-codex \
|
|
101
|
+
--PROMPT "Generate unified diff to add logging. OUTPUT: Unified Diff Patch ONLY."
|
|
73
102
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
```bash
|
|
103
|
+
# 多轮会话
|
|
77
104
|
python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
|
|
78
|
-
--cd
|
|
79
|
-
--
|
|
105
|
+
--cd . --model gpt-5.3-codex \
|
|
106
|
+
--SESSION_ID "uuid-from-previous" \
|
|
107
|
+
--PROMPT "Now write unit tests for the method we discussed"
|
|
80
108
|
```
|
|
81
109
|
|
|
82
|
-
|
|
110
|
+
---
|
|
83
111
|
|
|
84
|
-
|
|
85
|
-
python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
|
|
86
|
-
--cd "/project" \
|
|
87
|
-
--PROMPT "Debug this error: NullPointerException in line 42" \
|
|
88
|
-
--return-all-messages
|
|
89
|
-
```
|
|
112
|
+
## Codex Profile 配置
|
|
90
113
|
|
|
91
|
-
|
|
114
|
+
已在 `~/.codex/config.toml` 中预设 3 个 profile:
|
|
92
115
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
"agent_messages": "模型回复内容..."
|
|
99
|
-
}
|
|
100
|
-
```
|
|
116
|
+
| Profile | 模型 | 沙箱 | 推理强度 | 适用场景 |
|
|
117
|
+
|---------|------|------|---------|---------|
|
|
118
|
+
| `review` | gpt-5.3-codex | read-only | medium | 快速代码审查 |
|
|
119
|
+
| `analyze` | gpt-5.3-codex | read-only | high | 深度逻辑分析 |
|
|
120
|
+
| `prototype` | gpt-5.3-codex | workspace-write | high | 原型生成 |
|
|
101
121
|
|
|
102
|
-
|
|
103
|
-
```json
|
|
104
|
-
{
|
|
105
|
-
"success": false,
|
|
106
|
-
"error": "错误信息描述"
|
|
107
|
-
}
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
## 协作工作流
|
|
122
|
+
---
|
|
111
123
|
|
|
112
|
-
|
|
124
|
+
## 协作分工原则
|
|
113
125
|
|
|
114
|
-
|
|
|
115
|
-
|
|
116
|
-
|
|
|
117
|
-
|
|
|
118
|
-
|
|
|
119
|
-
|
|
|
126
|
+
| 角色 | Claude Code 负责 | Codex 负责 |
|
|
127
|
+
|------|-----------------|-----------|
|
|
128
|
+
| **架构** | 设计、决策、审校 | 分析现有代码 |
|
|
129
|
+
| **开发** | 规范重构、最终代码 | 原型生成(Diff) |
|
|
130
|
+
| **审查** | 规范检查、最终判定 | 逐文件审查、安全扫描 |
|
|
131
|
+
| **调试** | 日志分析、定位 | 深度代码分析、补丁 |
|
|
120
132
|
|
|
121
133
|
### 重要约束
|
|
122
134
|
|
|
123
|
-
1.
|
|
124
|
-
2.
|
|
125
|
-
3.
|
|
135
|
+
1. **只读优先**: 默认 `read-only`,仅原型生成用 `workspace-write`
|
|
136
|
+
2. **英语 Prompt**: 与 Codex 交互用英语
|
|
137
|
+
3. **中文强制**: 每次 PROMPT 末尾追加:
|
|
126
138
|
```
|
|
127
139
|
IMPORTANT LANGUAGE RULES:
|
|
128
|
-
- All SQL COMMENT values MUST be in Chinese
|
|
129
|
-
- All Java/code comments
|
|
130
|
-
-
|
|
131
|
-
- Variable names and class names remain in English (camelCase/PascalCase)
|
|
140
|
+
- All SQL COMMENT values MUST be in Chinese
|
|
141
|
+
- All Java/code comments MUST be in Chinese
|
|
142
|
+
- Variable names and class names remain in English
|
|
132
143
|
```
|
|
133
|
-
4.
|
|
134
|
-
5.
|
|
135
|
-
6. **后台运行**: 对于长时间任务,使用 `Run in the background`
|
|
136
|
-
|
|
137
|
-
## 与本项目的集成
|
|
138
|
-
|
|
139
|
-
### 典型用例:后端模块分析
|
|
140
|
-
|
|
141
|
-
```bash
|
|
142
|
-
# 分析 Service 层实现
|
|
143
|
-
python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
|
|
144
|
-
--cd . \
|
|
145
|
-
--PROMPT "Analyze the three-layer architecture (Controller -> Service -> Mapper) in ruoyi-modules/ruoyi-system. Focus on how buildQueryWrapper is implemented in Service layer."
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
### 典型用例:代码审查
|
|
144
|
+
4. **脏原型思维**: Codex 输出视为草稿,Claude 按项目规范重构
|
|
145
|
+
5. **后台运行**: 长时间任务用 subagent `run_in_background`
|
|
149
146
|
|
|
150
|
-
|
|
151
|
-
# 审查新增的业务模块
|
|
152
|
-
python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
|
|
153
|
-
--cd "/project" \
|
|
154
|
-
--PROMPT "Review the XxxServiceImpl.java for potential bugs, security issues, and adherence to the project's three-layer architecture pattern (Controller -> Service -> Mapper, NO DAO layer). OUTPUT: Review comments with specific line numbers."
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
## 安装前置
|
|
158
|
-
|
|
159
|
-
```bash
|
|
160
|
-
# 安装 Codex CLI
|
|
161
|
-
npm install -g @openai/codex
|
|
162
|
-
|
|
163
|
-
# 配置 API Key(可选,如果未设置环境变量)
|
|
164
|
-
codex auth login
|
|
165
|
-
```
|
|
147
|
+
---
|
|
166
148
|
|
|
167
149
|
## 故障排除
|
|
168
150
|
|
|
169
151
|
| 问题 | 解决方案 |
|
|
170
152
|
|------|---------|
|
|
171
|
-
|
|
|
172
|
-
| `
|
|
173
|
-
|
|
|
174
|
-
|
|
|
153
|
+
| MCP 工具未出现 | 重启 Claude Code 会话,检查 `~/.claude.json` |
|
|
154
|
+
| `codex: command not found` | `npm i -g @openai/codex` 并确认 PATH |
|
|
155
|
+
| 模型不对 | 调用时显式传 `model: "gpt-5.3-codex"` |
|
|
156
|
+
| MCP 连接超时 | `npx -y codex-mcp-server` 手动测试 |
|
|
157
|
+
| 桥接脚本 SESSION_ID 失败 | 检查网络和 API Key |
|