ai-engineering-init 1.3.4 → 1.4.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 (226) hide show
  1. package/.claude/hooks/skill-forced-eval.js +2 -0
  2. package/.claude/settings.json +3 -3
  3. package/.claude/skills/add-skill/SKILL.md +79 -32
  4. package/.claude/skills/api-development/SKILL.md +83 -377
  5. package/.claude/skills/architecture-design/SKILL.md +138 -632
  6. package/.claude/skills/backend-annotations/SKILL.md +134 -506
  7. package/.claude/skills/banana-image/SKILL.md +10 -3
  8. package/.claude/skills/brainstorm/SKILL.md +103 -535
  9. package/.claude/skills/bug-detective/SKILL.md +147 -1097
  10. package/.claude/skills/bug-detective/references/error-patterns.md +242 -0
  11. package/.claude/skills/code-patterns/SKILL.md +116 -426
  12. package/.claude/skills/code-patterns/references/leniu-code-patterns.md +87 -0
  13. package/.claude/skills/crud-development/SKILL.md +64 -304
  14. package/.claude/skills/data-permission/SKILL.md +105 -412
  15. package/.claude/skills/data-permission/references/custom-data-scope.md +90 -0
  16. package/.claude/skills/file-oss-management/SKILL.md +106 -714
  17. package/.claude/skills/file-oss-management/references/entities.md +105 -0
  18. package/.claude/skills/file-oss-management/references/service-impl.md +104 -0
  19. package/.claude/skills/leniu-api-development/SKILL.md +142 -626
  20. package/.claude/skills/leniu-api-development/references/real-examples.md +273 -0
  21. package/.claude/skills/leniu-architecture-design/SKILL.md +176 -391
  22. package/.claude/skills/leniu-backend-annotations/SKILL.md +132 -519
  23. package/.claude/skills/leniu-brainstorm/SKILL.md +132 -541
  24. package/.claude/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
  25. package/.claude/skills/leniu-crud-development/SKILL.md +232 -938
  26. package/.claude/skills/leniu-crud-development/references/templates.md +597 -0
  27. package/.claude/skills/leniu-customization-location/SKILL.md +410 -0
  28. package/.claude/skills/leniu-data-permission/SKILL.md +70 -0
  29. package/.claude/skills/leniu-java-entity/SKILL.md +76 -590
  30. package/.claude/skills/leniu-java-entity/references/templates.md +237 -0
  31. package/.claude/skills/leniu-java-export/SKILL.md +94 -379
  32. package/.claude/skills/leniu-java-logging/SKILL.md +106 -709
  33. package/.claude/skills/leniu-java-logging/references/data-mask.md +46 -0
  34. package/.claude/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
  35. package/.claude/skills/leniu-java-mybatis/SKILL.md +73 -446
  36. package/.claude/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
  37. package/.claude/skills/leniu-report-customization/SKILL.md +111 -365
  38. package/.claude/skills/leniu-report-customization/references/table-fields.md +93 -0
  39. package/.claude/skills/leniu-report-standard-customization/SKILL.md +111 -334
  40. package/.claude/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
  41. package/.claude/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
  42. package/.claude/skills/leniu-security-guard/SKILL.md +133 -347
  43. package/.claude/skills/mysql-debug/SKILL.md +364 -0
  44. package/.claude/skills/openspec-apply-change/SKILL.md +10 -1
  45. package/.claude/skills/openspec-archive-change/SKILL.md +9 -1
  46. package/.claude/skills/openspec-bulk-archive-change/SKILL.md +9 -1
  47. package/.claude/skills/openspec-continue-change/SKILL.md +9 -1
  48. package/.claude/skills/openspec-explore/SKILL.md +10 -1
  49. package/.claude/skills/openspec-ff-change/SKILL.md +9 -1
  50. package/.claude/skills/openspec-new-change/SKILL.md +9 -1
  51. package/.claude/skills/openspec-onboard/SKILL.md +15 -130
  52. package/.claude/skills/openspec-sync-specs/SKILL.md +9 -1
  53. package/.claude/skills/openspec-verify-change/SKILL.md +9 -1
  54. package/.claude/skills/performance-doctor/SKILL.md +110 -434
  55. package/.claude/skills/redis-cache/SKILL.md +89 -595
  56. package/.claude/skills/redis-cache/references/listeners.md +23 -0
  57. package/.claude/skills/scheduled-jobs/SKILL.md +88 -407
  58. package/.claude/skills/security-guard/SKILL.md +137 -532
  59. package/.claude/skills/security-guard/references/encrypt-config.md +103 -0
  60. package/.claude/skills/security-guard/references/sensitive-strategies.md +42 -0
  61. package/.claude/skills/sms-mail/SKILL.md +116 -574
  62. package/.claude/skills/sms-mail/references/mail-config.md +88 -0
  63. package/.claude/skills/sms-mail/references/sms-config.md +74 -0
  64. package/.claude/skills/social-login/SKILL.md +112 -514
  65. package/.claude/skills/social-login/references/provider-configs.md +118 -0
  66. package/.claude/skills/tenant-management/SKILL.md +129 -444
  67. package/.claude/skills/tenant-management/references/tenant-scenarios.md +91 -0
  68. package/.claude/skills/test-development/SKILL.md +86 -540
  69. package/.claude/skills/test-development/references/parameterized-examples.md +119 -0
  70. package/.claude/skills/utils-toolkit/SKILL.md +52 -305
  71. package/.claude/skills/utils-toolkit/references/redis-utils-api.md +56 -0
  72. package/.claude/skills/websocket-sse/SKILL.md +105 -550
  73. package/.claude/skills/workflow-engine/SKILL.md +147 -502
  74. package/.codex/skills/add-skill/SKILL.md +79 -32
  75. package/.codex/skills/api-development/SKILL.md +172 -599
  76. package/.codex/skills/architecture-design/SKILL.md +138 -504
  77. package/.codex/skills/backend-annotations/SKILL.md +134 -496
  78. package/.codex/skills/banana-image/SKILL.md +10 -3
  79. package/.codex/skills/brainstorm/SKILL.md +103 -535
  80. package/.codex/skills/bug-detective/SKILL.md +147 -1097
  81. package/.codex/skills/bug-detective/references/error-patterns.md +242 -0
  82. package/.codex/skills/code-patterns/SKILL.md +120 -282
  83. package/.codex/skills/code-patterns/references/leniu-code-patterns.md +87 -0
  84. package/.codex/skills/crud-development/SKILL.md +64 -292
  85. package/.codex/skills/data-permission/SKILL.md +108 -407
  86. package/.codex/skills/data-permission/references/custom-data-scope.md +90 -0
  87. package/.codex/skills/database-ops/SKILL.md +8 -154
  88. package/.codex/skills/error-handler/SKILL.md +10 -0
  89. package/.codex/skills/file-oss-management/SKILL.md +106 -714
  90. package/.codex/skills/file-oss-management/references/entities.md +105 -0
  91. package/.codex/skills/file-oss-management/references/service-impl.md +104 -0
  92. package/.codex/skills/git-workflow/SKILL.md +27 -5
  93. package/.codex/skills/leniu-api-development/SKILL.md +142 -626
  94. package/.codex/skills/leniu-api-development/references/real-examples.md +273 -0
  95. package/.codex/skills/leniu-architecture-design/SKILL.md +176 -391
  96. package/.codex/skills/leniu-backend-annotations/SKILL.md +132 -519
  97. package/.codex/skills/leniu-brainstorm/SKILL.md +132 -541
  98. package/.codex/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
  99. package/.codex/skills/leniu-crud-development/SKILL.md +232 -938
  100. package/.codex/skills/leniu-crud-development/references/templates.md +597 -0
  101. package/.codex/skills/leniu-customization-location/SKILL.md +410 -0
  102. package/.codex/skills/leniu-data-permission/SKILL.md +70 -0
  103. package/.codex/skills/leniu-java-code-style/SKILL.md +510 -0
  104. package/.codex/skills/leniu-java-entity/SKILL.md +76 -590
  105. package/.codex/skills/leniu-java-entity/references/templates.md +237 -0
  106. package/.codex/skills/leniu-java-export/SKILL.md +94 -379
  107. package/.codex/skills/leniu-java-logging/SKILL.md +106 -709
  108. package/.codex/skills/leniu-java-logging/references/data-mask.md +46 -0
  109. package/.codex/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
  110. package/.codex/skills/leniu-java-mybatis/SKILL.md +73 -446
  111. package/.codex/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
  112. package/.codex/skills/leniu-report-customization/SKILL.md +111 -365
  113. package/.codex/skills/leniu-report-customization/references/table-fields.md +93 -0
  114. package/.codex/skills/leniu-report-standard-customization/SKILL.md +111 -334
  115. package/.codex/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
  116. package/.codex/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
  117. package/.codex/skills/leniu-security-guard/SKILL.md +133 -347
  118. package/.codex/skills/mysql-debug/SKILL.md +364 -0
  119. package/.codex/skills/openspec-apply-change/SKILL.md +10 -1
  120. package/.codex/skills/openspec-archive-change/SKILL.md +9 -1
  121. package/.codex/skills/openspec-bulk-archive-change/SKILL.md +9 -1
  122. package/.codex/skills/openspec-continue-change/SKILL.md +9 -1
  123. package/.codex/skills/openspec-explore/SKILL.md +10 -1
  124. package/.codex/skills/openspec-ff-change/SKILL.md +9 -1
  125. package/.codex/skills/openspec-new-change/SKILL.md +9 -1
  126. package/.codex/skills/openspec-onboard/SKILL.md +15 -130
  127. package/.codex/skills/openspec-sync-specs/SKILL.md +9 -1
  128. package/.codex/skills/openspec-verify-change/SKILL.md +9 -1
  129. package/.codex/skills/performance-doctor/SKILL.md +110 -434
  130. package/.codex/skills/project-navigator/SKILL.md +20 -1
  131. package/.codex/skills/redis-cache/SKILL.md +93 -589
  132. package/.codex/skills/redis-cache/references/listeners.md +23 -0
  133. package/.codex/skills/scheduled-jobs/SKILL.md +88 -407
  134. package/.codex/skills/security-guard/SKILL.md +141 -527
  135. package/.codex/skills/security-guard/references/encrypt-config.md +103 -0
  136. package/.codex/skills/security-guard/references/sensitive-strategies.md +42 -0
  137. package/.codex/skills/sms-mail/SKILL.md +116 -574
  138. package/.codex/skills/sms-mail/references/mail-config.md +88 -0
  139. package/.codex/skills/sms-mail/references/sms-config.md +74 -0
  140. package/.codex/skills/social-login/SKILL.md +112 -514
  141. package/.codex/skills/social-login/references/provider-configs.md +118 -0
  142. package/.codex/skills/store-pc/SKILL.md +258 -383
  143. package/.codex/skills/tenant-management/SKILL.md +129 -444
  144. package/.codex/skills/tenant-management/references/tenant-scenarios.md +91 -0
  145. package/.codex/skills/test-development/SKILL.md +86 -540
  146. package/.codex/skills/test-development/references/parameterized-examples.md +119 -0
  147. package/.codex/skills/ui-pc/SKILL.md +350 -387
  148. package/.codex/skills/utils-toolkit/SKILL.md +52 -283
  149. package/.codex/skills/utils-toolkit/references/redis-utils-api.md +56 -0
  150. package/.codex/skills/websocket-sse/SKILL.md +105 -550
  151. package/.codex/skills/workflow-engine/SKILL.md +147 -502
  152. package/.cursor/hooks.json +3 -3
  153. package/.cursor/skills/add-skill/SKILL.md +79 -32
  154. package/.cursor/skills/api-development/SKILL.md +83 -377
  155. package/.cursor/skills/architecture-design/SKILL.md +138 -632
  156. package/.cursor/skills/backend-annotations/SKILL.md +134 -506
  157. package/.cursor/skills/banana-image/SKILL.md +10 -3
  158. package/.cursor/skills/brainstorm/SKILL.md +103 -535
  159. package/.cursor/skills/bug-detective/SKILL.md +147 -1097
  160. package/.cursor/skills/bug-detective/references/error-patterns.md +242 -0
  161. package/.cursor/skills/code-patterns/SKILL.md +116 -426
  162. package/.cursor/skills/code-patterns/references/leniu-code-patterns.md +87 -0
  163. package/.cursor/skills/crud-development/SKILL.md +64 -304
  164. package/.cursor/skills/data-permission/SKILL.md +105 -412
  165. package/.cursor/skills/data-permission/references/custom-data-scope.md +90 -0
  166. package/.cursor/skills/file-oss-management/SKILL.md +106 -714
  167. package/.cursor/skills/file-oss-management/references/entities.md +105 -0
  168. package/.cursor/skills/file-oss-management/references/service-impl.md +104 -0
  169. package/.cursor/skills/git-workflow/SKILL.md +27 -5
  170. package/.cursor/skills/leniu-api-development/SKILL.md +142 -626
  171. package/.cursor/skills/leniu-api-development/references/real-examples.md +273 -0
  172. package/.cursor/skills/leniu-architecture-design/SKILL.md +176 -391
  173. package/.cursor/skills/leniu-backend-annotations/SKILL.md +132 -519
  174. package/.cursor/skills/leniu-brainstorm/SKILL.md +132 -541
  175. package/.cursor/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
  176. package/.cursor/skills/leniu-crud-development/SKILL.md +232 -938
  177. package/.cursor/skills/leniu-crud-development/references/templates.md +597 -0
  178. package/.cursor/skills/leniu-customization-location/SKILL.md +410 -0
  179. package/.cursor/skills/leniu-data-permission/SKILL.md +70 -0
  180. package/.cursor/skills/leniu-java-code-style/SKILL.md +510 -0
  181. package/.cursor/skills/leniu-java-entity/SKILL.md +76 -590
  182. package/.cursor/skills/leniu-java-entity/references/templates.md +237 -0
  183. package/.cursor/skills/leniu-java-export/SKILL.md +94 -379
  184. package/.cursor/skills/leniu-java-logging/SKILL.md +106 -709
  185. package/.cursor/skills/leniu-java-logging/references/data-mask.md +46 -0
  186. package/.cursor/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
  187. package/.cursor/skills/leniu-java-mybatis/SKILL.md +73 -446
  188. package/.cursor/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
  189. package/.cursor/skills/leniu-report-customization/SKILL.md +111 -365
  190. package/.cursor/skills/leniu-report-customization/references/table-fields.md +93 -0
  191. package/.cursor/skills/leniu-report-standard-customization/SKILL.md +111 -334
  192. package/.cursor/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
  193. package/.cursor/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
  194. package/.cursor/skills/leniu-security-guard/SKILL.md +133 -347
  195. package/.cursor/skills/mysql-debug/SKILL.md +364 -0
  196. package/.cursor/skills/openspec-apply-change/SKILL.md +10 -1
  197. package/.cursor/skills/openspec-archive-change/SKILL.md +9 -1
  198. package/.cursor/skills/openspec-bulk-archive-change/SKILL.md +9 -1
  199. package/.cursor/skills/openspec-continue-change/SKILL.md +9 -1
  200. package/.cursor/skills/openspec-explore/SKILL.md +10 -1
  201. package/.cursor/skills/openspec-ff-change/SKILL.md +9 -1
  202. package/.cursor/skills/openspec-new-change/SKILL.md +9 -1
  203. package/.cursor/skills/openspec-onboard/SKILL.md +15 -130
  204. package/.cursor/skills/openspec-sync-specs/SKILL.md +9 -1
  205. package/.cursor/skills/openspec-verify-change/SKILL.md +9 -1
  206. package/.cursor/skills/performance-doctor/SKILL.md +110 -434
  207. package/.cursor/skills/redis-cache/SKILL.md +89 -595
  208. package/.cursor/skills/redis-cache/references/listeners.md +23 -0
  209. package/.cursor/skills/scheduled-jobs/SKILL.md +88 -407
  210. package/.cursor/skills/security-guard/SKILL.md +137 -532
  211. package/.cursor/skills/security-guard/references/encrypt-config.md +103 -0
  212. package/.cursor/skills/security-guard/references/sensitive-strategies.md +42 -0
  213. package/.cursor/skills/sms-mail/SKILL.md +116 -574
  214. package/.cursor/skills/sms-mail/references/mail-config.md +88 -0
  215. package/.cursor/skills/sms-mail/references/sms-config.md +74 -0
  216. package/.cursor/skills/social-login/SKILL.md +112 -514
  217. package/.cursor/skills/social-login/references/provider-configs.md +118 -0
  218. package/.cursor/skills/tenant-management/SKILL.md +129 -444
  219. package/.cursor/skills/tenant-management/references/tenant-scenarios.md +91 -0
  220. package/.cursor/skills/test-development/SKILL.md +86 -540
  221. package/.cursor/skills/test-development/references/parameterized-examples.md +119 -0
  222. package/.cursor/skills/utils-toolkit/SKILL.md +52 -305
  223. package/.cursor/skills/utils-toolkit/references/redis-utils-api.md +56 -0
  224. package/.cursor/skills/websocket-sse/SKILL.md +105 -550
  225. package/.cursor/skills/workflow-engine/SKILL.md +147 -502
  226. package/package.json +1 -1
