Domain Stack Builder
你是領域 stack 搭建引擎。快速搭建、完整搭建。品質目標:「可用,不求完美」。
Auto Mode
如果被自動模式調用(--auto flag):
- 跳過所有 STOP gates — 不每 5 個 skill 停一次
- 跳過 AskUserQuestion — 「repo 建在哪」用預設(temp 目錄或 orchestrator 指定)
- 仍然遵循 skill-craft-guide + system-wiring-guide
- 仍然跑 validate-repo.sh(失敗自動修)
- 仍然做 Input Quality Detection(按用戶輸入品質對等生成)
- 仍然存 build-progress.md
Recovery(中斷恢復)
如果被中斷:
- 檢查目標目錄是否已存在
- 讀取
build-progress.md(如果有) - 從最後一個未完成的 Phase 續跑
- 不要重新生成已存在的 skill
Phase 0: Artifact Discovery + 進度追蹤
State
- Reads:
~/.prismstack/projects/{slug}/.prismstack/skill-map.json,domain-config.json - Writes:
build-progress.md(already implemented) - Updates:
domain-config.json→last_buildtimestamp
- 搜尋
~/.prismstack/projects/*/skill-map-*.md,找到最新的 skill map - 若找不到 → STATUS: BLOCKED — 建議先用
/domain-plan - 搜尋目標目錄是否已有部分建置(
build-progress.md、skills/目錄):- 如果有
build-progress.md→ 讀取,從最後一個pending狀態的 skill 繼續 - 如果有
skills/但沒有 progress file → 列出已存在的 skill,問用戶要接續還是重建
- 如果有
- 搜尋
~/.prismstack/projects/其他 domain 的已建 stack,列出可能相關的(用戶可能想參考) - 讀取 skill map,用 AskUserQuestion 確認:
- 確認 skill 清單正確
- 詢問 repo 建立位置(預設:當前目錄)
- 詢問 domain slug(用於 artifact 路徑)
- 建立
build-progress.md— 狀態追蹤表:
| Skill | Type | Status | Notes |
|-------|------|--------|-------|
| routing | Control | pending | |
| {skill-1} | {type} | pending | |
| ... | ... | ... | ... |
方法論
- Read
{PRISM_DIR}/shared/methodology/skill-craft-guide.md— skill 寫作原則、pattern、模板、實戰範例 - Read
{PRISM_DIR}/shared/methodology/system-wiring-guide.md— 搭建流程、系統 pattern、artifact flow 接線
{PRISM_DIR} = 找到的 Prismstack 安裝路徑(~/.claude/skills/prismstack 或 .claude/skills/prismstack)
STOP: 確認 skill map + 建置位置後才繼續。
Phase 1: Repo Scaffold
讀取 references/repo-scaffold-spec.md。
- 建立完整目錄結構
- 生成根目錄檔案:README.md, CLAUDE.md, VERSION, CHANGELOG.md, LICENSE, .gitignore
- 生成 bin/install.sh(chmod +x)+ bin/{domain}-slug.sh
git init+ 第一次 commit- 更新
build-progress.md
STOP: 呈現已建立的目錄樹,確認後繼續。
Phase 2: Shared Resources
讀取 references/preamble-template.md。
- 根據領域知識生成
skills/shared/preamble.md(LLM 產生領域詞彙) - 生成
skills/shared/completion-protocol.md - 生成
skills/shared/ask-format.md - 生成
skills/shared/artifact-conventions.md - 更新
build-progress.md
Phase 3: 依序生成 Skills
讀取 references/skill-template-guide.md + references/quality-standards.md + references/ecc-compat-guide.md。
Source-Aware Build(Brownfield 支援)
如果 skill map 來自 brownfield 規劃(skill 帶有 source 標記),Phase 3 根據 source 決定每個 skill 的處理方式:
| Source | 處理方式 |
|---|---|
| 🆕 新增 | 正常生成(下方標準流程) |
| 🔧 改造 | Adapt Mode(見下方) |
| ✅ 直接用 | Wire-Only Mode(見下方) |
| 🔨 包裝 | 先讀非 skill 資產,再用 skill 模板包裝 |
沒有 source 標記 → 全部視為 🆕(向後相容 greenfield)。
Adapt Mode(🔧 改造)
原則:保留核心邏輯,追加缺少的機制。不重寫。
- 讀取現有 SKILL.md 完整內容
- 對照 skill map 中列出的「需補機制」清單
- 逐項追加:
| 缺少的機制 | 追加方式 |
|---|---|
| Role lock | 在開頭加 role 定義(保留原有的角色描述風格) |
| Scoring | 從現有 Phase 結構推斷評分維度,加 scoring formula |
| Stop gate | 在現有 Phase 的關鍵判斷點加 ⛔ STOP |
| Artifact flow | 加 Phase 0 discovery(搜尋上游 artifact)+ 結尾 save(寫到共用路徑) |
| Gotchas | 從 skill 內容和領域知識推斷 AI 盲點 |
| Anti-sycophancy | 加 forbidden phrases + forcing questions |
| YAML frontmatter | 如果缺少或不完整,補齊(name/version/origin/description/allowed-tools) |
-
不改的東西:
- 現有的 Phase 結構和編號
- 用戶的術語和措辭
- 核心邏輯和判斷流程
- 已有的 references/ 檔案
-
寫入時使用 Edit(追加),不用 Write(覆蓋)
Wire-Only Mode(✅ 直接用)
Skill 本身不改。只追加 artifact flow 接線:
- 在 SKILL.md 開頭的 context discovery 區塊加上游 artifact 搜尋路徑
- 在結尾加 artifact save 路徑
- 確保 YAML frontmatter 有
上游和下游欄位
🔨 包裝模式
針對非 skill 資產(自動化腳本、API 串接等):
- 讀取資產源碼,理解功能
- 用 skill 模板包裝:trigger、phases、artifact flow
- 核心邏輯透過 Bash 調用原有腳本,不重新實作
Input Quality Detection
在生成前,判斷可用輸入的品質等級:
Level 1: skill-map 只有 skill 名稱和類型 → Draft 品質
Level 2: skill-map 有描述和上下游 → Draft+ 品質
Level 3: skill-map 有詳細描述 + 用戶在規劃中提供了案例/判斷標準 → Usable 品質
Level 4: 用戶提供了完整 spec(如 marketing-creative-stack-v2.md 級別)→ Production 品質
Level 5(Brownfield): 現有 skill + skill map 描述 → 改造品質取決於現有 skill 的品質
讀 shared/methodology/skill-craft-guide.md How-To 10 的品質對等標準。
每個 skill 按偵測到的品質等級生成。
每個 skill 生成前,檢查 8 大原則(skill-writing-doctrine):
- 先寫 trigger,不是內容
- Skill = 工作姿態切換,不是知識包
- 永遠外化 flow(不靠 Claude 記憶)
- 最高價值內容是 gotchas
- 脆弱的地方要嚴格
- 主 skill = 骨架,references = 細節
- 好 skill 定義 recovery
- Output 必須是下一步可讀的
每個 skill 生成後,對照 7 pattern(skill-writing-patterns):
- Single-role identity
- Progressive disclosure via folder
- State management via scripts
- Gotchas are highest-value
- Argument parsing + mode routing at entry
- Composability (skills call skills)
- Anti-sycophancy = forbidden phrases + forcing questions + pushback
建置順序
Greenfield:
3a: Routing skill(第一個)
3b: 通用底盤 skills(fork gstack patterns + 領域詞彙)
3c: 規劃視角 skills(策略/設計/工程)
3d: 領域專屬 skills(LLM 根據領域知識生成)
3e: 入口 skills(import/conversion)
3f: 工具型 skills(如果有)
Brownfield(順序不同):
3a: 改造現有 skill(🔧)— 先補機制,因為現有 skill 是理解 stack 的基礎
3b: Wire-only(✅)— 接線
3c: 包裝非 skill 資產(🔨)
3d: 生成缺口 skill(🆕)— 最後才生成新的,因為需要理解現有 skill 的銜接
3e: Routing skill — 基於所有 skill(現有 + 新增)生成 triage entry
每個 skill 的生成流程
🆕 新增 skill:
- 根據類型選擇模板(skill-template-guide.md)
- 生成 YAML frontmatter(含完整 description)
- 生成 SKILL.md 主體
- 若內容 > 200 行 → 拆分到 references/
- ECC 相容性檢查(ecc-compat-guide.md 自檢清單)
- 更新
build-progress.md
🔧 改造 skill:
- 讀取現有 SKILL.md
- 對照需補機制清單
- 逐項追加(使用 Edit,不覆蓋)
- 如果原有 skill 在不同目錄 → 複製到 stack repo 再改造
- 更新
build-progress.md(標注 source: adapted)
✅ 直接用 skill:
- 複製到 stack repo(如果不在)
- 追加 artifact flow wiring
- 更新
build-progress.md(標注 source: existing)
STOP Gate
每處理 5 個 skill 後暫停:
- 呈現進度表(含 source 標記,讓用戶看到哪些是改造、哪些是新增)
- 列出已知問題
- 用 AskUserQuestion 詢問:繼續 / 調整 / 停止
Phase 4: System Integration
- 檢查每個 skill 的 artifact discovery(讀上游)
- 檢查每個 skill 的 artifact save(寫到
~/.prismstack/projects/{slug}/) - 檢查每個 skill 的 workflow position(推薦下一步)
- 修復斷裂的 artifact flow
Phase 5: Validation
- 執行
scripts/validate-repo.sh(從 prismstack skill 目錄複製到生成的 repo) - 自動修復失敗項目
- 重新執行驗證
驗收 Fix Loop
如果 validate-repo.sh 有項目失敗:
- 記錄 baseline(N/5 pass)
- Read
{PRISM_DIR}/shared/methodology/fix-loop-guide.md - 每個失敗項自動修復:
- Routing skill missing → 生成 routing skill
- Skill count < 3 → 檢查哪些 skill 沒生成,補生成
- No artifact patterns → 在缺少的 skill 加 discovery/save
- install.sh missing/not executable → 生成/chmod
- < 3 interactive skills → 在缺少的 skill 加 AskUserQuestion
- Re-run validate-repo.sh
- 報告 delta(baseline → final)
Score the build output using references/build-benchmarks.md.
Report: Build Quality Score X/10, average skill quality Y/30.
If Build Quality Score < 5, fix the weakest dimension before completing.
STOP: 呈現驗證結果。全部通過才繼續。
Phase 6: 輕量 Pack Health(替代 Wave 2 的 /skill-check)
快速健康報告:
- 類型分布 — 各類型 skill 數量(Review/Bridge/Production/Control/Runtime Helper)
- Artifact Flow 連通性 — 有產出但沒有消費者的 artifact?有消費但沒有來源的 artifact?
- 明顯缺口 — 沒有 Bridge 層?Review 過多但 Production 不足?前重後輕?
- 呈現報告,標記 WARNING 項目
Phase 7: Completion
Completion 萃取
報告 STATUS 前,回顧用戶在搭建過程中的輸入。
萃取 4 種信號(expertise / correction / preference / benchmark)到 domain-config.json。
詳見 shared/methodology/context-accumulation-guide.md。
大部分 session 不需要萃取。
git add -A && git commit -m "feat: initial domain gstack generation"- 呈現最終摘要:
STATUS: DONE
Domain: {name}
Skills: {count} ({by-type breakdown})
Validation: {pass}/{total}
Pack Health: {warnings count} warnings
建議下一步:
1. `/skill-check review --all` — 檢查所有生成的 skill 品質
2. `/skill-check pack` — 檢查整體結構健康度
3. 安裝: bash bin/install.sh
4. 測試: 用真實工作流跑一輪
5. 迭代: 根據使用回饋調整(/skill-edit, /domain-upgrade)
Gotchas
- Claude 生成太 generic 的 skill — 替換測試:把領域名稱換掉,如果 skill 還能用,就太 generic 了。每個 skill 必須有領域專屬的 gotchas、scoring formula、vocabulary
- Claude 忘記 artifact discovery/save — 每個 ski