prototype

作者: mattpocock

建立一個可拋棄的原型,在確定設計前先完善構想。在兩個分支之間切換——一個可執行的終端應用程式,用於測試狀態或商業邏輯問題;或從同一路由切換多種截然不同的UI變體。當使用者想要製作原型、驗證資料模型或狀態機、模擬UI、探索設計選項,或說出「把這個做成原型」、「讓我玩玩看」、「試試幾種設計」時使用。

npx skills add https://github.com/mattpocock/skills --skill prototype

Prototype

A prototype is throwaway code that answers a question. The question decides the shape.

Pick a branch

Identify which question is being answered — from the user's prompt, the surrounding code, or by asking if the user is around:

  • "Does this logic / state model feel right?"LOGIC.md. Build a tiny interactive terminal app that pushes the state machine through cases that are hard to reason about on paper.
  • "What should this look like?"UI.md. Generate several radically different UI variations on a single route, switchable via a URL search param and a floating bottom bar.

The two branches produce very different artifacts — getting this wrong wastes the whole prototype. If the question is genuinely ambiguous and the user isn't reachable, default to whichever branch better matches the surrounding code (a backend module → logic; a page or component → UI) and state the assumption at the top of the prototype.

Rules that apply to both

  1. Throwaway from day one, and clearly marked as such. Locate the prototype code close to where it will actually be used (next to the module or page it's prototyping for) so context is obvious — but name it so a casual reader can see it's a prototype, not production. For throwaway UI routes, obey whatever routing convention the project already uses; don't invent a new top-level structure.
  2. One command to run. Whatever the project's existing task runner supports — pnpm <name>, python <path>, bun <path>, etc. The user must be able to start it without thinking.
  3. No persistence by default. State lives in memory. Persistence is the thing the prototype is checking, not something it should depend on. If the question explicitly involves a database, hit a scratch DB or a local file with a clear "PROTOTYPE — wipe me" name.
  4. Skip the polish. No tests, no error handling beyond what makes the prototype runnable, no abstractions. The point is to learn something fast and then delete it.
  5. Surface the state. After every action (logic) or on every variant switch (UI), print or render the full relevant state so the user can see what changed.
  6. Delete or absorb when done. When the prototype has answered its question, either delete it or fold the validated decision into the real code — don't leave it rotting in the repo.

When done

The answer is the only thing worth keeping from a prototype. Capture it somewhere durable (commit message, ADR, issue, or a NOTES.md next to the prototype) along with the question it was answering. If the user is around, that capture is a quick conversation; if not, leave the placeholder so they (or you, on the next pass) can fill in the verdict before deleting the prototype.

來自 mattpocock 的更多技能

grill-me
mattpocock
持續追問使用者關於某個計畫或設計,直到達成共識,並逐一釐清決策樹的每個分支。適用於使用者想對計畫進行壓力測試、接受設計挑戰,或提到「grill me」時。
researchcommunicationproject-management
grill-with-docs
mattpocock
一場燒烤式討論,挑戰你的計劃與現有領域模型的一致性,精煉術語,並在決策逐漸明朗時即時更新文件(CONTEXT.md、ADRs)。當使用者希望針對專案的語言與已記錄的決策來壓力測試其計劃時使用。
developmentdocumentresearch
improve-codebase-architecture
mattpocock
在程式碼庫中尋找深化機會,依據 CONTEXT.md 中的領域語言與 docs/adr/ 中的決策。適用於使用者想要改善架構、尋找重構機會、整合緊密耦合的模組,或讓程式碼庫更易於測試及便於 AI 導航時使用。
developmentcode-reviewapi
teach
mattpocock
在此工作區內,教導使用者一項新技能或概念。
communicationproductivity
tdd
mattpocock
以紅-綠-重構循環進行測試驅動開發。當使用者想透過TDD建立功能或修復錯誤、提及「紅-綠-重構」、需要整合測試,或要求測試優先開發時使用。
developmenttesting
to-prd
mattpocock
將當前對話內容轉換為PRD,並發佈到專案問題追蹤器中。當使用者希望從當前內容建立PRD時使用。
developmentdocumentproject-management
handoff
mattpocock
將當前對話壓縮成一份交接文件,供其他代理接手處理。
communicationproject-managementdocument
diagnose
mattpocock
針對難以解決的錯誤與效能回歸問題,採用嚴謹的診斷循環流程:重現 → 最小化 → 假設 → 檢測 → 修復 → 回歸測試。當使用者提出「診斷這個」/「除錯這個」、回報錯誤、表示某功能損壞/拋出異常/失敗,或描述效能回歸情況時啟用。
developmenttestingcode-review