@@ -0,0 +1,364 @@
1
+ ---
2
+ name: mysql-debug
3
+ description: |
4
+ MySQL 数据库查询调试技能。通过 mysql CLI 直接查询本地 MySQL 数据库,配合日志进行 Bug 排查。
5
+ Bug 修复时自动评估是否需要查库,从日志中提取数据库名(租户ID),支持手动指定数据库。
6
+
7
+ 触发场景:
8
+ - 结合日志排查 Bug 时需要查询数据库验证数据
9
+ - 检查数据库中某条记录的实际值
10
+ - 验证 SQL 执行结果是否符合预期
11
+ - 排查数据不一致、数据丢失、数据异常问题
12
+ - 需要查看表结构、索引、数据分布
13
+
14
+ 触发词:查数据库、查表、执行SQL、查记录、mysql查询、数据库排查、验证数据、查数据、db查询、数据库调试
15
+ ---
16
+
17
+ # MySQL 数据库查询调试技能
18
+
19
+ ## 概述
20
+
21
+ 本技能用于在 Bug 排查过程中直接查询 MySQL 数据库,验证数据状态。配合日志分析定位问题根因。
22
+
23
+ **核心能力**:
24
+ 1. 智能判断 Bug 是否需要查库(明显代码错误跳过)
25
+ 2. 从日志自动提取数据库名(租户 ID = 数据库名)
26
+ 3. 只读查询,安全排查
27
+
28
+ ---
29
+
30
+ ## 首次使用引导(必须执行)
31
+
32
+ 当本技能被激活时,**必须先执行以下两项检查**,任一不通过则输出引导提示并停止查库操作:
33
+
34
+ ### 检查 1:配置文件是否就绪
35
+
36
+ 读取 `.claude/mysql-config.json`,确定当前环境(用户指定 或 `default` 字段),检查该环境的 password 是否仍为占位符 `YOUR_PASSWORD`:
37
+
38
+ ```
39
+ 如果文件不存在 或 当前环境的 password == "YOUR_PASSWORD":
40
+ → 输出引导提示(见下方模板),不执行查库
41
+ ```
42
+
43
+ ### 检查 2:mysql CLI 是否可用
44
+
45
+ 执行 `which mysql`,检查是否返回有效路径:
46
+
47
+ ```
48
+ 如果 mysql 命令不存在:
49
+ → 输出引导提示(见下方模板),不执行查库
50
+ ```
51
+
52
+ ### 引导提示模板
53
+
54
+ 当检查不通过时,输出以下提示:
55
+
56
+ ```
57
+ ⚠️ 数据库查询功能需要先完成配置:
58
+
59
+ 1. 编辑 .claude/mysql-config.json,填入你的 MySQL 连接信息:
60
+ 配置文件支持多环境(local / dev / prod),至少配置一个环境:
61
+ - host: 数据库地址
62
+ - port: 端口(默认 3306)
63
+ - user: 用户名
64
+ - password: 数据库密码(替换 YOUR_PASSWORD)
65
+
66
+ 2. 安装 MySQL 客户端:
67
+ brew install mysql-client
68
+
69
+ 完成后重新触发即可使用数据库查询辅助排查。
70
+ ```
71
+
72
+ > 引导提示输出后,Bug 排查仍可继续(走 bug-detective 纯代码分析路径),只是跳过数据库查询环节。
73
+
74
+ ---
75
+
76
+ ## 多环境支持
77
+
78
+ ### 配置文件结构
79
+
80
+ `.claude/mysql-config.json` 支持多环境配置:
81
+
82
+ ```json
83
+ {
84
+ "environments": {
85
+ "local": { "host": "127.0.0.1", "port": 3306, "user": "root", "password": "xxx" },
86
+ "dev": { "host": "dev-db.example.com", "port": 3306, "user": "dev_user", "password": "xxx" },
87
+ "prod": { "host": "prod-db.example.com", "port": 3306, "user": "readonly", "password": "xxx" }
88
+ },
89
+ "default": "local"
90
+ }
91
+ ```
92
+
93
+ ### 环境选择规则
94
+
95
+ | 优先级 | 来源 | 示例 |
96
+ |--------|------|------|
97
+ | 1(最高) | 用户对话中指定 | "连 dev 环境查一下"、"用生产库看看" |
98
+ | 2 | 配置文件 `default` 字段 | `"default": "local"` |
99
+
100
+ ### 环境关键词映射
101
+
102
+ 用户说的话 → 对应环境名:
103
+
104
+ | 用户说法 | 环境 |
105
+ |---------|------|
106
+ | "本地"、"local"、"本地环境" | `local` |
107
+ | "开发"、"dev"、"测试环境"、"开发环境" | `dev` |
108
+ | "生产"、"prod"、"线上"、"正式环境" | `prod` |
109
+
110
+ ### 连接示例
111
+
112
+ ```bash
113
+ # 用户说"连 dev 环境查一下 order_info"
114
+ # → 读取 environments.dev 的连接信息 + 日志提取的数据库名
115
+ mysql -h dev-db.example.com -P 3306 -u dev_user -p'xxx' 546198574447230976 -e "SELECT ..."
116
+ ```
117
+
118
+ ---
119
+
120
+ ## 核心流程:是否需要查库?
121
+
122
+ ### 决策树(Bug 修复时必须先评估)
123
+
124
+ ```
125
+ 用户报告 Bug / 提供日志
126
+
127
+ ├─ 明显的代码错误? ──→ ✅ 不需要查库,直接修复
128
+ │ - NPE 且代码中未做空判断
129
+ │ - 语法错误、拼写错误
130
+ │ - 类型转换错误(ClassCastException)
131
+ │ - 缺少 import、注解遗漏
132
+ │ - 方法签名不匹配
133
+
134
+ ├─ 数据相关的问题? ──→ 🔍 需要查库
135
+ │ - "查不到数据"、"数据为空"
136
+ │ - "数量不对"、"金额不对"
137
+ │ - SQL 相关异常(DataIntegrityViolation、DuplicateKey)
138
+ │ - 关联查询结果异常
139
+ │ - 状态流转异常(订单状态不对等)
140
+
141
+ ├─ 不确定是代码还是数据? ──→ 🔍 需要查库确认
142
+ │ - 逻辑正确但结果错误
143
+ │ - 特定租户/特定数据才出现的 Bug
144
+ │ - 生产有问题但本地无法复现
145
+
146
+ └─ 配置/环境问题? ──→ ✅ 不需要查库
147
+ - 启动失败、Bean 创建异常
148
+ - 配置文件错误
149
+ - 依赖版本冲突
150
+ ```
151
+
152
+ ### 评估输出格式
153
+
154
+ 在 Bug 修复响应中,先输出评估结论:
155
+
156
+ ```
157
+ 📊 数据库查询评估:需要查库
158
+ 理由:日志显示 order_info 查询返回空,需要确认数据是否存在
159
+ 数据库:546198574447230976(从日志提取)
160
+ ```
161
+
162
+ 或:
163
+
164
+ ```
165
+ 📊 数据库查询评估:不需要查库
166
+ 理由:明显的 NPE,代码中 getUserInfo() 返回值未做空判断
167
+ ```
168
+
169
+ ---
170
+
171
+ ## 从日志提取数据库名
172
+
173
+ ### 日志格式说明
174
+
175
+ 本项目的日志格式:
176
+
177
+ ```
178
+ 2026-03-04 10:21:40.902,-,546198574447230976,, DEBUG 94396 --- [ XNIO-1 task-3] n.x.f.c.request.RequestLoggingFilter : 47 : >>> GET /api/v2/web/xxx
179
+ ```
180
+
181
+ 各字段含义:
182
+
183
+ ```
184
+ 时间戳 ,-,租户ID(=数据库名),, 日志级别 PID --- [线程名] 类名 : 行号 : 日志内容
185
+ ```
186
+
187
+ ### 提取规则
188
+
189
+ 1. **自动提取**:从日志行中匹配 `,-,(\d{15,19}),,` 模式,提取的数字即为数据库名
190
+ 2. **手动指定**:用户直接说"查 546198574447230976 库"或"数据库名是 xxx"
191
+ 3. **优先级**:手动指定 > 日志提取 > 配置文件 default
192
+
193
+ ### 提取示例
194
+
195
+ ```
196
+ 日志:2026-03-04 10:21:40.902,-,546198574447230976,, DEBUG ...
197
+
198
+ 数据库名 = 546198574447230976
199
+ ```
200
+
201
+ 连接时使用:
202
+ ```bash
203
+ mysql -h 127.0.0.1 -P 3306 -u root -p'password' 546198574447230976 -e "SELECT ..."
204
+ ```
205
+
206
+ ---
207
+
208
+ ## 查询执行
209
+
210
+ ### 连接方式
211
+
212
+ 读取 `.claude/mysql-config.json` 获取 host/port/user/password,数据库名从日志提取或用户指定:
213
+
214
+ ```bash
215
+ # 从配置读取连接信息 + 动态数据库名
216
+ mysql -h {host} -P {port} -u {user} -p'{password}' {database_from_log} -e "{SQL}"
217
+ ```
218
+
219
+ ### 常用排查查询模板
220
+
221
+ #### 查看表结构
222
+ ```sql
223
+ DESCRIBE table_name;
224
+ SHOW CREATE TABLE table_name;
225
+ ```
226
+
227
+ #### 按 ID 查记录
228
+ ```sql
229
+ SELECT * FROM table_name WHERE id = {id} AND del_flag = 2;
230
+ ```
231
+
232
+ #### 查看最近修改的数据
233
+ ```sql
234
+ SELECT * FROM table_name
235
+ WHERE uptime >= '{log_timestamp}'
236
+ ORDER BY uptime DESC
237
+ LIMIT 20;
238
+ ```
239
+
240
+ #### 检查关联数据一致性
241
+ ```sql
242
+ SELECT a.id, b.id AS related_id
243
+ FROM table_a a
244
+ LEFT JOIN table_b b ON a.related_id = b.id
245
+ WHERE a.id = {id} AND b.id IS NULL;
246
+ ```
247
+
248
+ #### 统计数据分布
249
+ ```sql
250
+ SELECT status, COUNT(*) as cnt
251
+ FROM table_name
252
+ WHERE del_flag = 2
253
+ GROUP BY status;
254
+ ```
255
+
256
+ #### 查看某时间段的操作记录
257
+ ```sql
258
+ SELECT * FROM table_name
259
+ WHERE crtime BETWEEN '{start}' AND '{end}'
260
+ ORDER BY crtime DESC
261
+ LIMIT 50;
262
+ ```
263
+
264
+ ---
265
+
266
+ ## 安全规范(强制执行,违反即终止)
267
+
268
+ ### 允许执行的 SQL(白名单)
269
+
270
+ **只允许以下语句类型**:
271
+ - `SELECT` — 查询数据
272
+ - `DESCRIBE` / `DESC` — 查看表结构
273
+ - `SHOW` — 查看建表语句、索引、状态等
274
+ - `EXPLAIN` — 分析执行计划
275
+
276
+ ### 禁止执行的 SQL(黑名单)
277
+
278
+ **DDL 操作 — 全部禁止**:
279
+ - `CREATE TABLE / VIEW / INDEX / DATABASE`
280
+ - `ALTER TABLE / COLUMN`
281
+ - `DROP TABLE / VIEW / INDEX / DATABASE`
282
+ - `TRUNCATE TABLE`
283
+ - `RENAME TABLE`
284
+
285
+ **DML 写操作 — 全部禁止**:
286
+ - `INSERT` — 禁止插入数据
287
+ - `UPDATE` — 禁止更新数据
288
+ - `DELETE` — 禁止删除数据
289
+ - `REPLACE` — 禁止替换数据
290
+
291
+ **权限/管理操作 — 全部禁止**:
292
+ - `GRANT / REVOKE`
293
+ - `SET GLOBAL`
294
+ - `FLUSH`
295
+
296
+ ### 敏感 SQL 拦截(执行前必须分析)
297
+
298
+ 在执行任何 SQL 之前,必须进行安全分析。遇到以下情况时,**不执行 SQL,改为输出分析结果并询问用户**:
299
+
300
+ | 风险类型 | 检测规则 | 处理方式 |
301
+ |---------|---------|---------|
302
+ | 无 WHERE 全表扫描 | `SELECT * FROM xxx` 无 WHERE 子句 | 提醒用户加条件,或自动加 `LIMIT 10` |
303
+ | 大范围查询 | WHERE 条件覆盖范围过大(如 `del_flag = 2`) | 提醒加更精确条件,强制 `LIMIT 50` |
304
+ | 多表 JOIN 无条件 | JOIN 无 ON 条件(笛卡尔积) | 拒绝执行,提示补充 JOIN 条件 |
305
+ | 子查询嵌套过深 | 超过 3 层嵌套子查询 | 输出 SQL 让用户确认后再执行 |
306
+ | 敏感表查询 | 涉及用户密码表、密钥表 | 输出脱敏后的 SQL 分析,不直接查询 |
307
+
308
+ ### 执行前检查流程
309
+
310
+ ```
311
+ 收到/构造 SQL
312
+
313
+ ├─ 是否在白名单内? ──→ 否 → 拒绝执行,输出原因
314
+
315
+ ├─ 是否命中敏感规则? ──→ 是 → 输出风险分析,询问用户
316
+
317
+ ├─ 是否包含 LIMIT? ──→ 否 → 自动追加 LIMIT 50
318
+
319
+ └─ 通过所有检查 → 执行 SQL
320
+ ```
321
+
322
+ ### 查询结果安全
323
+
324
+ - 查询必须加 `LIMIT`(默认 LIMIT 50)防止返回过多数据
325
+ - 不在输出中暴露密码、手机号(phone)、身份证(id_card)等敏感字段
326
+ - 查询结果中的敏感字段用 `***` 脱敏展示
327
+ - 如需修改数据,**只输出 SQL 语句让用户手动执行**,不代为执行
328
+
329
+ ### 配置文件安全
330
+
331
+ - `.claude/mysql-config.json` 已加入 `.gitignore`,禁止提交到版本库
332
+
333
+ ---
334
+
335
+ ## 与 bug-detective 配合
336
+
337
+ 本技能是 `bug-detective` 的数据层扩展。当 bug-detective 被触发时,会自动评估是否需要同时激活 mysql-debug:
338
+
339
+ | 步骤 | bug-detective | mysql-debug |
340
+ |------|--------------|-------------|
341
+ | 1 | 分析日志、定位异常层 | 评估是否需要查库 |
342
+ | 2 | 识别涉及的表和查询 | 从日志提取数据库名 |
343
+ | 3 | 推断可能原因 | 执行 SQL 验证数据 |
344
+ | 4 | 给出修复方案 | 用数据证实/排除假设 |
345
+
346
+ 典型联合使用:
347
+ ```
348
+ 用户:"订单查询接口返回空数据,日志如下..."
349
+ 日志:2026-03-04 10:21:40.902,-,546198574447230976,, ERROR ...
350
+
351
+ → 评估:需要查库(数据返回空,需确认数据是否存在)
352
+ → 提取数据库:546198574447230976
353
+ → 执行:SELECT * FROM order_info WHERE id = xxx AND del_flag = 2
354
+ → 发现:del_flag = 1(已删除),用户操作了删除但不知情
355
+ → 修复方案:恢复数据 / 检查前端删除按钮权限
356
+ ```
357
+
358
+ ---
359
+
360
+ ## 注意
361
+
362
+ - 本技能专注于**查询数据库辅助排查**,不涉及建表、迁移等操作(请使用 `database-ops`)
363
+ - 如果是纯代码错误(NPE、语法错误等)不需要查库,请使用 `bug-detective`
364
+ - 如果是 SQL 性能问题(慢查询),请使用 `performance-doctor`
@@ -1,6 +1,15 @@
1
1
  ---
2
2
  name: openspec-apply-change
3
- description: Implement tasks from an OpenSpec change. Use when the user wants to start implementing, continue implementation, or work through tasks.
3
+ description: |
4
+ Implement tasks from an OpenSpec change. Use when the user wants to start implementing, continue implementation, or work through tasks.
5
+
6
+ 触发场景:
7
+ - 需要实现 OpenSpec 变更中的任务
8
+ - 执行变更制品中定义的实现步骤
9
+ - 将规格和设计转化为实际代码
10
+ - 逐个完成 tasks.md 中的待办事项
11
+
12
+ 触发词:实现任务、开始实现、opsx:apply、openspec apply、执行变更、开始编码、实现变更
4
13
  license: MIT
5
14
  compatibility: Requires openspec CLI.
6
15
  metadata:
@@ -1,6 +1,14 @@
1
1
  ---
2
2
  name: openspec-archive-change
3
- description: Archive a completed change in the experimental workflow. Use when the user wants to finalize and archive a change after implementation is complete.
3
+ description: |
4
+ Archive a completed change in the experimental workflow. Use when the user wants to finalize and archive a change after implementation is complete.
5
+
6
+ 触发场景:
7
+ - 变更实现完毕,需要归档保存
8
+ - 完成的变更需要移入 archive 目录
9
+ - 项目决策记录需要持久化保存
10
+
11
+ 触发词:归档变更、归档、opsx:archive、openspec archive、完成变更、存档、归档完成
4
12
  license: MIT
