Subagent Parallel Development Code Review¶
概念概覽
Subagent 並行開發的 Coding Style 風險¶
核心知識¶
Subagent 並行開發的 Coding Style 風險¶
使用 subagent 並行實作多個子任務(如 W6.1–W6.6 六個 worker)時,各 subagent 缺乏跨任務的 coding style 一致性約束,容易在以下地方出現違規:
- 變數命名:Go 慣例是小寫開頭(
ctx、userID),subagent 生成程式碼中容易出現大寫開頭(Ctx、UserID) - 其他 coding-style.md 中的規範,subagent 若未在 prompt 中收到完整規則,會依自身預設行為生成
強制審查流程¶
subagent 並行產出
→ 合併前逐一 code review
→ 必查項:coding-style.md 所有規則
→ 違規:不可接受,必須強制修正(不是可選建議)
→ 修正後才能合併進主 branch
與 repo-wide Build Failure 的邊界劃分¶
當 git diff --name-status main 確認 build failure 不在本 branch 引入的檔案範圍內,屬於 repo-wide merge blocker,應開獨立 issue 追蹤,不應阻塞當前 PR 的程式碼審查。
經驗教訓¶
-
subagent prompt 必須附帶完整 coding-style.md 規則,而非假設 subagent 知道 repo 慣例
-
並行任務完成後的整合 review 是必要步驟,不能因為「自動生成」就降低審查標準
常見陷阱¶
-
以為 subagent 看過 codebase 就會自動遵守 coding style,實際上每個 subagent 是獨立 context
-
把 repo-wide build failure 歸咎於當前 PR,或反過來完全忽略不處理,兩者都不正確
最佳實踐¶
-
在 subagent prompt template 中固定加入 coding-style.md 的 key rules section
-
建立 subagent 產出的 checklist:變數命名、error handling pattern、import 順序等必查項
相關概念¶
來源 Sessions¶
| 日期 | Session | 貢獻摘要 |
|---|---|---|
| 2026-04-02 | 157b6880-f9d3-466a-abf9-07af0459b5d5 | 記錄了 subagent 並行開發模式下 coding-style 違規的高發場景及強制審查要點 |