@ranger1/dx 0.1.104 → 0.1.105

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ranger1/dx",
3
- "version": "0.1.104",
3
+ "version": "0.1.105",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -0,0 +1,537 @@
1
+ ---
2
+ name: feature-decide-plan-execute
3
+ description: 仅在用户显式调用 $feature-decide-plan-execute 或明确要求使用 feature-decide-plan-execute 技能时使用;不要通过关键词自动触发。
4
+ ---
5
+
6
+ # Feature Decide · Plan · Execute · Push
7
+
8
+ ## Overview
9
+
10
+ 把"一个需求落到 PR 已创建、待审查"这一段流程跑完:**决策(Track A/B/C)→ 写实施计划(含 critic 循环)→ 执行代码 + 并行验证(含修复循环)→ commit → push → 创建 PR**。多 PR 时按依赖顺序完成多个 PR 的提交推送。
11
+
12
+ **不负责审查与合并**——所有 PR 拿到编号后交给 `pr-train-ship` 跑 review → fix → auto-merge。
13
+
14
+ 本 skill 是 `multi-pr-feature-delivery` 拆出的"前半段(含 PR 创建)"。后半段(审查 + 合并)见 `pr-train-ship`。
15
+
16
+ ## Scope
17
+
18
+ 显式调用本 skill 后,第一步永远是 **Step 0 复杂度评估**,由评估决定后续 Track A / B / C。
19
+
20
+ 适用:
21
+
22
+ - 一个 issue / 需求从决策落到"PR 已创建"。
23
+ - 用户明确要求决定 Track / 写实施计划 / 跑 critic / 执行 + 验证 / commit / push / 建 PR。
24
+
25
+ **不要用:** 用户未显式调用时不要自动进入;纯讨论 / 纯文档润色 / 单文件 typo 不需要本 skill。
26
+
27
+ ## 输出契约
28
+
29
+ 本 skill 结束时必须输出一个 **PR 清单**,作为给 `pr-train-ship` 的 handoff:
30
+
31
+ ```
32
+ [PR Handoff]
33
+ 模式:单 PR / Train N
34
+ PR 列表:
35
+ - PR #1234(feat: schema + writer)— 已 push 待 review
36
+ - PR #1235(feat: consumer + DTO)— 草稿,依赖 #1234,等其 merge 后再 push
37
+ Issue: #4774
38
+ ```
39
+
40
+ **Train 模式核心约束:本 skill 一次只能 push 当前可独立合并的 PR**。后续 PR 在前 PR merge 到 main 后再切分支 / 实现 / push(由调用方循环本 skill 或由 `pr-train-ship` 完成前 PR 后回调本 skill)。
41
+
42
+ ## Step 0:复杂度评估闸门(必跑,不可跳)
43
+
44
+ 第一件事不是动代码,是对照下表打勾给出 Track 判定。**不允许凭感觉直接进入 Track C,也不允许"看上去简单"跳过 Step 0**。
45
+
46
+ ### 评估维度
47
+
48
+ | # | 维度 | 计为"复杂"的判据 |
49
+ |---|------|-----------------|
50
+ | D1 | **改动层数** | 同时改 ≥3 个:Prisma schema / backend service / frontend / admin-front / seed / RBAC / api-contracts |
51
+ | D2 | **数据流跨越** | 存在"写入方 → 消费方"两侧改动,且消费方运行期依赖写入方先产生数据(scheduler / cron / 队列消费者 / event handler) |
52
+ | D3 | **Schema 变更** | 新增/修改 Prisma 模型(新表、新列、外键、索引),且有运行期消费者 |
53
+ | D4 | **新独立模块** | 新建 NestJS module / 新前端 page route / 新 admin 菜单(≥1 个全新顶层目录) |
54
+ | D5 | **基建改动** | 改 RBAC enum / ErrorCode / 全局拦截器 / Module DI 拓扑 / 共享 helper(影响多个模块) |
55
+ | D6 | **预估改动量** | 按经验估算 diff > 400 行 或 > 8 个文件 |
56
+ | D7 | **测试基建** | 需要新增 E2E fixture / 通用 helper 给后续 PR 复用 |
57
+ | D8 | **不可逆/高风险** | 数据回填脚本 / 破坏性 migration / 影响生产已有数据 |
58
+
59
+ ### Track 判定
60
+
61
+ | 命中条数 | Track | 形态 |
62
+ |---------|-------|------|
63
+ | **0 条** | **Track A — 直接交付** | 不写文档、不分 PR;改完 commit/push/建 PR → `pr-train-ship` 收口 |
64
+ | **1-2 条**(且 D2/D3/D8 均未命中) | **Track B — 单 PR + 轻量计划** | 写实施计划(无 spec),critic 一轮,单 PR → `pr-train-ship` |
65
+ | **≥3 条** 或 **D2/D3/D8 任一命中** | **Track C — 多 PR train** | 写实施计划 + 严苛 critic(≤3 轮) + 按数据流拆 PR + 按依赖序串行 push PR,每个 PR 交 `pr-train-ship` |
66
+
67
+ > ⚠️ **D2 / D3 / D8 是"硬升级条件"**:任一命中,无论总命中数多少,必须进 Track C。
68
+
69
+ ### Step 0 输出模板
70
+
71
+ ```
72
+ [复杂度评估]
73
+ 命中维度:D1=Y D2=N D3=N D4=Y D5=N D6=Y D7=N D8=N(共 3 条)
74
+ 硬升级触发:无
75
+ 判定:Track C — 多 PR train
76
+ 预估 PR 数:3(schema+writer / consumer+DTO / frontend)
77
+ ```
78
+
79
+ ---
80
+
81
+ ## Issue Gate(必跑,不可跳)
82
+
83
+ 任何 Track 在切分支前都必须有 issue ID。先 `gh issue list --search "<keyword>" --state open` 确认;如无则按下表创建。
84
+
85
+ ### Issue 创建时机
86
+
87
+ | Track | 时机 | 原因 |
88
+ |-------|---------|------|
89
+ | **A** | Step 0 之后、切分支之前 | 分支命名 `*/<id>-<slug>` 与 commit `Refs/Closes: #<id>` 需 issue ID |
90
+ | **B** | 实施计划写完后、plan critic 之前 | issue body "方案"段引用 plan 路径 |
91
+ | **C** | PR 拓扑确定后、plan critic 之前 | "方案"段附 PR 拓扑表 + plan 路径 |
92
+
93
+ ### Issue 模板(必含 4 段)
94
+
95
+ ```markdown
96
+ ## 背景
97
+ (为什么做:用户痛点 / 业务目标 / 触发事件,1-3 段)
98
+
99
+ ## 目标
100
+ (做完后达成什么可观测结果)
101
+
102
+ ## 方案
103
+ (Track A 写 1-2 句;Track B/C 引用 plan 文档路径,可附 PR 拓扑表)
104
+
105
+ ## 验收标准
106
+ - [ ] 可勾选 / 可验证的具体项
107
+ ```
108
+
109
+ ```bash
110
+ gh issue create --title "<title>" --body-file - <<'MSG'
111
+ ## 背景
112
+ ...
113
+ ## 目标
114
+ ...
115
+ ## 方案
116
+ ...
117
+ ## 验收标准
118
+ - [ ] ...
119
+ MSG
120
+ ```
121
+
122
+ 已有 issue 但 4 段不全 → `gh issue edit <id> --body-file -` 补齐。**验收标准缺失 = 不允许进入实现阶段**。
123
+
124
+ ---
125
+
126
+ ## Track A:直接执行 + push(简单改动)
127
+
128
+ **适用:** Step 0 命中 0 条。
129
+
130
+ **本 skill 内动作:**
131
+
132
+ 1. Issue Gate
133
+ 2. 切分支 `fix|feat|chore/<id>-<slug>`
134
+ 3. 修改代码(直接动手,不写 plan)
135
+ 4. **执行 + 并行验证循环**(见下方)
136
+ 5. **Commit + Push + 创建 PR**(见下方"PR 创建段")
137
+ 6. 输出 PR Handoff → 交 `pr-train-ship`
138
+
139
+ **禁止:** 写 spec.md / plan.md、跑 plan critic、做 PR 拆分讨论。
140
+
141
+ ---
142
+
143
+ ## Track B:单 PR + 轻量计划(中等改动)
144
+
145
+ **适用:** Step 0 命中 1-2 条且 D2/D3/D8 均未命中。
146
+
147
+ **本 skill 内动作:**
148
+
149
+ 1. 落盘实施计划:`docs/superpowers/plans/YYYY-MM-DD-<topic>.md`(不写 spec)
150
+ - 计划结构:Files / Steps / Verify / Commit,粒度 2-5 分钟每 Task
151
+ 2. Issue Gate(plan 路径写入"方案"段)
152
+ 3. **Plan critic 循环** 一轮(见下方)
153
+ 4. 切分支 `feat/<id>-<slug>`,按 plan task-by-task 执行(推荐 `superpowers:subagent-driven-development`)
154
+ 5. **执行 + 并行验证循环**
155
+ 6. **Commit + Push + 创建 PR**
156
+ 7. 输出 PR Handoff → 交 `pr-train-ship`
157
+
158
+ ---
159
+
160
+ ## Track C:多 PR train(复杂改动)
161
+
162
+ **适用:** Step 0 命中 ≥3 条 或 D2/D3/D8 任一命中。
163
+
164
+ ### C-Step 1:撰写实施计划(不写 spec)
165
+
166
+ 落盘路径:`docs/superpowers/plans/YYYY-MM-DD-<topic>-multi-pr.md`
167
+
168
+ > ⚠️ 不写 spec.md。信息不够回 `superpowers:brainstorming` 补齐设计,不要靠 spec 兜底。
169
+
170
+ 计划结构:
171
+
172
+ ```markdown
173
+ # <功能名> Multi-PR Implementation Plan
174
+
175
+ **Goal:** 一句话
176
+ **Track:** C
177
+ **Total PRs:** N
178
+ **Issue:** #<id>
179
+
180
+ ## PR 拓扑(按硬依赖拓扑序)
181
+
182
+ | # | PR 标题 | 涵盖层 | 依赖 PR | 是否需哨兵 |
183
+ |---|---------|--------|---------|-----------|
184
+ | 1 | feat: schema + writer | Prisma + scheduler | - | 是 |
185
+ | 2 | feat: consumer + DTO | service + api-contracts | #1 | 否 |
186
+ | 3 | feat: frontend | Next.js | #2 | 否 |
187
+
188
+ ## PR-N Detail(每个 PR 独立一段)
189
+
190
+ ### PR 1: feat: schema + writer
191
+ **Files:** Create / Modify 列表
192
+ **Tasks:** 每步完整代码、Verify、Commit
193
+ **Sentinel:**(如需)哨兵 SQL 查询模板
194
+ ```
195
+
196
+ Issue Gate(拓扑表写入"方案"段)。
197
+
198
+ ### C-Step 2:严苛 plan critic(≤3 轮)
199
+
200
+ 派 `oh-my-claudecode:critic`(通过 `Task` / `Agent` 工具)。审核要点:
201
+
202
+ 1. PR 拓扑序是否符合"硬依赖拓扑序"?
203
+ 2. 是否有 PR 把"写入方 + 消费方"塞进同一个?(违反 D2)
204
+ 3. Schema PR 是否独立?是否带哨兵 SQL?
205
+ 4. 每个 PR 是否可独立 review / 合并 / 回滚?
206
+ 5. Import 路径、Zodios 方法名、DTO 签名是否真实存在
207
+ 6. 是否遗漏 ErrorCode / Swagger / RBAC / api-contracts / 菜单注册 / Seed
208
+ 7. 测试基建放在第几个 PR,时序合理否
209
+
210
+ 每轮 critic 落盘 `.omc/plans/<topic>-multi-pr-critic-roundN.md`。
211
+
212
+ **Hard Gate:** Critical / Major 必修;3 轮仍未过 → escalate 回 `superpowers:brainstorming` 重谈设计。**不允许"接受 minor 妥协"强行通过**。
213
+
214
+ ### C-Step 3:按 PR 序列循环(**本 skill 完成代码 + commit + push + 建 PR**)
215
+
216
+ 对计划中每个 PR,依序:
217
+
218
+ 1. **前置条件检查**:若本 PR 依赖上游 PR(如 PR2 依赖 PR1),**上游 PR 必须已 merge 到 main**。未 merge 则本 skill 不继续,输出"等待 PR-#X merge 后再调用本 skill 继续"提示,结束本次会话。
219
+ 2. `git checkout main && git pull && git checkout -b feat/<id>-<slug>-pr<n>`
220
+ 3. 按 PR-N detail 的 Tasks 执行(推荐 `superpowers:subagent-driven-development`)
221
+ 4. Migration 路径(如有):`dx db migrate --dev --name X` → 失败走 Manual SQL fallback → `dx db deploy --dev` 验证
222
+ 5. **执行 + 并行验证循环**(全绿才继续)
223
+ 6. **如本 PR 是写入侧**:等真实写入路径跑过一次,记录哨兵 SQL 输出(供下一 PR body 用)
224
+ 7. **Commit + Push + 创建 PR**(PR body 加 `**PR Train:** N/Total`,消费侧贴哨兵 SQL)
225
+ 8. 输出当前 PR 的 PR Handoff → 交 `pr-train-ship`
226
+ 9. **等 `pr-train-ship` 完成本 PR(真正 merge 到 main)后,再回到 1 处理下一 PR**
227
+
228
+ > ⚠️ **本 skill 在一次调用内一般只产出一个"待 ship 的 PR"**(除非多个 PR 之间无依赖且当前 main 已包含所有必需上游变更——这种情况罕见)。Train 串行的核心约束是:**前 PR 真 merge 后才 push 后续 PR**。
229
+
230
+ ---
231
+
232
+ ## 拆解原则(Track C 用)
233
+
234
+ PR 数量按 issue 实际形态决定(常见 2-6 个)。
235
+
236
+ **Step 1:列"切面变更"** — Schema / 写入路径 / 读取路径 / 独立子模块 / 客户端 / 管理端 / 基建 / 运营脚本。
237
+
238
+ **Step 2:识别"硬依赖边界"** —
239
+ 1. 数据可用性依赖(最强拆分理由)
240
+ 2. API 契约依赖
241
+ 3. DI/Module 依赖
242
+ 4. 测试基建依赖
243
+
244
+ > ⚠️ 数据流跨越规则优先于行数门槛。"写入方"和"消费方"两侧都改且消费方运行依赖写入方先产生数据 → 必须分 PR。
245
+
246
+ **Step 3:按"硬依赖拓扑序"排出 PR 序列** — 基础设施在前,叶子在后。
247
+
248
+ **Step 4:是否需要"等待哨兵"** — 异步写入路径的消费 PR body 必须附可复现查询:
249
+
250
+ ```sql
251
+ SELECT count(*) AS rows,
252
+ count(*) FILTER (WHERE <new_column> IS NOT NULL) AS populated,
253
+ max(<updated_at_column>) AS last_run
254
+ FROM <new_or_extended_table>
255
+ WHERE <time_filter_matching_writer_cadence>;
256
+ ```
257
+
258
+ ---
259
+
260
+ ## Plan Critic 循环(Track B / C)
261
+
262
+ ```dot
263
+ digraph plan_critic {
264
+ "落盘 plan.md" [shape=box];
265
+ "Critic plan" [shape=box];
266
+ "Critical/Major errors?" [shape=diamond];
267
+ "Round < 3?" [shape=diamond];
268
+ "Fix plan + 重跑 critic" [shape=box];
269
+ "Escalate brainstorming" [shape=box];
270
+ "进入执行阶段" [shape=doublecircle];
271
+
272
+ "落盘 plan.md" -> "Critic plan";
273
+ "Critic plan" -> "Critical/Major errors?";
274
+ "Critical/Major errors?" -> "Round < 3?" [label="yes"];
275
+ "Critical/Major errors?" -> "进入执行阶段" [label="no"];
276
+ "Round < 3?" -> "Fix plan + 重跑 critic" [label="yes"];
277
+ "Round < 3?" -> "Escalate brainstorming" [label="no"];
278
+ "Fix plan + 重跑 critic" -> "Critical/Major errors?";
279
+ "Escalate brainstorming" -> "落盘 plan.md";
280
+ }
281
+ ```
282
+
283
+ **Track B:** 一轮 critic 即可。**Track C:** 严苛 critic ≤3 轮,超限必须 escalate。
284
+
285
+ 每轮 critic artifact 落盘 `.omc/plans/<topic>-critic-roundN.md`,PR body 引用。
286
+
287
+ ## Critic 决策矩阵
288
+
289
+ | 严重级 | 默认决策 | 例外 |
290
+ |--------|---------|------|
291
+ | **Critical** | 必修 | 无 |
292
+ | **Major** | 修,除非有书面 out-of-scope 理由 | 转 follow-up issue |
293
+ | **Minor** | 修复 if < 5 行;否则附理由拒绝 | 不接受"超出本 PR 范围"作为唯一理由 |
294
+ | **What's Missing** | 转 follow-up issue 或纳入拒绝理由 | 历史遗留需明示 |
295
+
296
+ ---
297
+
298
+ ## 执行 + 并行验证循环(所有 Track 共用)
299
+
300
+ ```dot
301
+ digraph exec_verify {
302
+ "执行代码(task-by-task)" [shape=box];
303
+ "Migration?" [shape=diamond];
304
+ "dx db migrate --dev" [shape=box];
305
+ "Manual SQL fallback" [shape=box];
306
+ "dx db deploy --dev" [shape=box];
307
+ "并行 lint + build + tests (run_in_background)" [shape=box];
308
+ "全部通过?" [shape=diamond];
309
+ "修复失败项" [shape=box];
310
+ "Ready → commit/push/建 PR" [shape=doublecircle];
311
+
312
+ "执行代码(task-by-task)" -> "Migration?";
313
+ "Migration?" -> "dx db migrate --dev" [label="schema 改动"];
314
+ "Migration?" -> "并行 lint + build + tests (run_in_background)" [label="无"];
315
+ "dx db migrate --dev" -> "Manual SQL fallback" [label="drift"];
316
+ "dx db migrate --dev" -> "dx db deploy --dev" [label="ok"];
317
+ "Manual SQL fallback" -> "dx db deploy --dev";
318
+ "dx db deploy --dev" -> "并行 lint + build + tests (run_in_background)";
319
+ "并行 lint + build + tests (run_in_background)" -> "全部通过?";
320
+ "全部通过?" -> "Ready → commit/push/建 PR" [label="yes"];
321
+ "全部通过?" -> "修复失败项" [label="no"];
322
+ "修复失败项" -> "并行 lint + build + tests (run_in_background)";
323
+ }
324
+ ```
325
+
326
+ ### 并行 Verify(不允许串行)
327
+
328
+ ```bash
329
+ # 三个独立 run_in_background Bash 调用
330
+ # dx lint
331
+ # dx build affected --dev (或直接 dx build <target> --dev)
332
+ # dx test unit/e2e 按改动范围
333
+
334
+ # 优先用 SYSTEM 自动通知(每个 background 完成时 task-notification 到达)
335
+ # 不要写本地 pgrep 等待循环
336
+ ```
337
+
338
+ 兜底(仅在通知不可用时):
339
+
340
+ ```bash
341
+ deadline=$(($(date +%s) + 1800))
342
+ until [ -z "$(pgrep -f 'nx (lint|build|test|run-many|affected)' 2>/dev/null)" ]; do
343
+ [ "$(date +%s)" -ge "$deadline" ] && { echo "TIMEOUT"; exit 1; }
344
+ sleep 5
345
+ done
346
+ ```
347
+
348
+ > **为什么不能串行**:lint 失败时 build/test 仍提供独立信号;串行会屏蔽后续问题,增加 fix-rebuild-rerun 循环。3 信号并发 = 单次循环修干净所有维度。
349
+
350
+ ### 验证失败修复循环
351
+
352
+ 任一信号失败 → 修复 → **重跑全部三路**(不允许只重跑失败那一路)→ 直到全绿。
353
+
354
+ 修复轮数无硬上限,但出现以下必须停下来重审:
355
+
356
+ - 同一类错误连续 3 次修复仍出现 → 设计问题,回 plan critic 或 `superpowers:brainstorming`
357
+ - 修一个错引入两个新错 → 同上
358
+
359
+ ## Manual Migration Fallback
360
+
361
+ `dx db migrate --dev --name X` 报 "dev DB drift / reset" 时:
362
+
363
+ ```bash
364
+ TS=$(date -u +%Y%m%d%H%M%S)
365
+ mkdir -p apps/backend/prisma/schema/migrations/${TS}_<name>
366
+
367
+ # 手写 migration.sql(参考已存在的 migration 文件抄格式)
368
+
369
+ dx db deploy --dev
370
+ dx db generate
371
+ pnpm type-check:backend
372
+ ```
373
+
374
+ > 📝 `dx db reset --dev` 是 dev 环境合法但最后手段操作。优先:Manual SQL → `dx db migrate --dev --name X` → reset(与队友确认后)。生产 / staging reset 禁止。
375
+
376
+ ---
377
+
378
+ ## PR 创建段(所有 Track 共用 · 验证全绿后执行)
379
+
380
+ ### 1. Commit
381
+
382
+ ```bash
383
+ git add -A
384
+ git diff --cached --stat
385
+ git commit -F - <<'MSG'
386
+ <type>: <概要>
387
+
388
+ 变更说明:
389
+ - <改动点 1:做了什么 + 为什么>
390
+ - <改动点 2>
391
+
392
+ Refs: #<issue-id>
393
+ MSG
394
+ ```
395
+
396
+ 多 commit 的复杂 PR:按"一个逻辑改动一个 commit"组织,PR 合并时 `--squash` 会折叠。
397
+
398
+ ### 2. Push
399
+
400
+ ```bash
401
+ git push -u origin HEAD
402
+ ```
403
+
404
+ ### 3. 合并冲突检测
405
+
406
+ ```bash
407
+ git fetch origin main
408
+ git merge --no-commit --no-ff origin/main
409
+ ```
410
+
411
+ - 无冲突 → `git merge --abort` 撤回,继续 4
412
+ - 有冲突 → `git merge --abort` → `git merge origin/main` 解冲突 → commit `merge: 解决与 main 的冲突` → push
413
+
414
+ ### 4. 收集变更分析
415
+
416
+ ```bash
417
+ git log origin/main..HEAD --oneline
418
+ git diff origin/main...HEAD --stat
419
+ git diff origin/main...HEAD
420
+ ```
421
+
422
+ ### 5. 创建 PR
423
+
424
+ PR 描述必须让 reviewer 不看代码就能理解改动目的:
425
+
426
+ ```bash
427
+ gh pr create --base main \
428
+ --title "<type>: <概要>" \
429
+ --body-file - <<'MSG'
430
+ **PR Train:** N/Total(依赖 #prev-pr-num) <!-- 仅 Track C 加这行 -->
431
+
432
+ ## 变更目的
433
+
434
+ [为什么做这个改动,解决了什么问题]
435
+
436
+ ## 主要改动
437
+
438
+ ### [模块/文件组 1]
439
+ - [改动描述:做了什么 + 为什么]
440
+
441
+ ### [模块/文件组 2]
442
+ - [改动描述]
443
+
444
+ ## 影响范围
445
+
446
+ - **API 变更**:[有/无,列端点]
447
+ - **数据库变更**:[有/无,说明迁移]
448
+ - **向后兼容**:[是/否,说明破坏点]
449
+
450
+ ## 验证情况
451
+
452
+ - [x] 本地 lint / build / 关联测试通过
453
+ - [ ] 待 CI 验证项
454
+
455
+ ## 哨兵 SQL(消费侧 PR 必填,其余可省)
456
+
457
+ ```sql
458
+ SELECT count(*) ... FROM ...;
459
+ -- 输出:rows=128, populated=128, last_run=2026-05-19 08:00:00
460
+ ```
461
+
462
+ ## 关联
463
+
464
+ Closes: #<issue-id> <!-- 末 PR 用 Closes;中间 PR 用 Refs -->
465
+ MSG
466
+ ```
467
+
468
+ 记录返回的 PR 编号。
469
+
470
+ ### 6. 输出 PR Handoff
471
+
472
+ ```
473
+ [PR Handoff]
474
+ 模式:Track <A/B/C>,<N>/<Total>
475
+ 当前 PR:#<num> <标题> — 已 push 待 review
476
+ Issue: #<id>
477
+ 建议下一步:调用 pr-train-ship --pr <num> 进入审查→合并流程
478
+ ```
479
+
480
+ ---
481
+
482
+ ## Hard Gates(不可跳过)
483
+
484
+ 1. **Track 闸门** — Step 0 必须输出 Track 判定后才进入。
485
+ 2. **Issue Gate** — 切分支前必须有 issue + 4 段齐全;验收标准缺失 = 不允许实现。
486
+ 3. **Plan critic gate**(B / C)— 没通过 plan critic 不得进入执行。
487
+ 4. **PR0 哨兵 gate**(C 且涉及异步写入)— 写入侧真实跑过一次后,消费侧 PR body 必须贴 SQL 证据。
488
+ 5. **Critic 上限**(C)— plan critic ≤3 轮,超限必须 escalate `superpowers:brainstorming`。
489
+ 6. **验证未全绿不创建 PR** — 三路并行验证全部 exit 0 才能 commit/push/建 PR。
490
+ 7. **Train 依赖串行 gate**(C)— 本 PR 依赖的上游 PR 必须已 merge 到 main 才能切本 PR 分支。
491
+ 8. **不越界做审查/合并** — 本 skill **禁止** `gh pr comment` 发审核报告 / `gh pr merge`。审查 + 合并全部交 `pr-train-ship`。
492
+ 9. **Heredoc gate** — commit / PR body / Issue body 多行内容必须 heredoc,禁止 `-m "...\n..."`。
493
+ 10. **不在 main commit** — 必须先切分支。
494
+
495
+ ## Quick Reference
496
+
497
+ | 操作 | 命令 |
498
+ |------|------|
499
+ | 查 issue | `gh issue list --search "<keyword>" --state open` |
500
+ | 创建 issue | `gh issue create --title "..." --body-file - <<'MSG' ... MSG` |
501
+ | 补全 issue | `gh issue edit <id> --body-file - <<'MSG' ... MSG` |
502
+ | 切分支 | `git checkout main && git pull && git checkout -b feat/<id>-<slug>` |
503
+ | Critic plan | `Task` / `Agent` tool with `subagent_type: oh-my-claudecode:critic` |
504
+ | 手动迁移目录 | `mkdir -p apps/backend/prisma/schema/migrations/$(date -u +%Y%m%d%H%M%S)_<name>` |
505
+ | 应用迁移 | `dx db deploy --dev` |
506
+ | 并行 verify | 三个 `run_in_background` Bash 分别跑 `dx lint` / `dx build ... --dev` / `dx test ...` |
507
+ | 冲突检测 | `git fetch origin main && git merge --no-commit --no-ff origin/main` |
508
+ | 创建 PR | `gh pr create --base main --title "..." --body-file - <<'MSG' ... MSG` |
509
+ | 检查依赖 PR 是否已 merge | `gh pr view <num> --json mergedAt` |
510
+
511
+ ## Common Mistakes
512
+
513
+ | 错误 | 加固 |
514
+ |------|------|
515
+ | 跳过 Step 0 凭感觉判定 Track | Hard Gate 1 |
516
+ | 没 issue 直接切分支 | Hard Gate 2 |
517
+ | Issue 只有标题就当合格 | 4 段必须齐全,验收标准必须可勾选 |
518
+ | Track B/C 在写 plan 之前先建 issue | 时序错:issue "方案"段要引用 plan 路径 |
519
+ | "只是加一个字段" 跳过 Track C | D3 硬升级,schema 改动一律进 C |
520
+ | Schema diff 当 plan | Plan 含拓扑序、哨兵、import 路径、Verify |
521
+ | 串行 lint→build→test | 并行 3 路 |
522
+ | 第一反应 `dx db reset --dev` | reset 是最后手段 |
523
+ | 第 3 轮 critic 仍未过强行 minor 妥协 | 必须 escalate brainstorming |
524
+ | 验证只跑一路就 push | 三路全绿才能 push |
525
+ | 本 skill 内部 `gh pr comment` 发审核 | Hard Gate 8:审查交 `pr-train-ship` |
526
+ | 本 skill 内部 `gh pr merge` | 同上 |
527
+ | Track C 上游 PR 还没 merge 就 push 下游 | Hard Gate 7:依赖串行 |
528
+ | commit / PR body 用 `\n` 字面量 | Hard Gate 9:必须 heredoc |
529
+ | 一次会话内 push 多个有依赖关系的 PR | 每次只 push 一个,等其 merge 后再继续 |
530
+ | 同一类错连修 3 次仍出现 | 回 plan critic 或 brainstorming |
531
+
532
+ ## Tie-In With Other Skills
533
+
534
+ - `superpowers:brainstorming` — 设计阶段;critic escalate 时回到此
535
+ - `superpowers:subagent-driven-development` — task-by-task 执行推荐工具
536
+ - `pr-train-ship` — 本 skill 输出 PR 编号后的下游:审查 + 合并
537
+ - `oh-my-claudecode:critic` agent — 通过 `Task` / `Agent` 工具调度