5
13
  compatibility: Requires openspec CLI.
6
14
  metadata:
@@ -1,6 +1,14 @@
1
1
  ---
2
2
  name: openspec-bulk-archive-change
3
- description: Archive multiple completed changes at once. Use when archiving several parallel changes.
3
+ description: |
4
+ Archive multiple completed changes at once. Use when archiving several parallel changes.
5
+
6
+ 触发场景:
7
+ - 多个变更同时完成,需要批量归档
8
+ - 清理多个已完成的并行变更
9
+ - 需要处理多个变更之间的规格冲突后统一归档
10
+
11
+ 触发词:批量归档、全部归档、opsx:bulk-archive、一起归档、归档所有变更、批量存档
4
12
  license: MIT
5
13
  compatibility: Requires openspec CLI.
6
14
  metadata:
@@ -1,6 +1,14 @@
1
1
  ---
2
2
  name: openspec-continue-change
3
- description: Continue working on an OpenSpec change by creating the next artifact. Use when the user wants to progress their change, create the next artifact, or continue their workflow.
3
+ description: |
4
+ Continue working on an OpenSpec change by creating the next artifact. Use when the user wants to progress their change, create the next artifact, or continue their workflow.
5
+
6
+ 触发场景:
7
+ - 需要继续推进已有变更的下一个制品
8
+ - 上次中断后恢复变更工作
9
+ - 逐步创建变更的 proposal/specs/design/tasks
10
+
11
+ 触发词:继续变更、继续、opsx:continue、openspec continue、下一步、推进变更、继续工作
4
12
  license: MIT
5
13
  compatibility: Requires openspec CLI.
6
14
  metadata:
@@ -1,6 +1,15 @@
1
1
  ---
2
2
  name: openspec-explore
3
- description: Enter explore mode - a thinking partner for exploring ideas, investigating problems, and clarifying requirements. Use when the user wants to think through something before or during a change.
3
+ description: |
4
+ Enter explore mode - a thinking partner for exploring ideas, investigating problems, and clarifying requirements. Use when the user wants to think through something before or during a change.
5
+
6
+ 触发场景:
7
+ - 需要在实现前先探索和思考问题
8
+ - 比较多种技术方案的优劣
9
+ - 调查代码库中的现有架构和模式
10
+ - 在变更实现过程中遇到困惑需要深入分析
11
+
12
+ 触发词:探索、opsx:explore、openspec explore、想一想、分析问题、调研方案、头脑风暴
4
13
  license: MIT
5
14
  compatibility: Requires openspec CLI.
6
15
  metadata:
@@ -1,6 +1,14 @@
1
1
  ---
2
2
  name: openspec-ff-change
3
- description: Fast-forward through OpenSpec artifact creation. Use when the user wants to quickly create all artifacts needed for implementation without stepping through each one individually.
3
+ description: |
4
+ Fast-forward through OpenSpec artifact creation. Use when the user wants to quickly create all artifacts needed for implementation without stepping through each one individually.
5
+
6
+ 触发场景:
7
+ - 需要快速一次性生成所有变更制品
8
+ - 跳过逐步创建,直接生成 proposal/specs/design/tasks
9
+ - 想快速启动一个变更并立即进入实现阶段
10
+
11
+ 触发词:快速创建、快进、opsx:ff、openspec ff、一键生成、快速开始、fast forward
4
12
  license: MIT
