xiaohongshu
xiaohongshu
forward-derivation
從已批准的 SDD 規格推演 BDD 場景和 TDD 測試骨架。 ATDD 驗收測試表為可選輸出,用於特殊需求。 使用時機:規格已批准、開始 BDD/TDD 實作、生成測試結構。 關鍵字:forward derivation, spec to test, BDD generation, TDD skeleton, test derivation, 正向推演, 規格轉測試, 測試生成。
Full skill instructions
語言: English | 繁體中文
版本: 2.0.0 最後更新: 2026-01-25 適用範圍: Claude Code Skills
核心規範:此技能實作正向推演標準。任何 AI 工具皆可參考核心規範取得完整方法論文件。
此技能引導您從已批准的 SDD 規格推演 BDD 場景和 TDD 測試骨架,並嚴格遵循反幻覺標準。
注意: ATDD 測試表為可選項,可透過
/derive-atdd取得。BDD 場景本身已作為可執行驗收測試,使 ATDD 表對大多數用例變得多餘。
正向推演是反向工程的對稱對應:
┌─────────────────────────────────────────────────────────────────┐
│ 正向推演工作流程 │
├─────────────────────────────────────────────────────────────────┤
│ │
│ 1️⃣ SPEC 解析(AI 自動化) │
│ ├─ 讀取已批准的規格 │
│ ├─ 提取驗收條件(GWT 或條列式) │
│ └─ 驗證 SPEC 結構和完整性 │
│ │
│ 2️⃣ 推演(AI 自動化) │
│ ├─ AC → BDD Gherkin 場景 │
│ ├─ AC → TDD 測試骨架(帶 TODO) │
│ └─ AC → ATDD 驗收測試表格 │
│ │
│ 3️⃣ 人類審查(必要) │
│ ├─ 驗證生成的場景符合 AC 意圖 │
│ ├─ 填寫 [TODO] 區塊 │
│ └─ 如需要精煉步驟定義 │
│ │
└─────────────────────────────────────────────────────────────────┘
| 命令 | 輸入 | 輸出 | 目的 |
|---|---|---|---|
/derive-bdd | SPEC-XXX.md | .feature | AC → Gherkin 場景 |
/derive-tdd | SPEC-XXX.md | .test.ts | AC → 測試骨架 |
/derive-atdd | SPEC-XXX.md | acceptance.md | AC → 驗收測試表格 |
/derive-all | SPEC-XXX.md | 以上全部 | 完整推演管道 |
關鍵:只推演規格中存在的內容。不添加 AC 未明確定義的場景、測試或功能。
# 反幻覺規則
輸入:SPEC 有 N 個驗收條件
輸出:恰好 N 個場景(BDD)
恰好 N 個測試群組(TDD)
恰好 N 個驗收測試(ATDD)
若任何輸出數量 ≠ 輸入數量 → 違規
每個生成項目必須包含可追溯性:
# Generated from: specs/SPEC-001.md
# AC: AC-1
@SPEC-001 @AC-1
Scenario: 使用者以有效憑證登入
| 標籤 | 使用時機 | 範例 |
|---|---|---|
[來源] | 直接來自 SPEC 的內容 | 功能標題、AC 文字 |
[推演] | 從 SPEC 內容轉換 | 從條列 AC 推演的 GWT |
[生成] | AI 生成的結構 | 測試骨架 |
[TODO] | 需要人類實作 | 斷言、步驟定義 |
輸入:已批准的規格檔案 輸出:結構化的驗收條件列表
動作:
驗證清單:
輸入:已解析的驗收條件 輸出:Gherkin .feature 檔案
轉換規則:
| AC 格式 | 轉換 |
|---|---|
| Given-When-Then | 直接對應到 Gherkin |
| 條列式 | 使用 GWT 模式匹配轉換 |
| 勾選清單 | 條件 → Given、動作 → When、結果 → Then |
輸入:已解析的驗收條件 輸出:測試骨架檔案
參數:
| 參數 | 選項 | 預設值 |
|---|---|---|
--lang | typescript, javascript, python, java, go | typescript |
--framework | vitest, jest, pytest, junit, go-test | vitest |
輸入:已解析的驗收條件 輸出:驗收測試表格文件
輸入:生成的檔案 輸出:審查和精煉的檔案
審查清單:
# Generated from: specs/SPEC-001.md
# Generator: /derive-bdd v1.0.0
# Generated at: 2026-01-19T10:00:00Z
@SPEC-001
Feature: 使用者認證
[來源] 來自 SPEC-001 摘要
@AC-1 @happy-path
Scenario: 使用者以有效憑證登入
# [來源] 來自 SPEC-001 AC-1
Given 已註冊的使用者有有效憑證
When 使用者提交登入表單
Then 使用者被導向儀表板
@AC-2 @error-handling
Scenario: 無效憑證登入失敗
# [來源] 來自 SPEC-001 AC-2
Given 使用者有無效憑證
When 使用者提交登入表單
Then 顯示錯誤訊息
/**
* Tests for SPEC-001: 使用者認證
* Generated from: specs/SPEC-001.md
* Generated at: 2026-01-19T10:00:00Z
* AC Coverage: AC-1, AC-2
*/
describe('SPEC-001: 使用者認證', () => {
describe('AC-1: 使用者以有效憑證登入', () => {
it('should redirect to dashboard on successful login', async () => {
// Arrange
// [TODO] 設定已註冊使用者和有效憑證
// Act
// [TODO] 提交登入表單
// Assert
// [TODO] 驗證導向儀表板
expect(true).toBe(true); // Placeholder
});
});
});
# SPEC-001 驗收測試
**規格**: SPEC-001
**生成時間**: 2026-01-19
**狀態**: 待審查
## AT-001: 使用者以有效憑證登入
**來源**: AC-1
| 步驟 | 動作 | 預期結果 | 通過/失敗 |
|------|------|----------|-----------|
| 1 | 導航到登入頁面 | 顯示登入表單 | [ ] |
| 2 | 輸入有效憑證 | 欄位接受輸入 | [ ] |
| 3 | 點擊登入 | 表單已提交 | [ ] |
| 4 | 驗證導向 | 顯示儀表板 | [ ] |
**測試人員**: _______________
**日期**: _______________
**結果**: [ ] 通過 / [ ] 失敗
/spec 工作流程完成 SPEC/derive-all 生成測試結構/derive-bdd 生成 BDD 場景/bdd 繼續 BDD 制定/derive-tdd 生成 TDD 骨架正向推演適合整合流程方法論:
spec-review (已批准) → forward-derivation → discovery (BDD)
│
├─→ .feature 檔案供 BDD
├─→ .test.ts 骨架供 TDD
└─→ acceptance.md 供 ATDD
┌─────────────────────────────────────────────────────────────────────────┐
│ 完整正向推演管道 │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ 已批准 SPEC │
│ │ │
│ ▼ │
│ /derive-all specs/SPEC-XXX.md │
│ │ │
│ ├─→ /derive-bdd │
│ │ └─→ features/SPEC-XXX.feature │
│ │ │
│ ├─→ /derive-tdd │
│ │ └─→ tests/SPEC-XXX.test.ts │
│ │ │
│ └─→ /derive-atdd │
│ └─→ acceptance/SPEC-XXX-acceptance.md │
│ │
│ 人類審查 │
│ │ │
│ ├─→ 驗證 1:1 AC 對應 │
│ ├─→ 填寫 [TODO] 區塊 │
│ └─→ 精煉步驟定義 │
│ │
└─────────────────────────────────────────────────────────────────────────┘
# 生成 BDD 場景
/derive-bdd specs/SPEC-001.md
# 使用 Python/pytest 生成 TDD 骨架
/derive-tdd specs/SPEC-001.md --lang python --framework pytest
# 生成所有測試結構
/derive-all specs/SPEC-001.md
# 預覽不建立檔案
/derive-all specs/SPEC-001.md --dry-run
# 指定輸出目錄
/derive-all specs/SPEC-001.md --output-dir ./generated
添加額外場景
從草稿 SPEC 推演
/derive-all跳過來源標註
過度指定技術細節
Given 使用 PostgreSQL 驅動程式建立資料庫連線Given 系統中存在使用者資料將骨架視為完整
此技能會自動偵測專案設定:
specs/ 目錄結構| 版本 | 日期 | 變更 |
|---|---|---|
| 2.0.0 | 2026-01-25 | ATDD 從必需改為可選輸出;/derive-all 現在只輸出 BDD + TDD |
| 1.1.0 | 2026-01-25 | 新增:統一標籤系統參考 |
| 1.0.0 | 2026-01-19 | 初始發布 |
此技能採用 CC BY 4.0 授權。
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience