Community程式設計與開發github.com

alfathafp/portofolio-web-design

在撰寫程式碼之前先建立規格。適用於啟動新專案、新功能或重大更改,且尚無規格時使用。

portofolio-web-design 是什麼?

這是一份規格驅動開發(Spec-Driven Development)技能,定義了一套結構化的四階段工作流程(規格 → 計劃 → 任務 → 實作),並在每個階段之間設置人工審查關卡。當一個需求包含多個可獨立測試的能力時,它會啟動「範圍檢查」(Phase 0),要求先建立能力地圖(Capability Map),確保模組邊界和依賴方向在撰寫任何規格之前就已明確。此技能支援 Claude Code、Cursor、Codex 等 AI 編碼代理,旨在將模糊的需求轉化為具體、可測試的驗收標準,並強調「先有規格再寫程式碼」的原則,以避免因假設不明確而導致的返工。它提供的規格模板涵蓋目標、指令、專案結構、程式碼風格、測試策略和邊界,並要求規格經人工核准後才能進入下一階段。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/alfathafp/portofolio-web-design/tree/HEAD/.agents/skills/spec-driven-development

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

規格驅動開發

概述

在撰寫任何程式碼之前先寫出結構化的規格。規格是你與人類工程師之間共同的真相來源 — 它定義了我們在建構什麼、為什麼建構,以及如何知道我們已經完成。沒有規格的程式碼就像在猜測。

何時使用

  • 啟動新專案或新功能
  • 需求不明確或不完整
  • 更改會影響多個檔案或模組
  • 你即將做出架構決策
  • 任務預計需要超過 30 分鐘才能實作

何時不使用: 單行修復、打字錯誤修正,或需求明確且自成一體、不具歧義的更改。

關卡式工作流程

規格驅動開發包含四個階段,並在階段之前有一個範圍檢查(Phase 0),該階段僅在一個請求中包含多個可獨立測試的能力時才會啟動。在當前階段未經驗證之前,請勿進入下一階段。

規格 ──→ 計劃 ──→ 任務 ──→ 實作
   │          │        │          │
   ▼          ▼        ▼          ▼
 人類       人類      人類        人類
 審查       審查      審查        審查

Phase 0:範圍檢查

大多數請求描述一個能力。如果這個請求也是如此,請跳過此階段,直接進入「規格」階段 — Phase 0 是為例外情況而存在,而非規則,且它不對單一能力的功能施加任何層級結構。

檢測。 當一個需求包含多個可獨立測試的能力時,請在進行規格化之前先進行分解:

  • 需求中提到了具有各自使用者或數據的獨立能力(例如:身份驗證、帳單、通知、報表)
  • 驗收標準可以分組,每組可以獨立交付和驗證
  • 一個能力可以被刪除或取代,而不需要改寫其他能力的需求

在撰寫任何規格之前,先提出一個能力地圖。 小型且可審查 — 一個模組表格加上建構順序,而非專案計劃:

# 能力地圖:[倡議名稱]

| 模組 ID | 職責 | 依賴於 |
|---|---|---|
| identity | 帳戶、工作階段、SSO | — |
| billing | 方案、發票、付款 | identity |
| notifications | 電子郵件和 Webhook 分發 | identity |
| reporting | 使用儀表板 | billing, notifications |

建構順序:identity → billing, notifications → reporting
  • 穩定的模組 ID。 使用 kebab-case,一旦選定,在倡議期間不可重新命名。規格、計劃和下游指令透過這些 ID 來選擇正在進行的工作,而不是猜測哪個規格是有效的。
  • 依賴方向,無循環。 箭頭指向單一方向。如果兩個模組彼此需要,則它們應合併為一個模組。
  • 介面存在於邊界。 地圖記錄了 billing 依賴於 identity;兩者之間的契約屬於提供者模組的規格(有關設計方式,請參閱 api-and-interface-design)。

地圖與每個階段一樣需要關卡。 在撰寫任何模組規格之前,人類必須審查模組邊界、依賴方向和建構順序。地圖出錯的代價很高;但審查十行程式碼的代價則不高。

然後對每個模組進行遞迴。 按照依賴順序,對每個模組執行「規格 → 計劃 → 任務 → 實作」。每個模組都有自己的規格,範圍限定在該模組的目標、邊界和成功標準。將已核准的地圖儲存在專案根目錄,並將每個模組的規格儲存在其旁邊,以模組 ID 命名(SPEC-identity.md、SPEC-billing.md)— 地圖(而非猜測檔名)是現有規格的索引。

Phase 1:規格

從高層級的願景開始。向人類提出釐清問題,直到需求變得具體。

立即浮現假設。 在撰寫任何規格內容之前,列出你的假設:

我所做的假設:
1. 這是一個網頁應用程式(非原生行動裝置)
2. 身份驗證使用基於工作階段的 Cookie(非 JWT)
3. 資料庫是 PostgreSQL(根據現有的 Prisma Schema)
4. 我們只針對現代瀏覽器(不支援 IE11)
→ 請立即糾正我,否則我將據此繼續。

不要默默地填補模糊的需求。規格的整個目的是在程式碼被寫入之前,就浮現出誤解 — 假設是最危險的誤解形式。

撰寫一份涵蓋以下六個核心領域的規格文件:

  1. 目標 — 我們在建構什麼,為什麼?使用者是誰?成功的樣貌是什麼?

  2. 指令 — 完整的可執行指令,包含標誌,而不僅僅是工具名稱。

    建構:npm run build
    測試:npm test -- --coverage
    Lint:npm run lint --fix
    開發:npm run dev
    
  3. 專案結構 — 原始碼、測試、文件的位置。

    src/           → 應用程式原始碼
    src/components → React 元件
    src/lib        → 共用工具
    tests/         → 單元和整合測試
    e2e/           → 端對端測試
    docs/          → 文件
    
  4. 程式碼風格 — 一個真實的程式碼片段比三段文字的說明更能展現你的風格。包含命名慣例、格式化規則,以及良好輸出的範例。

  5. 測試策略 — 使用哪個框架、測試檔案的位置、覆蓋率期望、哪個測試層級用於哪些關注點。

  6. 邊界 — 三層系統:

    • 始終執行: 在提交前執行測試、遵循命名慣例、驗證輸入
    • 先詢問: 資料庫 Schema 變更、新增依賴項、更改 CI 配置
    • 絕不執行: 提交機密、編輯供應商目錄、未經核准刪除失敗的測試

規格模板:

# 規格:[專案/功能名稱]

## 目標
[我們在建構什麼以及為什麼。使用者故事或驗收標準。]

## 技術棧
[框架、語言、關鍵依賴項與版本]

## 指令
[建構、測試、Lint、開發 — 完整指令]

## 專案結構
[目錄佈局及說明]

## 程式碼風格
[範例片段 + 關鍵慣例]

## 測試策略
[框架、測試位置、覆蓋率要求、測試層級]

## 邊界
- 始終: [...]
- 先詢問: [...]
- 絕不: [...]

## 成功標準
[我們如何知道已完成 — 具體、可測試的條件]

## 開放問題
[任何需要人類輸入的未解決事項]

外部規格工具: 此工作流程與格式無關。如果專案已使用 OpenSpec 或其他規格系統,請保留該系統的成品格式和儲存慣例,而不是建立一個重複的 SPEC.md。此技能擁有釐清、內容和核准關卡的擁有權;外部工具則擁有已核准規格的表達方式的擁有權。

將指示重新表述為成功標準。 當收到模糊的需求時,將其轉化為具體條件:

需求:「讓儀表板更快」

重新表述的成功標準:
- 儀表板 LCP < 2.5 秒(4G 連線)
- 初始資料載入完成時間 < 500 毫秒
- 載入期間無版面位移(CLS < 0.1)
→ 這些是正確的目標嗎?

這讓你可以循環、重試並解決問題,朝著明確的目標前進,而不是猜測「更快」是什麼意思。

在撰寫完規格後停止(至關重要)。 一旦規格儲存完成:

  1. 總結規格並列出任何開放問題。
  2. 請人類核准或要求更改。
  3. 立即停止你的回合。 請勿開始 Phase 2、呼叫 planning-and-task-breakdown,或在該回合中撰寫程式碼。計劃只會在人於後續回合中核准規格後才開始。

Phase 2:計劃

根據已驗證的規格,產生一份技術實作計劃:

  1. 識別主要元件及其依賴關係
  2. 決定實作順序(必須先建構什麼)
  3. 記錄風險與緩解策略
  4. 識別哪些可以並行建構,哪些必須循序漸進
  5. 定義各階段間的驗證檢查點

請遵循 planning-and-task-breakdown 以了解這些步驟背後的依賴關係圖映射和垂直切片機制;它是權威來源。上述項目符號是輕量級摘要;若它們之間有任何分歧,以 planning-and-task-breakdown 為準。

輸出慣例: 將計劃儲存至 tasks/plan.md,並將任務清單記錄在 planning-and-task-breakdown 定義的任務清單目標(預設為 tasks/todo.md;專案可以指定外部追蹤器)。如果 tasks/ 不存在則建立它。下游指令(/build 等)預期使用這些預設值。

計劃應該是可審查的:人類應該能夠閱讀它並說「是的,這是正確的方法」或「不,請更改 X」。

Phase 3:任務

將計劃分解為離散、可實作的任務:

  • 每個任務應可在一個專注的工作階段內完成
  • 每個任務有明確的驗收標準
  • 每個任務包含一個驗證步驟(測試、建構、手動檢查)
  • 任務按依賴關係排序,而非按感知重要性排序
  • 沒有任務需要更改超過約 5 個檔案

請遵循 planning-and-task-breakdown 以了解完整的任務規模和依賴排序機制;它是權威來源。下面的模板是輕量級內聯形式;若它們之間有任何分歧,以 planning-and-task-breakdown 為準。

任務模板:

- [ ] 任務:[描述]
  - 驗收:[完成時必須滿足的條件]
  - 驗證:[如何確認 — 測試指令、建構、手動檢查]
  - 檔案:[將會觸及的檔案]

Phase 4:實作

一次執行一個任務,遵循 skills/incremental-implementation/SKILL.md(incremental-implementation)和 skills/test-driven-development/SKILL.md(test-driven-development)。使用 skills/context-engineering/SKILL.md(context-engineering)在每個步驟載入正確的規格章節和原始碼檔案,而不是用整個規格淹沒代理的上下文。

保持規格活躍

規格是一個活文件,而非一次性產物:

  • 當決策改變時更新 — 如果發現資料模型需要更改,請先更新規格,然後再實作。
  • 當範圍改變時更新 — 新增或刪除的功能應反映在規格中。
  • 提交規格 — 規格應與程式碼一起存在於版本控制中。
  • 在 PR 中引用規格 — 連結回每個 PR 實作的規格章節。

常見的理由

理由現實
「這很簡單,我不需要規格」簡單的任務不需要長規格,但仍需要驗收標準。兩行的規格也可以。
「我寫完程式碼再寫規格」那是文件,不是規格。規格的價值在於在程式碼之前強制釐清。
「規格會拖慢我們」15 分鐘的規格可以防止數小時的返工。15 分鐘的瀑布式開發勝過 15 小時的除錯。
「無論如何需求都會改變」這就是為什麼規格是活文件。過時的規格仍然比沒有規格好。
「使用者知道他們想要什麼」即使明確的請求也有隱含的假設。規格會浮現這些假設。
「這是一個大功能;拆分它是開銷」如果驗收標準聚類成可獨立測試的群組,單一規格會強迫所有下游任務對整個契約進行推理。一個十行的能力地圖是便宜的替代方案。
「我會在計劃期間進行分解」計劃是在規格內切割任務。到那時,過大的產物已經存在 — 模組邊界和依賴方向必須在規格撰寫之前決定,而不是之後。

紅旗

  • 在沒有任何書面需求的情況下開始撰寫程式碼
  • 在釐清「完成」的定義之前,先問「我應該直接開始建構嗎?」
  • 實作任何規格或任務清單中未提及的功能
  • 做出架構決策卻未記錄
  • 因為「要建構什麼很明顯」而跳過規格
  • 在相同回合中撰寫規格並開始計劃或程式碼
  • 一個規格的需求涵蓋多個可獨立測試的能力
  • 在實作期間隱含地決定模組邊界或建構順序,因為沒有預先核准能力地圖

驗證

在繼續進行實作之前,請確認:

  • 規格涵蓋所有六個核心領域
  • 人類已審查並核准規格
  • 在儲存規格後該回合已結束;核准是在後續回合中給出的
  • 成功標準具體且可測試
  • 邊界(始終執行/先詢問/絕不執行)已定義
  • 規格已儲存至儲存庫中的檔案
  • 如果請求包含多個可獨立測試的能力,則能力地圖(模組 ID、依賴方向、建構順序)已在任何模組規格撰寫之前獲得核准
  • 每個模組規格都能追溯到已核准地圖中的一個模組 ID

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

alfathafp/portofolio-web-design

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).

alfathafp/portofolio-web-design

Tests in real browsers via Chrome DevTools MCP. Use when building or debugging anything that runs in a browser. Use when you need to inspect the DOM, capture console errors, analyze network requests, profile performance, or verify visual output with real runtime data. Requires the chrome-devtools MCP server to be configured.

alfathafp/portofolio-web-design

Automates CI/CD pipeline setup. Use when setting up or modifying build and deployment pipelines. Use when you need to automate quality gates, configure test runners in CI, or establish deployment strategies.

alfathafp/portofolio-web-design

Conducts multi-axis code review. Use before merging any change. Use when reviewing code written by yourself, another agent, or a human. Use when you need to assess code quality across multiple dimensions before it enters the main branch. Use when asked to review a diff or a pull request, even when the diff is pasted inline.

alfathafp/portofolio-web-design

Simplifies code for clarity. Use when refactoring code for clarity without changing behavior. Use when code works but is harder to read, maintain, or extend than it should be. Use when reviewing code that has accumulated unnecessary complexity.

alfathafp/portofolio-web-design

Establishes a project's quality bar as a written contract and stops agents quietly lowering it. Interviews the user on which dimensions matter, supplies sane default thresholds when they have no number in mind, records everything in CONSTRAINTS.md, and watches the diff for a weakened bar — new @ts-ignore or eslint-disable suppressions, skipped or deleted tests, assertions stripped out, unimplemented stubs, thresholds edited down. Use when no quality bar is written down, when the user says "set up constraints" or "define our standards", when the user wants dimensions they care about — accessibility, web performance, coverage — set up as enforced constraints, when an agent keeps silencing checks or skipping tests to get to green, when you need a coverage or performance threshold and don't know what number to pick, or when an agent writes more code than anyone will read.

alfathafp/portofolio-web-design

Optimizes agent context setup. Use when starting a new session, when agent output quality degrades, when switching between tasks, or when you need to configure rules files and context for a project.

alfathafp/portofolio-web-design

Guides systematic root-cause debugging. Use when tests fail, builds break, something that worked yesterday broke, behavior doesn't match expectations, or you encounter any unexpected error. Use when you need to figure out what broke and why — a systematic approach to finding and fixing the root cause rather than guessing.

alfathafp/portofolio-web-design

Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment".

alfathafp/portofolio-web-design

Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.

alfathafp/portofolio-web-design

Use when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.

alfathafp/portofolio-web-design

Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies

alfathafp/portofolio-web-design

Records decisions and documentation. Use when you need to document an architecture decision (ADR) or the reasoning behind a design choice, when changing public APIs, shipping features, or when you need to record context that future engineers and agents will need to understand the codebase.

alfathafp/portofolio-web-design

Subjects every non-trivial decision to a fresh-context adversarial review before it stands. Use when you want every assumption cross-examined before proceeding, when stress-testing a plan for hidden failure modes, when correctness matters more than speed, when working in unfamiliar code, when stakes are high (production auth, security-sensitive logic, a high-stakes migration, irreversible operations), or any time a confident output would be cheaper to verify now than to debug later.

alfathafp/portofolio-web-design

Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available

alfathafp/portofolio-web-design

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work

alfathafp/portofolio-web-design

Builds production-quality, accessible, responsive user-facing UIs. Use when building or modifying interfaces and pages, creating components, implementing layouts, meeting WCAG accessibility requirements, managing state, or when the output needs to look and feel production-quality rather than AI-generated.

alfathafp/portofolio-web-design

Structures git workflow practices. Use when making any code change. Use when committing, branching, resolving conflicts, splitting uncommitted work in a messy working tree into clean atomic commits, opening or reviewing a pull request (PR), pushing to a remote, or when you need to organize work across multiple parallel streams. Use when cutting a release, choosing a semantic version bump, tagging, or writing a changelog.

alfathafp/portofolio-web-design

Refines raw ideas into sharp, actionable concepts through structured divergent and convergent thinking. Use when an idea is still vague, when you need to stress-test assumptions before committing to a plan, or when you want to expand options before converging on one. Triggers on "ideate", "refine this idea", or "stress-test my plan".

alfathafp/portofolio-web-design

Guides stable API and interface design. Use when designing APIs, module boundaries, or any public interface. Use when creating REST or GraphQL endpoints, defining type contracts between modules, or establishing boundaries between frontend and backend.

相關技能