5
13
  compatibility: Requires openspec CLI.
6
14
  metadata:
@@ -1,6 +1,14 @@
1
1
  ---
2
2
  name: openspec-new-change
3
- description: Start a new OpenSpec change using the experimental artifact workflow. Use when the user wants to create a new feature, fix, or modification with a structured step-by-step approach.
3
+ description: |
4
+ Start a new OpenSpec change using the experimental artifact workflow. Use when the user wants to create a new feature, fix, or modification with a structured step-by-step approach.
5
+
6
+ 触发场景:
7
+ - 需要创建一个新的 OpenSpec 变更
8
+ - 开始一个新功能或修复的结构化工作流
9
+ - 初始化变更目录并查看第一个制品模板
10
+
11
+ 触发词:新建变更、新变更、opsx:new、openspec new、创建变更、开始新功能、新增变更
4
12
  license: MIT
5
13
  compatibility: Requires openspec CLI.
6
14
  metadata:
@@ -1,6 +1,14 @@
1
1
  ---
2
2
  name: openspec-onboard
3
- description: Guided onboarding for OpenSpec - walk through a complete workflow cycle with narration and real codebase work.
3
+ description: |
4
+ Guided onboarding for OpenSpec - walk through a complete workflow cycle with narration and real codebase work.
5
+
6
+ 触发场景:
7
+ - 首次使用 OpenSpec,需要引导式教学
8
+ - 想通过实际操作学习 OpenSpec 完整工作流
9
+ - 需要了解 OpenSpec 的所有命令和流程
10
+
11
+ 触发词:入门、onboard、opsx:onboard、openspec 教程、学习 openspec、新手引导、openspec 入门
4
12
  license: MIT
