name: erp-mr-create
description: 模块报告完成后,验证当前分支为 module- + worktree 干净,push 推代码和所有 evidence,创建 GitLab MR(报告嵌入描述),把 MR URL 追加到模块报告 § ⑫ 并 commit,把 MR iid 回写到 docs/08 该模块 MR: 字段并 commit,再次 push 同步。完成信号由 MR merged state 判定(docs/08 无 checkbox)。停下等待人工审核。
user-invocable: false
allowed-tools: Read Write Edit Skill Bash(git ) Bash(glab *) Bash(sed *) Bash(awk *) Bash(cat *) Bash(echo *) Bash(mkdir -p .tmp) Bash(mv .tmp/) Bash(rm -f .tmp/*)
所有输出必须使用中文。
erp-mr-create
前置条件
-
erp-module-report已生成报告文件并 commit 到 module 分支。 -
erp-local-test-gate返回了绿色,test-gate.md 已 commit 到 module 分支。 - 当前分支 =
module-<module_id>(由erp-module-start步骤 3 负责切入)。
执行步骤
步骤 0:红旗检查
调用 Skill(erp-red-flag-check) → 命中则停止。
步骤 1:验证当前分支
-
Bash:git branch --show-current→current_branch。 -
current_branch必须匹配module-*;否则打印错误并停止(不自动建分支——分支职责在erp-module-start步骤 3)。 - 从
current_branch取module_id = current_branch去掉"module-"前缀。
步骤 2:验证 worktree 干净(防止 evidence 文件漏 commit)
-
Bash:git status --porcelain - 输出非空 → 打印 dirty 文件清单并停止: ``` ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ [erp-mr-create] ⚠️ worktree 不干净,无法 push
以下文件有未提交改动:
push 前所有 evidence 必须已 commit 到 module 分支。检查点:
- erp-local-test-gate 步骤 3b 是否已 commit test-gate.md?
- erp-module-report 步骤 5b 是否已 commit 模块报告 + cross-module log?
- 本 skill 前没人跑过额外的 Edit/Write?
修复方式:git add <files> && git commit -m "...",然后重跑 /erp-workflow:erp-coding-start。
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
### 步骤 3:push 推送全部已 commit 内容
`git push -u origin <current_branch>` — **不要**使用 `--no-verify`(hook `deny-no-verify.sh` 会拦截)。
此 push 包含:代码 commit(erp-feature-tdd 产出)+ 模块 review fix commit(erp-feature-review 产出)+ test-gate evidence commit(erp-local-test-gate 产出)+ 模块完成报告 commit(erp-module-report 产出)。
### 步骤 4:读取 MR 标题模板
用 `Read` 读取 `${CLAUDE_SKILL_DIR}/templates/mr-title-template.md`,填充 `module_id`、`module_name`,得到 MR 标题字符串(一行,较短,进上下文 OK)。
### 步骤 5:生成 MR 描述文件(纯 shell,不读模块报告内容进上下文)
```bash
mkdir -p .tmp
DESC_FILE=.tmp/mr-desc.md
REPORT="docs/superpowers/module-reports/<date>-<module_id>.md"
# 先用 sed 替换 description 模板的简单槽位
sed -e "s|{{test_gate_conclusion}}|<值>|g" \
-e "s|{{test_subagent_id}}|<值>|g" \
-e "s|{{module_id}}|<值>|g" \
-e "s|{{date}}|<值>|g" \
"${CLAUDE_SKILL_DIR}/templates/mr-description-template.md" > "$DESC_FILE"
# 把模块报告完整内容直接管道注入,替换 {{module_report_contents}} 所在行
awk -v report="$REPORT" '
/\{\{module_report_contents\}\}/ { while ((getline line < report) > 0) print line; close(report); next }
{ print }
' "$DESC_FILE" > .tmp/mr-desc.final
mv .tmp/mr-desc.final "$DESC_FILE"
关键:模块报告内容只经 awk 管道流过,从不进入 LLM 上下文。
步骤 6:创建 MR
TITLE_FILE=.tmp/mr-title.txt
echo "<步骤 4 得到的标题>" > "$TITLE_FILE"
glab mr create --title "$(cat "$TITLE_FILE")" --description "$(cat "$DESC_FILE")"
rm -f .tmp/mr-title.txt .tmp/mr-desc.md
步骤 7:追加 MR URL 到模块报告 § ⑫ 并 commit
- 解析返回的 MR URL 和 IID(
<iid>)。 -
Edit docs/superpowers/module-reports/<date>-<module_id>.md的 § ⑫:把{{mr_url}}占位替换为实际 URL(若已替换过,追加一行)。 -
Bash:git add docs/superpowers/module-reports/<date>-<module_id>.md && git commit -m "docs(<module_id>): record MR !<iid> link in module report"。
步骤 8:回写 docs/08 的 MR 字段并 commit
-
Edit docs/08-模块任务管理.md:把当前模块条目的- MR: —改为- MR: !<iid>(只改一行)。docs/08 § 二每模块是 bullet(- module_id ...,无 checkbox),MR:字段是唯一动态字段。 -
Bash:git add docs/08-模块任务管理.md && git commit -m "chore(<module_id>): record MR !<iid> in docs/08"。
步骤 9:再次 push
步骤 3 的 push 之后,步骤 7 和 8 又产生了两个新 commit(MR link + docs/08 MR iid)。必须再次 push 让 MR 自动更新 commit 列表 + diff:
Bash: git push origin <current_branch>
步骤 10:向会话打印 MR URL
步骤 11:停止 — 等待人工 Approve + Merge
用户合并后再跑 /erp-workflow:erp-coding-start,入口会自动检测 MR merged → git checkout main + git pull --ff-only 同步远程 + 派发下一模块。
设计要点
-
main 是 protected branch,只能通过 MR 修改。MR diff 包含:代码 + 模块报告 + test-gate evidence + cross-module log + docs/08 的
MR: !<iid>字段。 -
完成信号由 MR state 判定——docs/08 § 二每模块是 bullet(无 checkbox),没有可翻勾的地方。从结构上消除"用户抢跑 coding-start 跳过未合并模块"的 ordering bug。仅
MR:字段在—/!<iid>之间变化。 -
worktree 干净前置(步骤 2):保证 test-gate.md、module-report.md、cross-module log.md 都已进 repo,审计证据完整;防止下次 coding-start
git checkout main遇到 dirty state。
参考
${CLAUDE_SKILL_DIR}/templates/mr-title-template.md${CLAUDE_SKILL_DIR}/templates/mr-description-template.md- 上游:
erp-module-report - 守门:
erp-red-flag-check - 下游闸门:用户手工 MR Approve + Merge