ai-engineering-init 1.6.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 (187) hide show
  1. package/.claude/agents/code-reviewer.md +3 -130
  2. package/.claude/hooks/skill-forced-eval.js +46 -60
  3. package/.claude/hooks/stop.js +24 -1
  4. package/.claude/settings.json +10 -1
  5. package/.claude/skills/api-development/SKILL.md +179 -130
  6. package/.claude/skills/architecture-design/SKILL.md +102 -212
  7. package/.claude/skills/backend-annotations/SKILL.md +166 -220
  8. package/.claude/skills/bug-detective/SKILL.md +225 -186
  9. package/.claude/skills/code-patterns/SKILL.md +127 -244
  10. package/.claude/skills/codex-code-review/SKILL.md +327 -0
  11. package/.claude/skills/collaborating-with-codex/SKILL.md +96 -113
  12. package/.claude/skills/crud-development/SKILL.md +226 -307
  13. package/.claude/skills/data-permission/SKILL.md +131 -202
  14. package/.claude/skills/database-ops/SKILL.md +158 -355
  15. package/.claude/skills/error-handler/SKILL.md +224 -285
  16. package/.claude/skills/file-oss-management/SKILL.md +174 -169
  17. package/.claude/skills/git-workflow/SKILL.md +123 -341
  18. package/.claude/skills/json-serialization/SKILL.md +121 -137
  19. package/.claude/skills/leniu-report-customization/SKILL.md +82 -2
  20. package/.claude/skills/leniu-report-standard-customization/SKILL.md +65 -2
  21. package/.claude/skills/loki-log-query/SKILL.md +400 -0
  22. package/.claude/skills/mysql-debug/SKILL.md +58 -22
  23. package/.claude/skills/performance-doctor/SKILL.md +83 -89
  24. package/.claude/skills/redis-cache/SKILL.md +134 -185
  25. package/.claude/skills/scheduled-jobs/SKILL.md +187 -224
  26. package/.claude/skills/security-guard/SKILL.md +168 -276
  27. package/.claude/skills/sms-mail/SKILL.md +266 -228
  28. package/.claude/skills/social-login/SKILL.md +257 -195
  29. package/.claude/skills/sync-back-merge/SKILL.md +66 -0
  30. package/.claude/skills/tenant-management/SKILL.md +172 -188
  31. package/.claude/skills/utils-toolkit/SKILL.md +214 -222
  32. package/.claude/skills/websocket-sse/SKILL.md +251 -172
  33. package/.claude/skills/workflow-engine/SKILL.md +178 -250
  34. package/.claude/skills/yunxiao-task-management/SKILL.md +489 -0
  35. package/.codex/skills/api-development/SKILL.md +179 -130
  36. package/.codex/skills/architecture-design/SKILL.md +102 -212
  37. package/.codex/skills/backend-annotations/SKILL.md +166 -220
  38. package/.codex/skills/bug-detective/SKILL.md +225 -186
  39. package/.codex/skills/code-patterns/SKILL.md +127 -244
  40. package/.codex/skills/collaborating-with-codex/SKILL.md +96 -113
  41. package/.codex/skills/crud-development/SKILL.md +226 -307
  42. package/.codex/skills/data-permission/SKILL.md +131 -202
  43. package/.codex/skills/database-ops/SKILL.md +158 -355
  44. package/.codex/skills/error-handler/SKILL.md +224 -285
  45. package/.codex/skills/file-oss-management/SKILL.md +174 -169
  46. package/.codex/skills/git-workflow/SKILL.md +123 -341
  47. package/.codex/skills/json-serialization/SKILL.md +121 -137
  48. package/.codex/skills/leniu-report-customization/SKILL.md +82 -2
  49. package/.codex/skills/leniu-report-standard-customization/SKILL.md +65 -2
  50. package/.codex/skills/loki-log-query/SKILL.md +400 -0
  51. package/.codex/skills/loki-log-query/environments.json +45 -0
  52. package/.codex/skills/mysql-debug/SKILL.md +58 -22
  53. package/.codex/skills/performance-doctor/SKILL.md +83 -89
  54. package/.codex/skills/redis-cache/SKILL.md +134 -185
  55. package/.codex/skills/scheduled-jobs/SKILL.md +187 -224
  56. package/.codex/skills/security-guard/SKILL.md +168 -276
  57. package/.codex/skills/skill-creator/LICENSE.txt +202 -0
  58. package/.codex/skills/skill-creator/SKILL.md +479 -0
  59. package/.codex/skills/skill-creator/agents/analyzer.md +274 -0
  60. package/.codex/skills/skill-creator/agents/comparator.md +202 -0
  61. package/.codex/skills/skill-creator/agents/grader.md +223 -0
  62. package/.codex/skills/skill-creator/assets/eval_review.html +146 -0
  63. package/.codex/skills/skill-creator/eval-viewer/generate_review.py +471 -0
  64. package/.codex/skills/skill-creator/eval-viewer/viewer.html +1325 -0
  65. package/.codex/skills/skill-creator/references/schemas.md +430 -0
  66. package/.codex/skills/skill-creator/scripts/__init__.py +0 -0
  67. package/.codex/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
  68. package/.codex/skills/skill-creator/scripts/generate_report.py +326 -0
  69. package/.codex/skills/skill-creator/scripts/improve_description.py +248 -0
  70. package/.codex/skills/skill-creator/scripts/package_skill.py +136 -0
  71. package/.codex/skills/skill-creator/scripts/quick_validate.py +103 -0
  72. package/.codex/skills/skill-creator/scripts/run_eval.py +310 -0
  73. package/.codex/skills/skill-creator/scripts/run_loop.py +332 -0
  74. package/.codex/skills/skill-creator/scripts/utils.py +47 -0
  75. package/.codex/skills/sms-mail/SKILL.md +266 -228
  76. package/.codex/skills/social-login/SKILL.md +257 -195
  77. package/.codex/skills/sync-back-merge/SKILL.md +66 -0
  78. package/.codex/skills/tenant-management/SKILL.md +172 -188
  79. package/.codex/skills/utils-toolkit/SKILL.md +214 -222
  80. package/.codex/skills/websocket-sse/SKILL.md +251 -172
  81. package/.codex/skills/workflow-engine/SKILL.md +178 -250
  82. package/.codex/skills/yunxiao-task-management/SKILL.md +489 -0
  83. package/.cursor/hooks/cursor-skill-eval.js +66 -6
  84. package/.cursor/hooks/stop.js +23 -1
  85. package/.cursor/skills/api-development/SKILL.md +179 -130
  86. package/.cursor/skills/architecture-design/SKILL.md +102 -212
  87. package/.cursor/skills/backend-annotations/SKILL.md +166 -220
  88. package/.cursor/skills/bug-detective/SKILL.md +225 -186
  89. package/.cursor/skills/code-patterns/SKILL.md +127 -244
  90. package/.cursor/skills/collaborating-with-codex/SKILL.md +96 -113
  91. package/.cursor/skills/crud-development/SKILL.md +226 -307
  92. package/.cursor/skills/data-permission/SKILL.md +131 -202
  93. package/.cursor/skills/database-ops/SKILL.md +158 -355
  94. package/.cursor/skills/error-handler/SKILL.md +224 -285
  95. package/.cursor/skills/file-oss-management/SKILL.md +174 -169
  96. package/.cursor/skills/git-workflow/SKILL.md +123 -341
  97. package/.cursor/skills/json-serialization/SKILL.md +121 -137
  98. package/.cursor/skills/leniu-report-customization/SKILL.md +82 -2
  99. package/.cursor/skills/leniu-report-standard-customization/SKILL.md +65 -2
  100. package/.cursor/skills/loki-log-query/SKILL.md +400 -0
  101. package/.cursor/skills/loki-log-query/environments.json +45 -0
  102. package/.cursor/skills/mysql-debug/SKILL.md +58 -22
  103. package/.cursor/skills/performance-doctor/SKILL.md +83 -89
  104. package/.cursor/skills/redis-cache/SKILL.md +134 -185
  105. package/.cursor/skills/scheduled-jobs/SKILL.md +187 -224
  106. package/.cursor/skills/security-guard/SKILL.md +168 -276
  107. package/.cursor/skills/skill-creator/LICENSE.txt +202 -0
  108. package/.cursor/skills/skill-creator/SKILL.md +479 -0
  109. package/.cursor/skills/skill-creator/agents/analyzer.md +274 -0
  110. package/.cursor/skills/skill-creator/agents/comparator.md +202 -0
  111. package/.cursor/skills/skill-creator/agents/grader.md +223 -0
  112. package/.cursor/skills/skill-creator/assets/eval_review.html +146 -0
  113. package/.cursor/skills/skill-creator/eval-viewer/generate_review.py +471 -0
  114. package/.cursor/skills/skill-creator/eval-viewer/viewer.html +1325 -0
  115. package/.cursor/skills/skill-creator/references/schemas.md +430 -0
  116. package/.cursor/skills/skill-creator/scripts/__init__.py +0 -0
  117. package/.cursor/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
  118. package/.cursor/skills/skill-creator/scripts/generate_report.py +326 -0
  119. package/.cursor/skills/skill-creator/scripts/improve_description.py +248 -0
  120. package/.cursor/skills/skill-creator/scripts/package_skill.py +136 -0
  121. package/.cursor/skills/skill-creator/scripts/quick_validate.py +103 -0
  122. package/.cursor/skills/skill-creator/scripts/run_eval.py +310 -0
  123. package/.cursor/skills/skill-creator/scripts/run_loop.py +332 -0
  124. package/.cursor/skills/skill-creator/scripts/utils.py +47 -0
  125. package/.cursor/skills/sms-mail/SKILL.md +266 -228
  126. package/.cursor/skills/social-login/SKILL.md +257 -195
  127. package/.cursor/skills/sync-back-merge/SKILL.md +66 -0
  128. package/.cursor/skills/tenant-management/SKILL.md +172 -188
  129. package/.cursor/skills/utils-toolkit/SKILL.md +214 -222
  130. package/.cursor/skills/websocket-sse/SKILL.md +251 -172
  131. package/.cursor/skills/workflow-engine/SKILL.md +178 -250
  132. package/.cursor/skills/yunxiao-task-management/SKILL.md +489 -0
  133. package/AGENTS.md +49 -540
  134. package/CLAUDE.md +73 -119
  135. package/README.md +37 -6
  136. package/bin/index.js +611 -25
  137. package/package.json +1 -1
  138. package/src/platform-map.json +4 -0
  139. package/src/skills/api-development/SKILL.md +179 -130
  140. package/src/skills/architecture-design/SKILL.md +102 -212
  141. package/src/skills/backend-annotations/SKILL.md +166 -220
  142. package/src/skills/bug-detective/SKILL.md +225 -186
  143. package/src/skills/code-patterns/SKILL.md +127 -244
  144. package/src/skills/codex-code-review/SKILL.md +261 -69
  145. package/src/skills/collaborating-with-codex/SKILL.md +96 -113
  146. package/src/skills/crud-development/SKILL.md +226 -307
  147. package/src/skills/data-permission/SKILL.md +131 -202
  148. package/src/skills/database-ops/SKILL.md +158 -355
  149. package/src/skills/error-handler/SKILL.md +224 -285
  150. package/src/skills/file-oss-management/SKILL.md +174 -169
  151. package/src/skills/git-workflow/SKILL.md +123 -341
  152. package/src/skills/json-serialization/SKILL.md +121 -137
  153. package/src/skills/leniu-report-customization/SKILL.md +82 -2
  154. package/src/skills/leniu-report-standard-customization/SKILL.md +65 -2
  155. package/src/skills/loki-log-query/SKILL.md +400 -0
  156. package/src/skills/loki-log-query/environments.json +45 -0
  157. package/src/skills/mysql-debug/SKILL.md +58 -22
  158. package/src/skills/performance-doctor/SKILL.md +83 -89
  159. package/src/skills/redis-cache/SKILL.md +134 -185
  160. package/src/skills/scheduled-jobs/SKILL.md +187 -224
  161. package/src/skills/security-guard/SKILL.md +168 -276
  162. package/src/skills/skill-creator/LICENSE.txt +202 -0
  163. package/src/skills/skill-creator/SKILL.md +479 -0
  164. package/src/skills/skill-creator/agents/analyzer.md +274 -0
  165. package/src/skills/skill-creator/agents/comparator.md +202 -0
  166. package/src/skills/skill-creator/agents/grader.md +223 -0
  167. package/src/skills/skill-creator/assets/eval_review.html +146 -0
  168. package/src/skills/skill-creator/eval-viewer/generate_review.py +471 -0
  169. package/src/skills/skill-creator/eval-viewer/viewer.html +1325 -0
  170. package/src/skills/skill-creator/references/schemas.md +430 -0
  171. package/src/skills/skill-creator/scripts/__init__.py +0 -0
  172. package/src/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
  173. package/src/skills/skill-creator/scripts/generate_report.py +326 -0
  174. package/src/skills/skill-creator/scripts/improve_description.py +248 -0
  175. package/src/skills/skill-creator/scripts/package_skill.py +136 -0
  176. package/src/skills/skill-creator/scripts/quick_validate.py +103 -0
  177. package/src/skills/skill-creator/scripts/run_eval.py +310 -0
  178. package/src/skills/skill-creator/scripts/run_loop.py +332 -0
  179. package/src/skills/skill-creator/scripts/utils.py +47 -0
  180. package/src/skills/sms-mail/SKILL.md +266 -228
  181. package/src/skills/social-login/SKILL.md +257 -195
  182. package/src/skills/sync-back-merge/SKILL.md +66 -0
  183. package/src/skills/tenant-management/SKILL.md +172 -188
  184. package/src/skills/utils-toolkit/SKILL.md +214 -222
  185. package/src/skills/websocket-sse/SKILL.md +251 -172
  186. package/src/skills/workflow-engine/SKILL.md +178 -250
  187. package/src/skills/yunxiao-task-management/SKILL.md +489 -0
@@ -0,0 +1,327 @@
1
+ ---
2
+ name: codex-code-review
3
+ description: |
4
+ 代码审查工作流。分两阶段:先执行本地规范检查(Grep 即时完成)+ 代码逻辑审查(Read 逐文件),再可选调用 Codex CLI 深度审查。
5
+
6
+ 触发场景:
7
+ - /dev 或 /crud 命令完成代码生成后
8
+ - Bug 修复完成后
9
+ - 用户说"审查代码"、"review"、"代码审查"、"检查代码"
10
+ - 用户说"检查一下刚写的代码"
11
+ - Stop Hook 提示后用户输入"review"
12
+
13
+ 触发词:代码审查、review、审查代码、检查代码、code review、代码质量、codex审查、codex review
14
+ ---
15
+
16
+ # 代码审查工作流
17
+
18
+ > 两阶段审查:**本地检查**(规范 + 逻辑) + **Codex 深度审查**(可选)。
19
+
20
+ ## Phase 1: 收集变更范围
21
+
22
+ ```bash
23
+ git diff --name-only HEAD
24
+ git diff --cached --name-only
25
+ ```
26
+
27
+ 如果没有变更文件,提示"没有检测到代码变更"并终止。
28
+
29
+ 将变更文件按类型分组:
30
+ - **Java 文件**:Controller / Business / Service / Mapper / Entity / VO / DTO
31
+ - **XML 文件**:Mapper XML
32
+ - **SQL 文件**:建表/变更脚本
33
+ - **其他**:配置文件等
34
+
35
+ ---
36
+
37
+ ## Phase 2: 本地检查(必做)
38
+
39
+ 分两步执行:**Step A** 用 Grep 批量扫描规范问题(秒级),**Step B** 用 Read 逐文件审查代码逻辑。
40
+
41
+ ### Step A: 项目规范扫描(Grep 批量检查)
42
+
43
+ #### 🔴 A1. 包名规范
44
+ ```bash
45
+ Grep pattern: "package org\.dromara\." path: [目标目录] glob: "*.java"
46
+ ```
47
+ - ❌ `package org.dromara.xxx` → ✅ `package net.xnzn.core.xxx`
48
+
49
+ #### 🔴 A2. 禁止 RuoYi 工具类
50
+ ```bash
51
+ Grep pattern: "MapstructUtils" path: [目标目录] glob: "*.java"
52
+ Grep pattern: "ServiceException" path: [目标目录] glob: "*.java"
53
+ Grep pattern: "import javax\.validation" path: [目标目录] glob: "*.java"
54
+ ```
55
+ - ❌ `MapstructUtils` → ✅ `BeanUtil.copyProperties()`
56
+ - ❌ `ServiceException` → ✅ `LeException`
57
+ - ❌ `javax.validation.*` → ✅ `jakarta.validation.*`(JDK 21)
58
+
59
+ #### 🔴 A3. 审计字段名称
60
+ ```bash
61
+ Grep pattern: "private.*createBy|private.*updateBy|private.*createTime|private.*updateTime" path: [目标目录] glob: "*.java"
62
+ ```
63
+ - ❌ `createBy/updateBy/createTime/updateTime` → ✅ `crby/upby/crtime/uptime`
64
+
65
+ #### 🔴 A4. del_flag 值语义
66
+ ```bash
67
+ Grep pattern: "delFlag.*=.*0|del_flag.*=.*0" path: [目标目录] glob: "*.java"
68
+ ```
69
+ - ❌ `delFlag = 0`(RuoYi 正常值) → ✅ `delFlag = 2`(leniu 正常值,1=删除)
70
+
71
+ #### 🔴 A5. Entity 不含 tenant_id
72
+ ```bash
73
+ Grep pattern: "tenantId|tenant_id" path: [目标目录] glob: "*.java"
74
+ ```
75
+ - ❌ 双库物理隔离,无需 `tenant_id` 字段
76
+
77
+ #### 🔴 A6. 禁止 Map 传递业务数据
78
+ ```bash
79
+ Grep pattern: "Map<String,\s*Object>" path: [目标目录] glob: "*.java"
80
+ ```
81
+ - ❌ `Map<String, Object>` → ✅ 使用 VO/DTO 类
82
+
83
+ #### 🟡 A7. 事务注解缺少 rollbackFor
84
+ ```bash
85
+ Grep pattern: "@Transactional\b" path: [目标目录] glob: "*.java"
86
+ # 对命中文件二次检查:是否缺少 rollbackFor
87
+ Grep pattern: "@Transactional\((?!.*rollbackFor)" path: [命中文件]
88
+ ```
89
+ - ❌ `@Transactional` → ✅ `@Transactional(rollbackFor = Exception.class)`
90
+
91
+ #### 🟡 A8. 请求体封装
92
+ ```bash
93
+ Grep pattern: "@RequestBody [^L]" path: [目标目录] glob: "*Controller.java"
94
+ ```
95
+ - 建议 POST 请求使用 `@RequestBody LeRequest<T>` 封装
96
+
97
+ #### 🟡 A9. 金额类型错误
98
+ ```bash
99
+ Grep pattern: "Double|Float|double|float" path: [目标目录] glob: "*.java"
100
+ # 在命中行中检查是否涉及金额字段(amount/price/money/fee/cost)
101
+ ```
102
+ - ❌ `Double/Float` 处理金额 → ✅ `Long`(分)或 `BigDecimal`
103
+
104
+ #### 🟡 A10. BigDecimal 比较错误
105
+ ```bash
106
+ Grep pattern: "BigDecimal.*==|==.*BigDecimal" path: [目标目录] glob: "*.java"
107
+ ```
108
+ - ❌ `bigDecimal1 == bigDecimal2` → ✅ `bigDecimal1.compareTo(bigDecimal2) == 0`
109
+
110
+ #### 🟡 A11. SELECT * 查询
111
+ ```bash
112
+ Grep pattern: "SELECT \*|select \*" path: [目标目录] glob: "*.xml"
113
+ ```
114
+ - ❌ `SELECT *` → ✅ 明确列出需要的字段
115
+
116
+ #### 🟡 A12. SQL 注入风险
117
+ ```bash
118
+ Grep pattern: '\$\{' path: [目标目录] glob: "*.xml"
119
+ ```
120
+ - ❌ `${}` 拼接参数 → ✅ `#{}` 参数化查询(ORDER BY 等特殊场景除外)
121
+
122
+ #### 🟡 A13. 国际化异常
123
+ ```bash
124
+ Grep pattern: 'new LeException\("[^"]*[\u4e00-\u9fa5]' path: [目标目录] glob: "*.java"
125
+ ```
126
+ - 建议使用 `I18n.getMessage()` 替代硬编码中文
127
+
128
+ ---
129
+
130
+ ### Step B: 代码逻辑审查(Read 逐文件检查)
131
+
132
+ 对每个变更的 Java 文件执行 Read,按以下清单逐项审查。
133
+
134
+ #### Java 必检项(所有 Java 文件)
135
+
136
+ | # | 检查项 | 检查要点 | 严重级 |
137
+ |---|--------|---------|--------|
138
+ | B1 | **空指针风险** | `selectOne`/`getOne`/`selectById` 返回值是否有 null 判断;Optional 是否正确处理 | 🔴 |
139
+ | B2 | **参数校验** | 入参是否校验非空和合法性(`@NotNull`/`@NotEmpty`/`Objects.requireNonNull`/手动 if 判断) | 🔴 |
140
+ | B3 | **并发安全** | 查询+新增/查询+更新的组合操作是否有竞态条件;是否需要分布式锁 | 🔴 |
141
+ | B4 | **事务边界** | 多表写操作是否加了 `@Transactional(rollbackFor = Exception.class)` | 🔴 |
142
+ | B5 | **资源关闭** | Stream/IO流/数据库连接是否用 try-with-resources 或 finally 关闭 | 🔴 |
143
+ | B6 | **集合并发修改** | `forEach` 内是否有 remove/add 操作;应使用 `Iterator` 或 `removeIf` | 🔴 |
144
+ | B7 | **分页泄漏** | `PageMethod.startPage()` 是否紧贴查询语句,中间不能有其他 SQL 查询 | 🔴 |
145
+
146
+ #### Java 安全项
147
+
148
+ | # | 检查项 | 检查要点 | 严重级 |
149
+ |---|--------|---------|--------|
150
+ | B8 | **租户隔离(仅定时任务)** | 定时任务中是否使用 `Executors.doInTenant()`/`doInAllTenant()` 切换到商户库;普通接口默认在商户库,无需额外处理 | 🔴 |
151
+ | B9 | **SQL 注入** | 动态 SQL 是否使用参数化查询;拼接 SQL 是否转义 | 🔴 |
152
+ | B10 | **越权访问** | 删除/修改操作是否校验数据归属(检查 where 条件是否包含归属字段) | 🔴 |
153
+ | B11 | **敏感信息** | 日志中是否打印了密码、token、身份证、银行卡等敏感信息 | 🔴 |
154
+ | B12 | **批量操作限制** | 批量删除/更新是否限制了最大数量,防止误操作全表 | 🟡 |
155
+
156
+ #### Java 跨模块调用项
157
+
158
+ | # | 检查项 | 检查要点 | 严重级 |
159
+ |---|--------|---------|--------|
160
+ | B13 | **返回值兜底** | 返回 `List`/`Map` 时是否有空集合兜底(`Collections.emptyList()`),避免调用方 NPE | 🟡 |
161
+ | B14 | **集合参数防御** | 集合入参(`List`/`Set`)是否判空,空集合的 `IN()` 会导致 SQL 异常 | 🔴 |
162
+ | B15 | **异常透传** | 是否吞掉异常不抛出(空 catch 块);跨模块调用需要明确的异常传递 | 🔴 |
163
+ | B16 | **日志追踪** | 关键操作或异常分支是否有日志(`log.info`/`log.error`),便于跨模块问题排查 | 🟡 |
164
+
165
+ #### Java 代码规范项
166
+
167
+ | # | 检查项 | 检查要点 | 严重级 |
168
+ |---|--------|---------|--------|
169
+ | B17 | **魔法值** | 是否存在未定义的常量(状态码 1/2/3 必须用枚举,字符串必须定义常量) | 🟡 |
170
+ | B18 | **方法长度** | 方法是否过长(>50 行),需要拆分为子方法 | 🔵 |
171
+ | B19 | **注释完整性** | 公共 API(Controller/Business 方法)是否有 JavaDoc 注释 | 🔵 |
172
+ | B20 | **空 catch 块** | catch 块是否为空或仅打印日志而不处理/不抛出 | 🟡 |
173
+ | B21 | **过时 API** | 是否使用了 `@Deprecated` 的方法或类 | 🔵 |
174
+ | B22 | **返回值一致性** | Controller 层是否统一返回 `LeResponse<T>`,不能裸返回 | 🟡 |
175
+
176
+ ---
177
+
178
+ #### MyBatis XML 检查(仅 XML 文件)
179
+
180
+ | # | 检查项 | 检查要点 | 严重级 |
181
+ |---|--------|---------|--------|
182
+ | X1 | **SQL 注入** | 使用 `${}` 而非 `#{}` 进行参数拼接(ORDER BY 等场景需白名单校验) | 🔴 |
183
+ | X2 | **IN 查询防护** | IN 查询是否用 `<foreach>` 且考虑集合为空的情况(空 IN 会 SQL 异常) | 🔴 |
184
+ | X3 | **动态 SQL 语法** | `<if>`/`<where>`/`<choose>` 标签使用是否正确,是否会产生多余的 AND/OR | 🟡 |
185
+ | X4 | **SELECT *** | 是否使用 `SELECT *`,应明确列出需要的字段 | 🟡 |
186
+ | X5 | **缺少 WHERE** | UPDATE/DELETE 是否缺少 WHERE 条件(全表操作风险) | 🔴 |
187
+ | X6 | **索引失效** | WHERE 条件是否对索引字段使用了函数(`DATE(crtime)`)或隐式类型转换 | 🟡 |
188
+ | X7 | **LIKE 前模糊** | `LIKE '%xxx%'` 或 `LIKE CONCAT('%', #{}, '%')` 前模糊导致全表扫描 | 🟡 |
189
+ | X8 | **大表无分页** | 大表查询是否遗漏分页,可能造成 OOM | 🟡 |
190
+ | X9 | **namespace 匹配** | namespace 是否与 Mapper 接口全限定名完全匹配 | 🔴 |
191
+ | X10 | **resultMap 映射** | 是否正确定义 resultMap,字段名和属性名是否对应 | 🟡 |
192
+
193
+ ---
194
+
195
+ ### 本地检查结果展示
196
+
197
+ ```
198
+ # 代码审查报告
199
+
200
+ 审查范围: [变更文件列表]
201
+
202
+ ## 🔴 严重问题(X 项)
203
+ 1. [B1 空指针风险]
204
+ 文件: OrderServiceImpl.java:42
205
+ 问题: selectById 返回值未做 null 判断
206
+ 修复: if (ObjectUtil.isNull(entity)) throw new LeException("数据不存在");
207
+
208
+ 2. [A2 禁止 RuoYi 工具类]
209
+ 文件: UserServiceImpl.java:15
210
+ 问题: 使用了 MapstructUtils
211
+ 修复: 替换为 BeanUtil.copyProperties()
212
+
213
+ ## 🟡 警告问题(X 项)
214
+ ...
215
+
216
+ ## 🔵 建议(X 项)
217
+ ...
218
+
219
+ ## ✅ 通过项
220
+ - [x] A1 包名规范 (net.xnzn.core.*)
221
+ - [x] A3 审计字段正确 (crby/crtime/upby/uptime)
222
+ - [x] A4 del_flag 语义正确 (2=正常)
223
+ - [x] B8 租户隔离正确
224
+ ...
225
+
226
+ 结论: ✅ 通过 / ⚠️ 需修复 X 项 / ❌ 不通过
227
+ ```
228
+
229
+ 如果全部通过 → 展示"本地检查通过",询问是否需要 Codex 深度审查。
230
+ 如果有问题 → 先修复严重问题,修复后再询问是否需要 Codex 深度审查。
231
+
232
+ ---
233
+
234
+ ## Phase 3: Codex 深度审查(可选)
235
+
236
+ > 依赖 `collaborating-with-codex` skill 的 `codex_bridge.py` 脚本。
237
+ > Codex 擅长发现本地规则难以覆盖的**逻辑 Bug、复杂并发问题、架构缺陷**。
238
+
239
+ Phase 2 完成后询问用户:"是否需要 Codex 深度审查?"
240
+ - 用户同意 → 执行以下流程
241
+ - 用户拒绝 → 跳到 Phase 5
242
+
243
+ ```bash
244
+ python3 .claude/skills/collaborating-with-codex/scripts/codex_bridge.py \
245
+ --cd . \
246
+ --sandbox read-only \
247
+ --PROMPT "Review the following changed files for code quality issues:
248
+
249
+ FILES TO REVIEW:
250
+ {变更文件列表,含相对路径}
251
+
252
+ REVIEW FOCUS (beyond basic lint):
253
+ 1. Logic bugs: race conditions, off-by-one, incorrect state transitions, edge cases
254
+ 2. Security: privilege escalation, data leakage across tenants, missing auth checks
255
+ 3. Architecture: Controller calling Mapper directly, Business layer bypassed, circular dependencies
256
+ 4. Performance: N+1 queries, missing pagination on large tables, unnecessary DB calls in loops
257
+ 5. Concurrency: check-then-act without locking, shared mutable state, CompletableFuture error handling
258
+
259
+ PROJECT CONTEXT:
260
+ - Package: net.xnzn.core.* (NOT org.dromara.*)
261
+ - 4-layer: Controller → Business → Service → Mapper
262
+ - Dual-database: tenant DB is default (by MERCHANT-ID header); only scheduled tasks need Executors.doInTenant()/doInAllTenant() to switch; Executors.doInSystem() for system DB access
263
+ - Audit fields: crby/crtime/upby/uptime
264
+ - del_flag: 1=deleted, 2=normal
265
+ - Exception: LeException (NOT ServiceException)
266
+ - Object copy: BeanUtil.copyProperties() (NOT MapstructUtils)
267
+ - Amount: stored as Long (fen/cents), NOT Double/Float
268
+ - Pagination: PageMethod.startPage() must be immediately before query
269
+
270
+ OUTPUT FORMAT:
271
+ For each issue:
272
+ - [SEVERITY] CRITICAL / WARNING / SUGGESTION
273
+ - [FILE] filepath:line_number
274
+ - [ISSUE] Description
275
+ - [FIX] Recommended fix
276
+
277
+ If no issues: ALL CLEAR
278
+
279
+ IMPORTANT: All comments in Chinese, code/paths in English."
280
+ ```
281
+
282
+ **关键约束**:
283
+ - 始终使用 `--sandbox read-only`,Codex 不直接修改文件
284
+ - 变更文件过多时(>10 个),按模块分批审查
285
+ - 使用 `run_in_background` 避免阻塞
286
+
287
+ ---
288
+
289
+ ## Phase 4: 用户确认后修复
290
+
291
+ 合并 Phase 2 和 Phase 3 的所有问题,等待用户确认:
292
+ - **全部修复**:"修复所有问题" → 逐个修复所有 🔴 + 🟡
293
+ - **选择性修复**:"只修复严重问题" → 仅修复 🔴
294
+ - **跳过**:"不需要修复" → 终止
295
+
296
+ 修复时:
297
+ 1. 按文件逐个修复,使用 Edit 工具
298
+ 2. 每修复一个文件,简要说明改动
299
+ 3. 🔵 建议级别默认跳过,除非用户明确要求
300
+ 4. 修复完成后运行 `git diff` 展示所有变更
301
+
302
+ ---
303
+
304
+ ## Phase 5: 最终确认
305
+
306
+ 修复完成后询问:"是否需要再次审查确认?"
307
+ - 如果用户同意 → 回到 Phase 2 重新审查
308
+ - 如果用户拒绝 → 输出最终结论并终止
309
+
310
+ ```
311
+ 结论: ✅ 通过 / ⚠️ 需修复 / ❌ 不通过
312
+ ```
313
+
314
+ ---
315
+
316
+ ## 前端审查(如涉及前端文件变更)
317
+
318
+ 前端项目路径:`/Users/xujiajun/Developer/frontProj/web`
319
+
320
+ | # | 检查项 | 检查要点 |
321
+ |---|--------|---------|
322
+ | F1 | 响应码 | 成功码是 `10000`(不是 200) |
323
+ | F2 | Token | `Admin-Token`(localStorage) |
324
+ | F3 | 租户头 | `MERCHANT-ID`(请求头) |
325
+ | F4 | 金额显示 | 后端返回分,前端用 `money()` 转元 |
326
+ | F5 | 权限指令 | 按钮权限使用 `v-hasPerm` |
327
+ | F6 | 加密 | 敏感字段使用 SM4 加密 |
@@ -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 |