5
13
  compatibility: Requires openspec CLI.
6
14
  metadata:
@@ -72,55 +80,13 @@ git log --oneline -10 2>/dev/null || echo "No git history"
72
80
 
73
81
  ### Present Suggestions
74
82
 
75
- From your analysis, present 3-4 specific suggestions:
76
-
77
- ```
78
- ## Task Suggestions
79
-
80
- Based on scanning your codebase, here are some good starter tasks:
81
-
82
- **1. [Most promising task]**
83
- Location: `src/path/to/file.ts:42`
84
- Scope: ~1-2 files, ~20-30 lines
85
- Why it's good: [brief reason]
86
-
87
- **2. [Second task]**
88
- Location: `src/another/file.ts`
89
- Scope: ~1 file, ~15 lines
90
- Why it's good: [brief reason]
91
-
92
- **3. [Third task]**
93
- Location: [location]
94
- Scope: [estimate]
95
- Why it's good: [brief reason]
83
+ From your analysis, present 3-4 specific suggestions with location, scope estimate, and brief reason. Include a "Something else?" option. Let the user pick a number or describe their own.
96
84
 
97
- **4. Something else?**
98
- Tell me what you'd like to work on.
99
-
100
- Which task interests you? (Pick a number or describe your own)
101
- ```
102
-
103
- **If nothing found:** Fall back to asking what the user wants to build:
104
- > I didn't find obvious quick wins in your codebase. What's something small you've been meaning to add or fix?
85
+ **If nothing found:** Fall back to asking what the user wants to build.
105
86
 
106
87
  ### Scope Guardrail
107
88
 
