Spec Kit 整合指南
Spec Kit(GitHub 開源)是 Spec-Driven Development 工具,核心理念是「先寫規格再開發」。GST 團隊將 Spec Kit 整合到現有的 Linear + Skills 工作流中。
兩種開發模式
| 模式 | 適用場景 | 工具 |
|---|---|---|
| Spec Kit 模式 | 大 Feature(>5 Issues)、重構、新專案 | Architect + Spec Kit |
| 傳統模式 | 小 Feature(2-5 Issues)、Bug Fix | 直接開發 |
架構
角色分工
| 角色 | 職責 | Spec Kit 關係 |
|---|---|---|
| PM | 協調、追蹤、建 Issue | 將 tasks.md 轉為 Linear Issues |
| Architect | 規格、計畫、任務拆解 | constitution → specify → plan → tasks |
| Dev | 實作程式碼 | 讀 spec + plan 作為開發 context |
| Project Test | 端到端功能驗收 | 讀 spec AC → 驗收 |
| Reviewer | Code Review | 對照 constitution + spec 審查 |
Spec Kit 目錄結構
目標 repo 安裝 Spec Kit 後的結構:
{target-repo}/
├── .specify/
│ ├── init-options.json # 初始化設定
│ ├── memory/
│ │ └── constitution.md # 專案原則(最高權威)
│ ├── templates/ # 模板
│ └── scripts/powershell/ # 輔助腳本
├── specs/
│ └── ###-feature-name/ # 每個 Feature 一個目錄
│ ├── spec.md # 功能規格
│ ├── plan.md # 實作計畫
│ ├── research.md # 研究產出
│ ├── data-model.md # 資料模型
│ ├── tasks.md # 任務清單
│ ├── checklists/ # 品質檢核
│ └── contracts/ # 介面契約
└── .agent/commands/speckit.*.md # Slash Commands
完整工作流
Spec Kit 模式(大 Feature / 重構)
Step 1: PM 建立 Parent Issue(Linear)
Step 2: PM 指派 Architect Task
Step 3: Architect 在目標 repo 執行 full-cycle
constitution → specify → clarify → plan → tasks → analyze
Step 4: Architect 產出 Handoff Report → PM
Step 5: PM 將 tasks.md 轉為 Linear Sub-Issues(含依賴 + specs/ 引用)
Step 6: Dev 依序取得 Sub-Issue → 讀 spec + plan → 開發
Step 7: Dev 完成 → 產出完成回報(含 spec 覆蓋)
Step 8: Project Test 驗收(有 qa/ 的專案)
Step 9: PM 建立 PR(含 spec 引用 + constitution 合規)
Step 10: Reviewer 審查(對照 constitution + spec 驗收條件)
傳統模式(小 Feature / Bug Fix)
PM 產出開發指令 → Dev 取得任務 → 開發 → 完成回報 → 建 PR → Review
(無 Spec Kit 參與)
GST Constitution 標準原則
所有 GST 專案的 Constitution 以此為基礎(視專案調整):
| # | 原則 | 說明 |
|---|---|---|
| I | Layered Architecture | Core 與 UI 分離 |
| II | GST Framework First | 優先使用 GST 底層元件 |
| III | Dependency Injection | 所有 Service 透過 DI 注入 |
| IV | MVVM Strict Compliance | WPF 必須 CommunityToolkit.Mvvm |
| V | Testing Requirements | Core 層關鍵 Service 必須有測試 |
| VI | Naming Conventions | 遵循 GST 命名慣例 |
| VII | Error Handling | BackgroundService 不可因例外終止 |
| VIII | Performance Standards | 明確定義量化指標 |
重構場景額外原則
| 原則 | 說明 |
|---|---|
| 向後相容 | 重構不可破壞現有功能 |
| 漸進式改善 | 每個 Task 完成後系統可建置可運行 |
| 測試先行 | 重構前先補測試 |
| Core 優先 | 優先重構可被後續 Phase 重用的層 |
Spec 文件版控
需 commit:
.specify/memory/constitution.md
specs/{feature-name}/
不需 commit(加 .gitignore):
.specify/templates/
.specify/scripts/
.specify/init-options.json
已知限制
Spec Kit CLI 安裝
specify init 在非互動 shell 會卡住(Rich TUI 相容性問題)。必須在 Windows Terminal PowerShell 中手動執行:
cd {target-repo}
uvx --from "git+https://github.com/github/spec-kit.git" specify init --here --no-git --force
Linear GitHub Automation 設定
必須調整 team 設定,否則建 PR 時 Issue 狀態會被 reset:
| 設定 | 建議值 |
|---|---|
| On PR or commit open | No action |
| On PR review request | In Review |
| On PR or commit merge | Done |
| Auto-close parent issues | 啟用 |