From zenbu-powers
前端 Stage 1:從 api.yml + discovery features 產出 Zod Schemas、Fixtures、MSW Handlers、API Client 函式。
npx claudepluginhub zenbuapps/zenbu-powers --plugin zenbu-powersThis skill uses the workspace's default tool permissions.
資料層建構者。從規格產出型別安全的 API 層,讓後續的 Gherkin 測試和元件實作都能直接引用。
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Checks Next.js compilation errors using a running Turbopack dev server after code edits. Fixes actionable issues before reporting complete. Replaces `next build`.
Guides code writing, review, and refactoring with Karpathy-inspired rules to avoid overcomplication, ensure simplicity, surgical changes, and verifiable success criteria.
Share bugs, ideas, or general feedback.
資料層建構者。從規格產出型別安全的 API 層,讓後續的 Gherkin 測試和元件實作都能直接引用。
先詢問:
SPECS_ROOT_DIR(discovery 產出的規格根目錄)PROJECT_ROOT(前端專案根目錄,含 src/)| 來源 | 用途 |
|---|---|
${SPECS_ROOT_DIR}/api/api.yml | schemas → Zod types、endpoints → handlers + client、error codes → 錯誤模擬、enums → 固定資料值 |
${SPECS_ROOT_DIR}/features/**/*.feature | Given 步驟中的具體實體資料 → 寫實的 fixtures(後端 Given 提到的每個值都必須出現在 fixtures) |
以下檔案已存在,本階段只在標記處補充,不重建:
src/lib/api/client.ts — apiClient<T>()(exported)、ApiClientError(exported);ApiResponse<T> / ApiError 為內部 interface,不對外 export,無需引用src/lib/api/index.ts — barrel re-export(在註解處補上新的 re-export)src/lib/types/index.ts — barrel re-export(在註解處補上新的 re-export)src/mocks/browser.ts — setupWorker + initMocks()src/mocks/handlers/index.ts — handler 彙總(在註解處補上新的 handler)src/components/MSWProvider.tsx — Client-side MSW 初始化src/lib/types/{resource}.schema.ts)對 api.yml 中每個 components/schemas:
z.enum(),物件用 z.object())z.infer<> 推導 TypeScript 型別並 exportsrc/lib/types/index.ts 補上 re-exportsrc/mocks/fixtures.ts)@/lib/types import 型別mock{Entity}[] 陣列,使用來自 features 的具體資料(不隨意編造)src/mocks/handlers/{resource}.ts)對 api.yml 中每個端點:
http.{method}() handlerclient.ts 的回應封套格式({ success, data } 或 { success, error })src/mocks/handlers/index.ts 補上新增的 handlersrc/lib/api/{resource}.ts)對 api.yml 中每個端點:
operationId)apiClient<T>() from @/lib/api/clientsrc/lib/api/index.ts 補上 re-exportsrc/
├── lib/
│ ├── types/
│ │ ├── {resource}.schema.ts ← Zod schemas + z.infer 型別
│ │ └── index.ts ← 補上 re-export(已有)
│ └── api/
│ ├── {resource}.ts ← API 客戶端函式
│ └── index.ts ← 補上 re-export(已有)
└── mocks/
├── fixtures.ts ← 型別化的模擬資料(已有空殼)
└── handlers/
├── {resource}.ts ← 按資源分的 handlers
└── index.ts ← 補上 handler 彙總(已有空殼)
${SPECS_ROOT_DIR}/features/ 的具體範例,不得憑空編造api.yml error response 必須在 handler 中有對應分支api.yml 的 path(含 path params)api.yml schemas 均有對應的 Zod schema 檔案api.yml endpoints 均有對應的 handler 和 client 函式fixtures.ts 的資料可追溯至 features/ 的具體 Given 步驟