108
- If the user picks or describes something too large (major feature, multi-day work):
109
-
110
- ```
111
- That's a valuable task, but it's probably larger than ideal for your first OpenSpec run-through.
112
-
113
- For learning the workflow, smaller is better—it lets you see the full cycle without getting stuck in implementation details.
114
-
115
- **Options:**
116
- 1. **Slice it smaller** - What's the smallest useful piece of [their task]? Maybe just [specific slice]?
117
- 2. **Pick something else** - One of the other suggestions, or a different small task?
118
- 3. **Do it anyway** - If you really want to tackle this, we can. Just know it'll take longer.
119
-
120
- What would you prefer?
121
- ```
122
-
123
- Let the user override if they insist—this is a soft guardrail.
89
+ If the user picks something too large (major feature, multi-day work), suggest slicing smaller or picking something else. Offer three options: slice it, pick another, or do it anyway. This is a soft guardrail—let the user override if they insist.
124
90
 
125
91
  ---
126
92
 
@@ -200,40 +166,7 @@ The proposal captures **why** we're making this change and **what** it involves
200
166
  I'll draft one based on our task.
201
167
  ```
202
168
 
203
- **DO:** Draft the proposal content (don't save yet):
204
-
205
- ```
206
- Here's a draft proposal:
207
-
208
- ---
209
-
210
- ## Why
211
-
212
- [1-2 sentences explaining the problem/opportunity]
213
-
214
- ## What Changes
215
-
216
- [Bullet points of what will be different]
217
-
218
- ## Capabilities
219
-
220
- ### New Capabilities
221
- - `<capability-name>`: [brief description]
222
-
223
- ### Modified Capabilities
224
- <!-- If modifying existing behavior -->
225
-
226
- ## Impact
227
-
228
- - `src/path/to/file.ts`: [what changes]
229
- - [other files if applicable]
230
-
231
- ---
232
-
233
- Does this capture the intent? I can adjust before we save it.
234
- ```
235
-
236
- **PAUSE** - Wait for user approval/feedback.
169
+ **DO:** Draft the proposal with sections: Why, What Changes, Capabilities (New/Modified), Impact. Show the draft and **PAUSE** for user approval/feedback before saving.
237
170
 
238
171
  After approval, save the proposal:
239
172
  ```bash
@@ -304,37 +237,7 @@ The design captures **how** we'll build it—technical decisions, tradeoffs, app
304
237
  For small changes, this might be brief. That's fine—not every change needs deep design discussion.
305
238
  ```
306
239
 
307
- **DO:** Draft design.md:
308
-
309
- ```
310
- Here's the design:
311
-
312
- ---
313
-
314
- ## Context
315
-
316
- [Brief context about the current state]
317
-
318
- ## Goals / Non-Goals
319
-
320
- **Goals:**
321
- - [What we're trying to achieve]
322
-
323
- **Non-Goals:**
324
- - [What's explicitly out of scope]
325
-
326
- ## Decisions
327
-
328
- ### Decision 1: [Key decision]
329
-
330
- [Explanation of approach and rationale]
331
-
332
- ---
333
-
334
- For a small task, this captures the key decisions without over-engineering.
335
- ```
336
-
337
- Save to `openspec/changes/<name>/design.md`.
240
+ **DO:** Draft design.md with sections: Context, Goals/Non-Goals, Decisions. Keep it brief for small changes. Save to `openspec/changes/<name>/design.md`.
338
241
 
339
242
  ---
340
243
 
@@ -496,25 +399,7 @@ Exit gracefully without pressure.
496
399
 
497
400
  ### User just wants command reference
498
401
 
499
- If the user says they just want to see the commands or skip the tutorial:
500
-
501
- ```
502
- ## OpenSpec Quick Reference
503
-
504
- | Command | What it does |
505
- |---------|--------------|
506
- | `/opsx:explore` | Think through problems (no code changes) |
507
- | `/opsx:new <name>` | Start a new change, step by step |
508
- | `/opsx:ff <name>` | Fast-forward: all artifacts at once |
509
- | `/opsx:continue <name>` | Continue an existing change |
510
- | `/opsx:apply <name>` | Implement tasks |
511
- | `/opsx:verify <name>` | Verify implementation |
512
- | `/opsx:archive <name>` | Archive when done |
513
-
514
- Try `/opsx:new` to start your first change, or `/opsx:ff` if you want to move fast.
515
- ```
516
-
517
- Exit gracefully.
402
+ If the user says they just want to see the commands or skip the tutorial, show the Command Reference table from Phase 11 and exit gracefully.
518
403
 
519
404
  ---
520
405
 
@@ -1,6 +1,14 @@
1
1
  ---
2
2
  name: openspec-sync-specs
3
- description: Sync delta specs from a change to main specs. Use when the user wants to update main specs with changes from a delta spec, without archiving the change.
3
+ description: |
4
+ Sync delta specs from a change to main specs. Use when the user wants to update main specs with changes from a delta spec, without archiving the change.
5
+
6
+ 触发场景:
7
+ - 需要将变更中的增量规格同步到主规格
8
+ - 变更的 delta spec 需要合并到 openspec/specs 目录
9
+ - 在归档前手动同步规格变更
10
+
11
+ 触发词:同步规格、同步specs、opsx:sync、openspec sync、合并规格、同步变更规格
4
12
  license: MIT
5
13
  compatibility: Requires openspec CLI.
6
14
  metadata:
@@ -1,6 +1,14 @@
1
1
  ---
2
2
  name: openspec-verify-change
3
- description: Verify implementation matches change artifacts. Use when the user wants to validate that implementation is complete, correct, and coherent before archiving.
3
+ description: |
4
+ Verify implementation matches change artifacts. Use when the user wants to validate that implementation is complete, correct, and coherent before archiving.
5
+
6
+ 触发场景:
7
+ - 实现完成后需要验证是否与规格一致
8
+ - 归档前检查任务完成度和代码正确性
9
+ - 需要生成变更的完整性/正确性/一致性报告
10
+
11
+ 触发词:验证变更、验证、opsx:verify、openspec verify、检查实现、校验变更、验收
4
12
  license: MIT
5
13
  compatibility: Requires openspec CLI.
6
14
  metadata: