feat(design): support new Claude Design handoff bundle (gzip+tar) - #9
feat(design): support new Claude Design handoff bundle (gzip+tar)#9gpwork4u wants to merge 9 commits into
Conversation
…estion 實跑 benchmark 時發現現行 sync-design.sh 無法吃 api.anthropic.com 的新版 handoff bundle(gzip+tar,內含 README + chats/ + project/*.jsx),會把壓縮檔 存成 index.html 導致 frontend pixel-perfect gate grep 不到任何元件。 - sync-design.sh: 自動偵測 bundle(tar) vs 單頁 html;bundle 解開後攤平 project/ 內容(index.html + *.jsx + styles.css + screenshots/)+ 保留 chats/ 與 BUNDLE-README.md;URL 抽取支援 api.anthropic.com;metadata 標註攝取格式與 「元件在 *.jsx 不是 index.html」「chats/ 是意圖來源」 - engineer.md pixel-perfect gate: grep 改成掃整個 design-source/(bundle 落在 *.jsx) - spec-writer.md: bundle 模式先讀 chats/ 反推意圖,testid grep *.jsx 驗證:sandbox 用真實 bundle 跑 sync-design 全程通過(10 元件檔 + chats + 截圖 + 完整 metadata);selftest 8/8。 Co-Authored-By: Claude <noreply@anthropic.com>
實跑請假系統 bundle 發現 prototype 的 *.jsx 完全沒有 data-testid(抽到 0 個),
暴露 workflow 假設「從 design 抽 testid」對 Claude Design prototype 不成立。
修正 testid 語義(design 提供結構/字串,testid 由 contract phase 擁有):
- ui-designer.md: 「design 有 testid 就沿用;沒有(常態)就依元件結構發明 kebab-case
testid 作為測試合約」;字串仍須忠實照搬不可發明
- tech-lead.md: 解除「不自創 testid」硬規則,改為照單吸收 ui-designer 發明的 testid;
UI 字串仍須忠實照 design
- engineer.md: frontend 實作時把 contracts.ts 的 data-testid 加到元件上(別預期 design 有)
- spec-writer.md: testid grep 為 0 屬正常,AC 用 {TESTIDS.xxx} placeholder
selftest 8/8。
Co-Authored-By: Claude <noreply@anthropic.com>
追加:發現③ testid 合約語義修正(同分支)實跑請假系統 bundle 時 已修(commit 隨本 PR):
→ design 角色澄清為「提供視覺/結構/字串」,testid 是團隊在 contract phase 擁有的合約。 |
… gate) 實跑 demo 發現 spec-writer/tech-lead 寫的 specs/ 停在 working tree 未進版控, worktree-isolated 的 engineer/qa/ui 從 origin clone 後讀不到 spec/contract, 會憑空亂寫。新增 Phase 3.8:commit specs/ 到 main(受保護則開 PR 合併)+ 確認 contracts.ts 在 main 上才放行。 Co-Authored-By: Claude <noreply@anthropic.com>
追加:發現④ orchestration gap(同分支,start skill Phase 3.8)實跑 demo 的 spec→tech-lead 階段揪出:spec-writer/tech-lead 寫的 已修:start skill 新增 Phase 3.8 hard gate — spawn lane 前 commit Benchmark run 結果(gpwork4u/leave-demo)瘦身 + bundle + testid 修正後的 opus 雙 agent 在真實請假系統 bundle 上全跑通:
→ 證實發現③修正有效(testid 發明流程端到端成立)、瘦身後的 spec-writer/tech-lead prompt 在真實專案可靠執行。 |
跑 demo backend engineer 揪出的真實缺陷: - contract-check.sh: report() 在 echo|while subshell 累加 VIOLATIONS,丟失 → 腳本永遠 exit 0、防漂移核心形同虛設。改為主 shell add_violations 累加。 - contract-check.sh: Check 2/5 只擋雙引號 "/api/",單引號 '/api/' 漏網 → 改 char class ["'] 同抓單雙引號。 - selftest.sh §4: 從「只驗語法」升級為「驗違規 exit 1 / 乾淨 exit 0」功能測試, 讓上述 bug 永不回歸。 - engineer.md: Step 4 路徑 bug(overview.md→specs/overview.md);澄清 docker 自驗是 Step 5 開發期選配非收尾 gate;補「turn 將盡先 push 保 deliverable」。 selftest 8/8(含新的 contract-check 功能驗證)。 Co-Authored-By: Claude <noreply@anthropic.com>
追加:發現⑤(最嚴重)+ engineer 真實驗證從 leave-demo 跑一個 backend engineer(issue #3:Prisma schema+seed+auth+RBAC+10 unit tests,PR #19 merged,contract 全 import)→ 驗證瘦身後 engineer.md 可驅動正確行為,且 engineer 回報了具體可改進處。 🔴 發現⑤(最嚴重)contract-check.sh 形同虛設: 順帶修:
selftest 8/8(含新的 contract-check 功能驗證)。 |
跑 demo frontend engineer(issue #9)揪出的真實缺陷: - frontend-scaffold.sh: 在 backend+frontend 共用一個 dev/ 時,直接把 Vite 骨架寫進 dev/ 根會**覆蓋 backend 已 merged 的 package.json / tsconfig.json**。修:偵測 dev/ 已有非前端 package.json → scaffold 隔離到 dev/web/(contracts 相對路徑連動調整), 純前端專案維持 dev/ 根(向後相容)。 - contract-check.sh: full 模式 find 沒 prune node_modules → 第三方 .d.ts 的 data-testid 範例被當違規。修:prune node_modules/dist/build/coverage/.next。 (此 bug 過去被 VIOLATIONS subshell bug 意外抵銷;修了 subshell 後若不 prune, 每個有 node_modules 的 frontend local-checks 都會誤擋——兩者必須一起修。) selftest 8/8。 Co-Authored-By: Claude <noreply@anthropic.com>
追加:frontend engineer 驗證 + 發現⑥⑦從 leave-demo 跑 frontend engineer(issue #9:登入+AppShell+導覽,PR #20 merged)。正面驗證:bundle 格式下 pixel-perfect gate 好用(一次找對 *.jsx)、從 contract 加 testid 流程順、deliver-first/contract import 無雷。又揪出兩個真實 bug:
至此 benchmark 共揪 7 個可靠度缺陷全修,backend + frontend 兩個 engineer lane 實跑驗證通過。selftest 8/8。 |
跑 demo pipeline engineer(issue #15)揪出: - ⑪ local-checks.sh contract 用 full mode → 修了 contract-check subshell bug 後, 任一 lane 的既有 contract 債會卡死所有其他 lane 的 push。改用 --diff origin/main 只查本分支改動(critical:⑤修正的必要配套)。 - ⑧ kit §3 compose 範本只有單一 app:補「contracts 在 build context 之外 → context 設 repo root」+「fullstack 雙子專案 db/api/web 三服務」指引(套舊範本的 backend Dockerfile 其實 build 不起來)。 - ⑨ ready-and-merge.sh 把 GitHub 帳務/基礎設施擋住的 CI 誤判為失敗而 deadlock: 偵測 billing/startup_failure → exit 2(與真失敗 exit 1 區分)+ 清楚訊息,不靜默 擋死也不冒險自動 merge。 - ⑩ kit 補:寫 workflow YAML 後 push 前本地 yaml.safe_load 驗語法。 selftest 8/8。 Co-Authored-By: Claude <noreply@anthropic.com>
跑 demo qa engineer(issue #17,88 個 e2e test)揪出:
- ⑫ contract-check Check 5 誤判 consumer lane:用 `grep '^\+.*data-testid='` 純計數,
把正確的模板插值 `[data-testid="${TESTIDS.x}"]` 算成「新增 hardcoded contract」→
任何用 testid 的 frontend/qa PR 結構性紅燈。改為只算真 literal(同 Check 1/2 pattern)
並排除 TESTIDS./API_PATHS 插值。
- ⑨ ready-and-merge billing 偵測補上 BlobNotFound(GitHub Actions 帳號 startup 失敗的
常見 log 字樣)。
selftest 8/8。
Co-Authored-By: Claude <noreply@anthropic.com>
追加:pipeline + qa lane 驗證 + 發現⑧–⑫(共 12 個缺陷)跑完 pipeline engineer(#15 PR#21 merged)與 qa engineer(#17 PR#22,88 test 1:1 對 88 AC)。至此 5 種 agent 全驗過(spec/tech-lead/backend/frontend/pipeline/qa)。 新增 5 個缺陷(多數是發現⑤「contract-check 永遠 exit 0」修好後浮現的連鎖):
|
Co-Authored-By: Claude <noreply@anthropic.com>
benchmark sprint-end 揪出⑬:code-review 與 verifier agent 會深挖每個檔卻在 耗盡 turn 前都沒寫出報告檔(報告產出指令原本在 prompt 末端)。改為在 agent 開頭結構性強制「報告檔骨架是第一個 Write 動作、邊查邊填」,並提醒抽查代表 性檔即可、寧可粒度粗也要寫出 verdict(同 deliver-first 的 all-or-nothing 精神)。 Co-Authored-By: Claude <noreply@anthropic.com>
追加:完整 Sprint 1 跑完 + 發現⑬(共 13 個缺陷)用 benchmark 把請假系統 Sprint 1 完整跑完並收尾(跳過 billing 擋住的 CI、admin merge):6 lane 全 PR merged、87 unit + 88 e2e、milestone 關閉。 Sprint review 真的抓到跨 lane CRITICAL(per-PR 看不到的):
發現⑬ code-review / verifier agent 深挖不寫報告:兩個唯讀 agent 逐檔深挖、耗盡 turn 前都沒寫出報告檔(產出指令原在 prompt 末端)。修:agent 開頭結構性強制「報告檔骨架是第一個 Write 動作、邊查邊填、抽查代表性檔即可」(同 deliver-first 的 all-or-nothing 精神)。 至此 benchmark 共揪 13 個可靠度缺陷全修,全 5 種 agent + 完整 sprint 流程(spec→plan→6 lane→review→verify→close)實跑驗證。selftest 8/8。 |
squash of PR #9(feat/design-bundle-support,stacked on #8)。實跑請假系統 benchmark 驗證瘦身後 prompt + 系統性找出並修復 13 個缺陷: contract-check 永遠 exit 0、frontend-scaffold 摧毀 backend、sync-design 不吃 bundle、testid 抽取假設、specs 未版控、node_modules 誤報、Check5 插值誤判、 local-checks full-mode、compose build context、ready-and-merge billing、 YAML lint、review/verifier 不寫報告。詳見 docs/BENCHMARK-2026-05.md。 Co-authored-by: Claude <noreply@anthropic.com>
Summary
實跑 benchmark(請假系統 design)時發現 SpecFlow 的 design 攝取與當前 Claude Design 匯出格式不相容——這是比 prompt 瘦身更關鍵的可靠度 gap:任何用新版 Claude Design 的專案會在第一步翻車。
問題
Changes
project/(index.html + *.jsx + css + screenshots)+ 保留chats/與BUNDLE-README.md;URL 支援 api.anthropic.com;metadata 標註格式與「元件在 *.jsx」「chats 是意圖來源」Test Plan
selftest.sh8/8 PASS🤖 Generated with Claude Code