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.
Files changed (118) hide show
  1. package/.claude/hooks/skill-forced-eval.js +46 -62
  2. package/.claude/settings.json +10 -1
  3. package/.claude/skills/api-development/SKILL.md +179 -130
  4. package/.claude/skills/architecture-design/SKILL.md +102 -212
  5. package/.claude/skills/backend-annotations/SKILL.md +166 -220
  6. package/.claude/skills/bug-detective/SKILL.md +225 -186
  7. package/.claude/skills/code-patterns/SKILL.md +127 -244
  8. package/.claude/skills/collaborating-with-codex/SKILL.md +96 -113
  9. package/.claude/skills/crud-development/SKILL.md +226 -307
  10. package/.claude/skills/data-permission/SKILL.md +131 -202
  11. package/.claude/skills/database-ops/SKILL.md +158 -355
  12. package/.claude/skills/error-handler/SKILL.md +224 -285
  13. package/.claude/skills/file-oss-management/SKILL.md +174 -169
  14. package/.claude/skills/git-workflow/SKILL.md +123 -341
  15. package/.claude/skills/json-serialization/SKILL.md +121 -137
  16. package/.claude/skills/performance-doctor/SKILL.md +83 -89
  17. package/.claude/skills/redis-cache/SKILL.md +134 -185
  18. package/.claude/skills/scheduled-jobs/SKILL.md +187 -224
  19. package/.claude/skills/security-guard/SKILL.md +168 -276
  20. package/.claude/skills/sms-mail/SKILL.md +266 -228
  21. package/.claude/skills/social-login/SKILL.md +257 -195
  22. package/.claude/skills/tenant-management/SKILL.md +172 -188
  23. package/.claude/skills/utils-toolkit/SKILL.md +214 -222
  24. package/.claude/skills/websocket-sse/SKILL.md +251 -172
  25. package/.claude/skills/workflow-engine/SKILL.md +178 -250
  26. package/.codex/skills/api-development/SKILL.md +179 -130
  27. package/.codex/skills/architecture-design/SKILL.md +102 -212
  28. package/.codex/skills/backend-annotations/SKILL.md +166 -220
  29. package/.codex/skills/bug-detective/SKILL.md +225 -186
  30. package/.codex/skills/code-patterns/SKILL.md +127 -244
  31. package/.codex/skills/collaborating-with-codex/SKILL.md +96 -113
  32. package/.codex/skills/crud-development/SKILL.md +226 -307
  33. package/.codex/skills/data-permission/SKILL.md +131 -202
  34. package/.codex/skills/database-ops/SKILL.md +158 -355
  35. package/.codex/skills/error-handler/SKILL.md +224 -285
  36. package/.codex/skills/file-oss-management/SKILL.md +174 -169
  37. package/.codex/skills/git-workflow/SKILL.md +123 -341
  38. package/.codex/skills/json-serialization/SKILL.md +121 -137
  39. package/.codex/skills/performance-doctor/SKILL.md +83 -89
  40. package/.codex/skills/redis-cache/SKILL.md +134 -185
  41. package/.codex/skills/scheduled-jobs/SKILL.md +187 -224
  42. package/.codex/skills/security-guard/SKILL.md +168 -276
  43. package/.codex/skills/sms-mail/SKILL.md +266 -228
  44. package/.codex/skills/social-login/SKILL.md +257 -195
  45. package/.codex/skills/tenant-management/SKILL.md +172 -188
  46. package/.codex/skills/utils-toolkit/SKILL.md +214 -222
  47. package/.codex/skills/websocket-sse/SKILL.md +251 -172
  48. package/.codex/skills/workflow-engine/SKILL.md +178 -250
  49. package/.cursor/hooks/cursor-skill-eval.js +66 -6
  50. package/.cursor/skills/api-development/SKILL.md +179 -130
  51. package/.cursor/skills/architecture-design/SKILL.md +102 -212
  52. package/.cursor/skills/backend-annotations/SKILL.md +166 -220
  53. package/.cursor/skills/bug-detective/SKILL.md +225 -186
  54. package/.cursor/skills/code-patterns/SKILL.md +127 -244
  55. package/.cursor/skills/collaborating-with-codex/SKILL.md +96 -113
  56. package/.cursor/skills/crud-development/SKILL.md +226 -307
  57. package/.cursor/skills/data-permission/SKILL.md +131 -202
  58. package/.cursor/skills/database-ops/SKILL.md +158 -355
  59. package/.cursor/skills/error-handler/SKILL.md +224 -285
  60. package/.cursor/skills/file-oss-management/SKILL.md +174 -169
  61. package/.cursor/skills/git-workflow/SKILL.md +123 -341
  62. package/.cursor/skills/json-serialization/SKILL.md +121 -137
  63. package/.cursor/skills/performance-doctor/SKILL.md +83 -89
  64. package/.cursor/skills/redis-cache/SKILL.md +134 -185
  65. package/.cursor/skills/scheduled-jobs/SKILL.md +187 -224
  66. package/.cursor/skills/security-guard/SKILL.md +168 -276
  67. package/.cursor/skills/sms-mail/SKILL.md +266 -228
  68. package/.cursor/skills/social-login/SKILL.md +257 -195
  69. package/.cursor/skills/tenant-management/SKILL.md +172 -188
  70. package/.cursor/skills/utils-toolkit/SKILL.md +214 -222
  71. package/.cursor/skills/websocket-sse/SKILL.md +251 -172
  72. package/.cursor/skills/workflow-engine/SKILL.md +178 -250
  73. package/AGENTS.md +49 -540
  74. package/CLAUDE.md +73 -119
  75. package/README.md +37 -6
  76. package/bin/index.js +5 -1
  77. package/package.json +1 -1
  78. package/src/skills/api-development/SKILL.md +179 -130
  79. package/src/skills/architecture-design/SKILL.md +102 -212
  80. package/src/skills/backend-annotations/SKILL.md +166 -220
  81. package/src/skills/bug-detective/SKILL.md +225 -186
  82. package/src/skills/code-patterns/SKILL.md +127 -244
  83. package/src/skills/collaborating-with-codex/SKILL.md +96 -113
  84. package/src/skills/crud-development/SKILL.md +226 -307
  85. package/src/skills/data-permission/SKILL.md +131 -202
  86. package/src/skills/database-ops/SKILL.md +158 -355
  87. package/src/skills/error-handler/SKILL.md +224 -285
  88. package/src/skills/file-oss-management/SKILL.md +174 -169
  89. package/src/skills/git-workflow/SKILL.md +123 -341
  90. package/src/skills/json-serialization/SKILL.md +121 -137
  91. package/src/skills/performance-doctor/SKILL.md +83 -89
  92. package/src/skills/redis-cache/SKILL.md +134 -185
  93. package/src/skills/scheduled-jobs/SKILL.md +187 -224
  94. package/src/skills/security-guard/SKILL.md +168 -276
  95. package/src/skills/sms-mail/SKILL.md +266 -228
  96. package/src/skills/social-login/SKILL.md +257 -195
  97. package/src/skills/tenant-management/SKILL.md +172 -188
  98. package/src/skills/utils-toolkit/SKILL.md +214 -222
  99. package/src/skills/websocket-sse/SKILL.md +251 -172
  100. package/src/skills/workflow-engine/SKILL.md +178 -250
  101. package/.claude/skills/skill-creator/LICENSE.txt +0 -202
  102. package/.claude/skills/skill-creator/SKILL.md +0 -479
  103. package/.claude/skills/skill-creator/agents/analyzer.md +0 -274
  104. package/.claude/skills/skill-creator/agents/comparator.md +0 -202
  105. package/.claude/skills/skill-creator/agents/grader.md +0 -223
  106. package/.claude/skills/skill-creator/assets/eval_review.html +0 -146
  107. package/.claude/skills/skill-creator/eval-viewer/generate_review.py +0 -471
  108. package/.claude/skills/skill-creator/eval-viewer/viewer.html +0 -1325
  109. package/.claude/skills/skill-creator/references/schemas.md +0 -430
  110. package/.claude/skills/skill-creator/scripts/__init__.py +0 -0
  111. package/.claude/skills/skill-creator/scripts/aggregate_benchmark.py +0 -401
  112. package/.claude/skills/skill-creator/scripts/generate_report.py +0 -326
  113. package/.claude/skills/skill-creator/scripts/improve_description.py +0 -248
  114. package/.claude/skills/skill-creator/scripts/package_skill.py +0 -136
  115. package/.claude/skills/skill-creator/scripts/quick_validate.py +0 -103
  116. package/.claude/skills/skill-creator/scripts/run_eval.py +0 -310
  117. package/.claude/skills/skill-creator/scripts/run_loop.py +0 -332
  118. 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
- ```java
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
- ### 4-5. Service 架构
16
+ ### RESTful API 设计
69
17
 
70
- ```java
71
- // ✅ 三层架构:不继承 ServiceImpl,直接注入 Mapper
72
- @Service
73
- public class XxxServiceImpl implements IXxxService {
74
- private final XxxMapper baseMapper;
75
-
76
- private LambdaQueryWrapper<Xxx> buildQueryWrapper(XxxBo bo) {
77
- LambdaQueryWrapper<Xxx> lqw = Wrappers.lambdaQuery();
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
- public class XxxServiceImpl extends ServiceImpl<XxxMapper, Xxx> { }
86
- ```
27
+ **URL 规范**:
28
+ - 使用名词复数:`/orders` 而非 `/order`
29
+ - 使用小写连字符:`/order-items` 而非 `/orderItems`
30
+ - 版本号放 URL 前缀:`/api/v1/`
31
+ - 嵌套资源不超过两层:`/orders/{id}/items`
87
32
 
88
- ### 6. RESTful 路径
33
+ ### 命名规范
89
34
 
90
- ```java
91
- // ✅
92
- @GetMapping("/list") @GetMapping("/{id}")
93
- @PostMapping @PutMapping
94
- @DeleteMapping("/{ids}") @PostMapping("/export")
95
-
96
- //
97
- @GetMapping("/pageAds") @GetMapping("/getAd/{id}")
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
- ### 8. 主键策略
44
+ **类命名约定**:
113
45
 
114
- ```sql
115
- -- ✅ 雪花ID
116
- id BIGINT(20) NOT NULL COMMENT '主键ID'
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
- ### 9. R.ok() 返回 String 陷阱
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
- ### 10. Entity 基类
134
-
135
- ```java
136
- // 业务表(需多租户隔离)
137
- public class Xxx extends TenantEntity {
138
- @TableId(value = "id")
139
- private Long id;
140
- }
141
-
142
- // 系统表(不需多租户)
143
- public class SysClient extends BaseEntity { }
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
- ### 11. @Cacheable 不可变集合
99
+ 支持按时间范围导出订单数据为 Excel 格式。
150
100
 
151
- ```java
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
- > **原因**:Jackson DefaultTyping.NON_FINAL 会为 `ImmutableCollections$List12` 添加类型信息,反序列化时导致 `ClassNotFoundException`。
104
+ ## 代码示例
162
105
 
163
- ### 12. BO 映射注解
106
+ ### 统一响应格式
164
107
 
165
108
  ```java
166
- // ✅ 单目标:@AutoMapper
167
- @AutoMapper(target = Xxx.class, reverseConvertGenerate = false)
168
- public class XxxBo { }
169
-
170
- // 多目标:@AutoMappers
171
- @AutoMappers({
172
- @AutoMapper(target = SysOperLog.class, reverseConvertGenerate = false),
173
- @AutoMapper(target = OperLogEvent.class)
174
- })
175
- public class SysOperLogBo { }
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
- ```java
181
- // 中文注释
182
- /** 根据 ID 查询用户信息 */
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
- throw new LeException(I18n.getMessage("user.not.exists"));
263
-
264
- // 租户上下文
265
- Long tenantId = TenantContextHolder.getTenantId();
266
-
267
- // 分页
268
- PageMethod.startPage(param.getPage().getPageNum(), param.getPage().getPageSize());
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
- ## 相关 Skill
274
-
275
- | 需要了解 | 激活 Skill |
276
- |---------|-----------|
277
- | 后端 CRUD 开发 | `crud-development` |
278
- | API 开发 | `api-development` |
279
- | 数据库设计 | `database-ops` |
280
- | 系统架构 | `architecture-design` |
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 协同开发。将编码任务委托给 Codex 进行原型开发、调试分析和代码审查。
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
- > 通过 Python 桥接脚本调用 Codex CLI,获取算法实现和代码审查建议。
23
+ > 两种调用方式:**MCP 原生集成**(推荐)和桥接脚本。默认模型 `gpt-5.3-codex`。
23
24
 
24
- ## 快速开始
25
+ ---
25
26
 
26
- ```bash
27
- # 相对路径(推荐,在项目根目录执行)
28
- python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py --cd . --PROMPT "Your task"
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
- **输出**: JSON 格式,包含 `success`、`SESSION_ID`、`agent_messages` 和可选的 `error`。
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
- | `--sandbox` | Literal | ❌ | `read-only` | 沙箱策略:`read-only`/`workspace-write`/`danger-full-access` |
77
+ | `--model` | str | ❌ | `gpt-5.3-codex` | 指定模型 |
78
+ | `--sandbox` | Literal | ❌ | `read-only` | 沙箱策略 |
40
79
  | `--SESSION_ID` | UUID | ❌ | `None` | 会话 ID(继续之前的对话) |
41
- | `--skip-git-repo-check` | bool | ❌ | `True` | 允许在非 Git 仓库运行 |
80
+ | `--profile` | str | ❌ | `None` | Codex profile(review/analyze/prototype) |
42
81
  | `--return-all-messages` | bool | ❌ | `False` | 返回完整推理信息 |
43
- | `--image` | List[Path] | ❌ | `None` | 附加图片文件到提示词 |
44
- | `--model` | str | ❌ | `None` | 指定模型(仅用户明确要求时使用) |
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 authentication flow in the login module"
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
- **始终保存 SESSION_ID** 用于后续对话:
60
-
61
- ```bash
62
- # 第一轮:分析代码
93
+ # 代码审查
63
94
  python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
64
- --cd "/project" \
65
- --PROMPT "Analyze the AdServiceImpl class"
95
+ --cd . --model gpt-5.3-codex --profile review \
96
+ --PROMPT "Review OrderWebBusiness.java for bugs. OUTPUT: Review with line numbers."
66
97
 
67
- # 后续轮次:使用 SESSION_ID 继续
98
+ # 生成 Diff 补丁
68
99
  python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
69
- --cd "/project" \
70
- --SESSION_ID "uuid-from-previous-response" \
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
- ### 3. 获取 Unified Diff 补丁
75
-
76
- ```bash
103
+ # 多轮会话
77
104
  python .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
78
- --cd "/project" \
79
- --PROMPT "Generate a unified diff to add logging to AdServiceImpl. OUTPUT: Unified Diff Patch ONLY."
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
- ### 4. 调试模式(返回完整信息)
110
+ ---
83
111
 
84
- ```bash
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
- ```json
95
- {
96
- "success": true,
97
- "SESSION_ID": "550e8400-e29b-41d4-a716-446655440000",
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
- | **后端逻辑分析** | Codex 擅长复杂算法和后端逻辑 |
117
- | **代码审查** | 获取代码质量和潜在问题的反馈 |
118
- | **Debug 分析** | 利用其强大的调试能力定位问题 |
119
- | **原型设计** | 快速获取实现思路(返回 Diff 而非直接修改) |
126
+ | 角色 | Claude Code 负责 | Codex 负责 |
127
+ |------|-----------------|-----------|
128
+ | **架构** | 设计、决策、审校 | 分析现有代码 |
129
+ | **开发** | 规范重构、最终代码 | 原型生成(Diff) |
130
+ | **审查** | 规范检查、最终判定 | 逐文件审查、安全扫描 |
131
+ | **调试** | 日志分析、定位 | 深度代码分析、补丁 |
120
132
 
121
133
  ### 重要约束
122
134
 
123
- 1. **只读模式**: 始终使用 `--sandbox read-only`,禁止 Codex 直接修改文件
124
- 2. **英语交互**: 与 Codex 交互时使用英语,获得更好效果
125
- 3. **中文输出强制**: Codex 倾向于输出英文,必须在每次 PROMPT 末尾追加以下约束:
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 (e.g., COMMENT '用户名' NOT COMMENT 'username')
129
- - All Java/code comments (Javadoc, inline //, block /* */) MUST be in Chinese
130
- - All field descriptions, table descriptions MUST be in Chinese
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. **Diff 输出**: PROMPT 中明确要求 `OUTPUT: Unified Diff Patch ONLY`
134
- 5. **重构代码**: Codex 的输出视为"脏原型",由 Claude 重构为生产代码(**特别检查注释和 COMMENT 是否为中文,不是则修正**)
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
- ```bash
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
- | `codex: command not found` | 确保已安装并添加到 PATH |
172
- | `SESSION_ID` 获取失败 | 检查网络连接和 API Key |
173
- | 输出被截断 | 使用 `--return-all-messages` 获取完整信息 |
174
- | Windows 路径问题 | 使用正斜杠 `/` 或双反斜杠 `\\` |
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 |