universal-dev-standards 5.3.2 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundled/ai/standards/adversarial-test.ai.yaml +277 -0
- package/bundled/ai/standards/agent-communication-protocol.ai.yaml +32 -166
- package/bundled/ai/standards/agent-dispatch.ai.yaml +32 -58
- package/bundled/ai/standards/audit-trail.ai.yaml +113 -0
- package/bundled/ai/standards/branch-completion.ai.yaml +34 -70
- package/bundled/ai/standards/change-batching-standards.ai.yaml +31 -180
- package/bundled/ai/standards/chaos-injection-tests.ai.yaml +91 -0
- package/bundled/ai/standards/container-image-standards.ai.yaml +88 -0
- package/bundled/ai/standards/container-security.ai.yaml +331 -0
- package/bundled/ai/standards/cost-budget-test.ai.yaml +96 -0
- package/bundled/ai/standards/data-contract.ai.yaml +110 -0
- package/bundled/ai/standards/data-migration-testing.ai.yaml +96 -0
- package/bundled/ai/standards/data-pipeline.ai.yaml +113 -0
- package/bundled/ai/standards/disaster-recovery-drill.ai.yaml +89 -0
- package/bundled/ai/standards/execution-history.ai.yaml +30 -288
- package/bundled/ai/standards/flaky-test-management.ai.yaml +89 -0
- package/bundled/ai/standards/flow-based-testing.ai.yaml +240 -0
- package/bundled/ai/standards/iac-design-principles.ai.yaml +83 -0
- package/bundled/ai/standards/incident-response.ai.yaml +107 -0
- package/bundled/ai/standards/license-compliance.ai.yaml +106 -0
- package/bundled/ai/standards/llm-output-validation.ai.yaml +269 -0
- package/bundled/ai/standards/mock-boundary.ai.yaml +250 -0
- package/bundled/ai/standards/mutation-testing.ai.yaml +192 -0
- package/bundled/ai/standards/pii-classification.ai.yaml +109 -0
- package/bundled/ai/standards/pipeline-integration-standards.ai.yaml +28 -169
- package/bundled/ai/standards/policy-as-code-testing.ai.yaml +227 -0
- package/bundled/ai/standards/prd-standards.ai.yaml +88 -0
- package/bundled/ai/standards/product-metrics-standards.ai.yaml +111 -0
- package/bundled/ai/standards/prompt-regression.ai.yaml +94 -0
- package/bundled/ai/standards/property-based-testing.ai.yaml +105 -0
- package/bundled/ai/standards/release-quality-manifest.ai.yaml +135 -0
- package/bundled/ai/standards/replay-test.ai.yaml +111 -0
- package/bundled/ai/standards/runbook.ai.yaml +104 -0
- package/bundled/ai/standards/sast-advanced.ai.yaml +135 -0
- package/bundled/ai/standards/schema-evolution.ai.yaml +111 -0
- package/bundled/ai/standards/secret-management-standards.ai.yaml +105 -0
- package/bundled/ai/standards/secure-op.ai.yaml +365 -0
- package/bundled/ai/standards/security-testing.ai.yaml +171 -0
- package/bundled/ai/standards/server-ops-security.ai.yaml +274 -0
- package/bundled/ai/standards/slo-sli.ai.yaml +97 -0
- package/bundled/ai/standards/smoke-test.ai.yaml +87 -0
- package/bundled/ai/standards/supply-chain-attestation.ai.yaml +109 -0
- package/bundled/ai/standards/test-completeness-dimensions.ai.yaml +52 -5
- package/bundled/ai/standards/user-story-mapping.ai.yaml +108 -0
- package/bundled/ai/standards/workflow-enforcement.ai.yaml +34 -240
- package/bundled/ai/standards/workflow-state-protocol.ai.yaml +31 -107
- package/bundled/core/adversarial-test.md +212 -0
- package/bundled/core/chaos-injection-tests.md +116 -0
- package/bundled/core/container-security.md +521 -0
- package/bundled/core/cost-budget-test.md +69 -0
- package/bundled/core/data-migration-testing.md +110 -0
- package/bundled/core/disaster-recovery-drill.md +73 -0
- package/bundled/core/flaky-test-management.md +73 -0
- package/bundled/core/flow-based-testing.md +142 -0
- package/bundled/core/llm-output-validation.md +178 -0
- package/bundled/core/mock-boundary.md +100 -0
- package/bundled/core/mutation-testing.md +97 -0
- package/bundled/core/policy-as-code-testing.md +188 -0
- package/bundled/core/prompt-regression.md +72 -0
- package/bundled/core/property-based-testing.md +73 -0
- package/bundled/core/release-quality-manifest.md +147 -0
- package/bundled/core/replay-test.md +86 -0
- package/bundled/core/sast-advanced.md +300 -0
- package/bundled/core/secure-op.md +314 -0
- package/bundled/core/security-testing.md +87 -0
- package/bundled/core/server-ops-security.md +493 -0
- package/bundled/core/smoke-test.md +65 -0
- package/bundled/core/supply-chain-attestation.md +117 -0
- package/bundled/locales/zh-CN/CHANGELOG.md +3 -3
- package/bundled/locales/zh-CN/README.md +1 -1
- package/bundled/locales/zh-CN/skills/ai-instruction-standards/SKILL.md +5 -5
- package/bundled/locales/zh-TW/CHANGELOG.md +3 -3
- package/bundled/locales/zh-TW/README.md +1 -1
- package/bundled/locales/zh-TW/skills/ai-instruction-standards/SKILL.md +183 -79
- package/bundled/skills/README.md +4 -3
- package/bundled/skills/SKILL_NAMING.md +94 -0
- package/bundled/skills/ai-instruction-standards/SKILL.md +181 -88
- package/bundled/skills/atdd-assistant/SKILL.md +8 -0
- package/bundled/skills/bdd-assistant/SKILL.md +7 -0
- package/bundled/skills/checkin-assistant/SKILL.md +8 -0
- package/bundled/skills/code-review-assistant/SKILL.md +7 -0
- package/bundled/skills/journey-test-assistant/SKILL.md +203 -0
- package/bundled/skills/orchestrate/SKILL.md +167 -0
- package/bundled/skills/plan/SKILL.md +234 -0
- package/bundled/skills/pr-automation-assistant/SKILL.md +8 -0
- package/bundled/skills/push/SKILL.md +49 -2
- package/bundled/skills/{process-automation → skill-builder}/SKILL.md +1 -1
- package/bundled/skills/{forward-derivation → spec-derivation}/SKILL.md +1 -1
- package/bundled/skills/spec-driven-dev/SKILL.md +7 -0
- package/bundled/skills/sweep/SKILL.md +145 -0
- package/bundled/skills/tdd-assistant/SKILL.md +7 -0
- package/package.json +1 -1
- package/src/commands/flow.js +8 -0
- package/src/commands/start.js +14 -0
- package/src/commands/sweep.js +8 -0
- package/src/commands/workflow.js +8 -0
- package/standards-registry.json +474 -12
- package/bundled/locales/zh-CN/skills/ac-coverage-assistant/SKILL.md +0 -190
- package/bundled/locales/zh-CN/skills/forward-derivation/SKILL.md +0 -71
- package/bundled/locales/zh-CN/skills/forward-derivation/guide.md +0 -130
- package/bundled/locales/zh-CN/skills/methodology-system/SKILL.md +0 -88
- package/bundled/locales/zh-CN/skills/methodology-system/create-methodology.md +0 -350
- package/bundled/locales/zh-CN/skills/methodology-system/guide.md +0 -131
- package/bundled/locales/zh-CN/skills/methodology-system/runtime.md +0 -279
- package/bundled/locales/zh-CN/skills/process-automation/SKILL.md +0 -143
- package/bundled/locales/zh-TW/skills/ac-coverage-assistant/SKILL.md +0 -195
- package/bundled/locales/zh-TW/skills/deploy-assistant/SKILL.md +0 -178
- package/bundled/locales/zh-TW/skills/forward-derivation/SKILL.md +0 -69
- package/bundled/locales/zh-TW/skills/forward-derivation/guide.md +0 -415
- package/bundled/locales/zh-TW/skills/methodology-system/SKILL.md +0 -86
- package/bundled/locales/zh-TW/skills/methodology-system/create-methodology.md +0 -350
- package/bundled/locales/zh-TW/skills/methodology-system/guide.md +0 -131
- package/bundled/locales/zh-TW/skills/methodology-system/runtime.md +0 -279
- package/bundled/locales/zh-TW/skills/process-automation/SKILL.md +0 -144
- /package/bundled/skills/{ac-coverage-assistant → ac-coverage}/SKILL.md +0 -0
- /package/bundled/skills/{methodology-system → dev-methodology}/SKILL.md +0 -0
- /package/bundled/skills/{methodology-system → dev-methodology}/create-methodology.md +0 -0
- /package/bundled/skills/{methodology-system → dev-methodology}/guide.md +0 -0
- /package/bundled/skills/{methodology-system → dev-methodology}/integrated-flow.md +0 -0
- /package/bundled/skills/{methodology-system → dev-methodology}/prerequisite-check.md +0 -0
- /package/bundled/skills/{methodology-system → dev-methodology}/runtime.md +0 -0
- /package/bundled/skills/{forward-derivation → spec-derivation}/guide.md +0 -0
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: deploy
|
|
3
|
-
source: ../../../../skills/deploy-assistant/SKILL.md
|
|
4
|
-
source_version: 1.0.0
|
|
5
|
-
translation_version: 1.0.0
|
|
6
|
-
last_synced: 2026-04-26
|
|
7
|
-
status: current
|
|
8
|
-
description: "[UDS] 引導無 CI/CD 平台下的可靠部署 — 生成 deploy.sh、verify.sh、rollback.sh、Makefile"
|
|
9
|
-
allowed-tools: Read, Bash(cat VERSION:*), Bash(git describe:*), Bash(which nginx:*), Bash(which rsync:*)
|
|
10
|
-
argument-hint: "[project type | 專案類型: node/python/docker/go]"
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
# 無 CI/CD 部署助手
|
|
14
|
-
|
|
15
|
-
> **語言**: [English](../../../../skills/deploy-assistant/SKILL.md) | 繁體中文
|
|
16
|
-
|
|
17
|
-
在沒有 GitHub Actions 或 GitLab CI 的環境中,引導建立可靠的部署腳本組。採用三層架構:防錯、驗證、回復。
|
|
18
|
-
|
|
19
|
-
## 三層部署架構
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
Layer 1: 防止錯誤部署
|
|
23
|
-
└─ set -euo pipefail + 版本 tag 強制 + deploy.lock
|
|
24
|
-
|
|
25
|
-
Layer 2: 驗證部署正確
|
|
26
|
-
└─ Smoke Test + /health 端點 + 版本號比對 + 自動 rollback
|
|
27
|
-
|
|
28
|
-
Layer 3: 快速回復能力
|
|
29
|
-
└─ Blue-Green 切換(Nginx)+ rollback.sh(< 30 秒)
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## 引導式問答
|
|
33
|
-
|
|
34
|
-
Skill 啟動後,AI 助手應詢問:
|
|
35
|
-
|
|
36
|
-
| 問題 | 選項 | 影響 |
|
|
37
|
-
|------|------|------|
|
|
38
|
-
| 專案類型 | node / python / go / docker | 建置命令 |
|
|
39
|
-
| 部署目標 | SSH+rsync / Docker Compose | 傳輸方式 |
|
|
40
|
-
| 是否支援 Blue-Green | yes / no | 生成 rollback.sh |
|
|
41
|
-
| 健康檢查 URL | 輸入 URL | verify.sh 目標 |
|
|
42
|
-
| 版本來源 | VERSION 檔案 / package.json / git tag | 版本比對邏輯 |
|
|
43
|
-
|
|
44
|
-
## 生成的腳本組
|
|
45
|
-
|
|
46
|
-
### deploy.sh(主部署腳本)
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
#!/usr/bin/env bash
|
|
50
|
-
set -euo pipefail
|
|
51
|
-
|
|
52
|
-
LOCK_FILE="/tmp/deploy.lock"
|
|
53
|
-
trap "rm -f $LOCK_FILE" EXIT
|
|
54
|
-
|
|
55
|
-
# 防並發
|
|
56
|
-
if [ -f "$LOCK_FILE" ]; then
|
|
57
|
-
echo "❌ 部署進行中(PID: $(cat $LOCK_FILE))"
|
|
58
|
-
exit 1
|
|
59
|
-
fi
|
|
60
|
-
echo $$ > "$LOCK_FILE"
|
|
61
|
-
|
|
62
|
-
# 版本 tag 強制
|
|
63
|
-
CURRENT_TAG=$(git describe --exact-match --tags HEAD 2>/dev/null || echo "")
|
|
64
|
-
if [ -z "$CURRENT_TAG" ]; then
|
|
65
|
-
echo "❌ 請先建立版本 tag:git tag vX.Y.Z && git push --tags"
|
|
66
|
-
exit 1
|
|
67
|
-
fi
|
|
68
|
-
|
|
69
|
-
echo "[1/4] 執行測試..."
|
|
70
|
-
# {TEST_COMMAND}
|
|
71
|
-
|
|
72
|
-
echo "[2/4] 建置產物..."
|
|
73
|
-
# {BUILD_COMMAND}
|
|
74
|
-
|
|
75
|
-
echo "[3/4] 推送到伺服器..."
|
|
76
|
-
rsync -avz --delete ./dist/ {USER}@{SERVER}:/app/
|
|
77
|
-
|
|
78
|
-
echo "[4/4] 驗證部署..."
|
|
79
|
-
./verify.sh || { echo "驗證失敗,執行 rollback..."; ./rollback.sh; exit 1; }
|
|
80
|
-
|
|
81
|
-
echo "{\"timestamp\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",\"version\":\"$CURRENT_TAG\",\"operator\":\"$(whoami)\",\"result\":\"success\"}" >> /var/log/deployments.jsonl
|
|
82
|
-
echo "✅ 部署成功:$CURRENT_TAG"
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### verify.sh(Smoke Test)
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
#!/usr/bin/env bash
|
|
89
|
-
set -euo pipefail
|
|
90
|
-
|
|
91
|
-
HEALTH_URL="${HEALTH_URL:-{HEALTH_URL}}"
|
|
92
|
-
EXPECTED_VERSION=$(cat VERSION)
|
|
93
|
-
|
|
94
|
-
for i in $(seq 1 3); do
|
|
95
|
-
RESPONSE=$(curl -sf --max-time 10 "$HEALTH_URL" 2>/dev/null) && break
|
|
96
|
-
echo "健康檢查嘗試 $i/3 失敗,等待 5s..."
|
|
97
|
-
sleep 5
|
|
98
|
-
done
|
|
99
|
-
|
|
100
|
-
ACTUAL_VERSION=$(echo "$RESPONSE" | python3 -c "import json,sys; print(json.load(sys.stdin)['version'])")
|
|
101
|
-
|
|
102
|
-
if [ "$ACTUAL_VERSION" != "$EXPECTED_VERSION" ]; then
|
|
103
|
-
echo "❌ 版本不符!預期 $EXPECTED_VERSION,實際 $ACTUAL_VERSION"
|
|
104
|
-
exit 1
|
|
105
|
-
fi
|
|
106
|
-
|
|
107
|
-
echo "✅ 版本驗證通過:$ACTUAL_VERSION"
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
### rollback.sh(Blue-Green 回滾)
|
|
111
|
-
|
|
112
|
-
```bash
|
|
113
|
-
#!/usr/bin/env bash
|
|
114
|
-
set -euo pipefail
|
|
115
|
-
|
|
116
|
-
CURRENT=$(readlink /app/current 2>/dev/null || echo "/app/blue")
|
|
117
|
-
TARGET=$([[ "$CURRENT" == *"green"* ]] && echo "/app/blue" || echo "/app/green")
|
|
118
|
-
|
|
119
|
-
ln -sfn "$TARGET" /app/current
|
|
120
|
-
nginx -s reload
|
|
121
|
-
|
|
122
|
-
echo "✅ 已切回 $TARGET($(date -u +%Y-%m-%dT%H:%M:%SZ))"
|
|
123
|
-
echo "{\"timestamp\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",\"event\":\"rollback\",\"from\":\"$CURRENT\",\"to\":\"$TARGET\",\"operator\":\"$(whoami)\"}" >> /var/log/deployments.jsonl
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### Makefile
|
|
127
|
-
|
|
128
|
-
```makefile
|
|
129
|
-
.PHONY: deploy rollback verify status
|
|
130
|
-
|
|
131
|
-
deploy:
|
|
132
|
-
@./deploy.sh
|
|
133
|
-
|
|
134
|
-
rollback:
|
|
135
|
-
@./rollback.sh
|
|
136
|
-
|
|
137
|
-
verify:
|
|
138
|
-
@./verify.sh
|
|
139
|
-
|
|
140
|
-
status:
|
|
141
|
-
@echo "Current slot: $$(readlink /app/current 2>/dev/null || echo 'N/A')"
|
|
142
|
-
@curl -s $${HEALTH_URL:-http://localhost/health} | python3 -m json.tool 2>/dev/null || echo "Health check failed"
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
## 使用方式
|
|
146
|
-
|
|
147
|
-
```bash
|
|
148
|
-
/deploy # 互動式引導,自動偵測專案類型
|
|
149
|
-
/deploy node # 指定 Node.js 專案直接生成
|
|
150
|
-
/deploy docker # Docker Compose 部署模式
|
|
151
|
-
/deploy --verify-only # 只生成 verify.sh
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
## 輸出確認清單
|
|
155
|
-
|
|
156
|
-
生成後,AI 助手必須確認:
|
|
157
|
-
|
|
158
|
-
- [ ] `deploy.sh` 包含 `set -euo pipefail`
|
|
159
|
-
- [ ] `deploy.sh` 包含 deploy.lock 防並發邏輯
|
|
160
|
-
- [ ] `verify.sh` 比對版本號(不只檢查 HTTP 200)
|
|
161
|
-
- [ ] `rollback.sh` 在驗證失敗時自動觸發
|
|
162
|
-
- [ ] `Makefile` 提供 `make deploy / make rollback / make status`
|
|
163
|
-
|
|
164
|
-
## 下一步引導
|
|
165
|
-
|
|
166
|
-
`/deploy` 完成後,AI 助手應建議:
|
|
167
|
-
|
|
168
|
-
> **部署腳本已生成。建議下一步:**
|
|
169
|
-
> - `chmod +x deploy.sh verify.sh rollback.sh` — 設定執行權限
|
|
170
|
-
> - `make verify` — 測試健康檢查設定
|
|
171
|
-
> - `git tag v1.0.0 && git push --tags` — 建立版本 tag
|
|
172
|
-
> - `make deploy` — 執行第一次部署
|
|
173
|
-
|
|
174
|
-
## 參考
|
|
175
|
-
|
|
176
|
-
- 核心標準:[no-cicd-deployment.md](../../../../core/no-cicd-deployment.md)
|
|
177
|
-
- 核心標準:[deployment-standards.md](../../../../core/deployment-standards.md)
|
|
178
|
-
- 相關 Skill:[ci-cd-assistant](../../skills/ci-cd-assistant/SKILL.md) — 有 CI/CD 平台的場景
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: forward-derivation
|
|
3
|
-
source: ../../../../skills/forward-derivation/SKILL.md
|
|
4
|
-
source_version: 2.0.0
|
|
5
|
-
translation_version: 2.0.0
|
|
6
|
-
last_synced: 2026-02-10
|
|
7
|
-
status: current
|
|
8
|
-
description: "[UDS] 從已批准的 SDD 規格生成衍生工件(BDD/TDD/ATDD)"
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
# 正向推演
|
|
12
|
-
|
|
13
|
-
> **語言**: [English](../../../../skills/forward-derivation/SKILL.md) | 繁體中文
|
|
14
|
-
|
|
15
|
-
從已批准的 SDD 規格生成衍生工件(BDD 場景、TDD 骨架、ATDD 表格)。
|
|
16
|
-
|
|
17
|
-
## 子命令
|
|
18
|
-
|
|
19
|
-
| 子命令 | 說明 | 輸出 | Output |
|
|
20
|
-
|--------|------|------|--------|
|
|
21
|
-
| `all` | 生成 BDD + TDD(預設) | `.feature` + `.test.*` | `.feature` + `.test.*` |
|
|
22
|
-
| `bdd` | 僅生成 BDD 場景 | `.feature` | `.feature` |
|
|
23
|
-
| `tdd` | 僅生成 TDD 骨架 | `.test.*` | `.test.*` |
|
|
24
|
-
| `atdd` | 生成 ATDD 測試表格 | `.md`(Markdown 表格) | `.md` (Markdown tables) |
|
|
25
|
-
|
|
26
|
-
## 工作流程
|
|
27
|
-
|
|
28
|
-
1. **讀取規格** - 分析輸入的 `SPEC-XXX.md` 檔案
|
|
29
|
-
2. **擷取 AC** - 解析所有驗收條件
|
|
30
|
-
3. **生成工件** - 建立 BDD/TDD/ATDD 輸出
|
|
31
|
-
4. **驗證** - 確保 AC 與生成項目之間的 1:1 對應
|
|
32
|
-
|
|
33
|
-
## 防幻覺規則
|
|
34
|
-
|
|
35
|
-
| 規則 | 說明 | Rule | Description |
|
|
36
|
-
|------|------|------|-------------|
|
|
37
|
-
| **1:1 對應** | 每個 AC 對應一個測試/場景 | 1:1 Mapping | Every AC has exactly one test/scenario |
|
|
38
|
-
| **可追溯性** | 所有工件引用規格與 AC 編號 | Traceability | All artifacts reference Spec ID and AC ID |
|
|
39
|
-
| **禁止捏造** | 不新增規格外的場景 | No Invention | Do not add scenarios not in the spec |
|
|
40
|
-
|
|
41
|
-
## 產生工件標籤
|
|
42
|
-
|
|
43
|
-
| 標籤 | 含義 | Tag | Meaning |
|
|
44
|
-
|------|------|-----|---------|
|
|
45
|
-
| `[Source]` | 直接來自規格 | Source | Direct content from spec |
|
|
46
|
-
| `[Derived]` | 從來源轉換 | Derived | Transformed from source |
|
|
47
|
-
| `[Generated]` | AI 產生的結構 | Generated | AI-generated structure |
|
|
48
|
-
| `[TODO]` | 需人工實作 | TODO | Requires human implementation |
|
|
49
|
-
|
|
50
|
-
## 使用方式
|
|
51
|
-
|
|
52
|
-
- `/derive all specs/SPEC-001.md` - 推演 BDD + TDD
|
|
53
|
-
- `/derive bdd specs/SPEC-001.md` - 僅推演 BDD 場景
|
|
54
|
-
- `/derive tdd specs/SPEC-001.md` - 僅推演 TDD 骨架
|
|
55
|
-
- `/derive atdd specs/SPEC-001.md` - 推演 ATDD 表格
|
|
56
|
-
|
|
57
|
-
## 下一步引導
|
|
58
|
-
|
|
59
|
-
`/derive` 完成後,AI 助手應建議:
|
|
60
|
-
|
|
61
|
-
> **測試工件已產生。建議下一步:**
|
|
62
|
-
> - 執行 `/tdd` 開始紅綠重構循環
|
|
63
|
-
> - 執行 `/bdd` 細化 Gherkin 場景
|
|
64
|
-
> - 檢查產生的 `[TODO]` 標記並補齊實作
|
|
65
|
-
|
|
66
|
-
## 參考
|
|
67
|
-
|
|
68
|
-
- 詳細指南:[guide.md](./guide.md)
|
|
69
|
-
- 核心規範:[forward-derivation-standards.md](../../../../core/forward-derivation-standards.md)
|
|
@@ -1,415 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
scope: partial
|
|
3
|
-
description: |
|
|
4
|
-
從已批准的 SDD 規格推演 BDD 場景和 TDD 測試骨架。
|
|
5
|
-
ATDD 驗收測試表為可選輸出,用於特殊需求。
|
|
6
|
-
使用時機:規格已批准、開始 BDD/TDD 實作、生成測試結構。
|
|
7
|
-
關鍵字:forward derivation, spec to test, BDD generation, TDD skeleton, test derivation, 正向推演, 規格轉測試, 測試生成。
|
|
8
|
-
source: ../../../../skills/forward-derivation/SKILL.md
|
|
9
|
-
source_version: 2.0.0
|
|
10
|
-
translation_version: 2.0.0
|
|
11
|
-
last_synced: 2026-01-25
|
|
12
|
-
status: current
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
# 正向推演指南
|
|
16
|
-
|
|
17
|
-
> **語言**: [English](../../../../skills/forward-derivation/SKILL.md) | 繁體中文
|
|
18
|
-
|
|
19
|
-
**版本**: 2.0.0
|
|
20
|
-
**最後更新**: 2026-01-25
|
|
21
|
-
**適用範圍**: Claude Code Skills
|
|
22
|
-
|
|
23
|
-
> **核心規範**:此技能實作[正向推演標準](../../core/forward-derivation-standards.md)。任何 AI 工具皆可參考核心規範取得完整方法論文件。
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
## 目的
|
|
28
|
-
|
|
29
|
-
此技能引導您從已批准的 SDD 規格推演 BDD 場景和 TDD 測試骨架,並嚴格遵循反幻覺標準。
|
|
30
|
-
|
|
31
|
-
> **注意**: ATDD 測試表為可選項,可透過 `/derive-atdd` 取得。BDD 場景本身已作為可執行驗收測試,使 ATDD 表對大多數用例變得多餘。
|
|
32
|
-
|
|
33
|
-
正向推演是[反向工程](../reverse-engineer/SKILL.md)的對稱對應:
|
|
34
|
-
- **反向工程**:程式碼 → 規格
|
|
35
|
-
- **正向推演**:規格 → 測試
|
|
36
|
-
|
|
37
|
-
## 快速參考
|
|
38
|
-
|
|
39
|
-
### 正向推演工作流程
|
|
40
|
-
|
|
41
|
-
```
|
|
42
|
-
┌─────────────────────────────────────────────────────────────────┐
|
|
43
|
-
│ 正向推演工作流程 │
|
|
44
|
-
├─────────────────────────────────────────────────────────────────┤
|
|
45
|
-
│ │
|
|
46
|
-
│ 1️⃣ SPEC 解析(AI 自動化) │
|
|
47
|
-
│ ├─ 讀取已批准的規格 │
|
|
48
|
-
│ ├─ 提取驗收條件(GWT 或條列式) │
|
|
49
|
-
│ └─ 驗證 SPEC 結構和完整性 │
|
|
50
|
-
│ │
|
|
51
|
-
│ 2️⃣ 推演(AI 自動化) │
|
|
52
|
-
│ ├─ AC → BDD Gherkin 場景 │
|
|
53
|
-
│ ├─ AC → TDD 測試骨架(帶 TODO) │
|
|
54
|
-
│ └─ AC → ATDD 驗收測試表格 │
|
|
55
|
-
│ │
|
|
56
|
-
│ 3️⃣ 人類審查(必要) │
|
|
57
|
-
│ ├─ 驗證生成的場景符合 AC 意圖 │
|
|
58
|
-
│ ├─ 填寫 [TODO] 區塊 │
|
|
59
|
-
│ └─ 如需要精煉步驟定義 │
|
|
60
|
-
│ │
|
|
61
|
-
└─────────────────────────────────────────────────────────────────┘
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### 命令概覽
|
|
65
|
-
|
|
66
|
-
| 命令 | 輸入 | 輸出 | 目的 |
|
|
67
|
-
|------|------|------|------|
|
|
68
|
-
| `/derive-bdd` | SPEC-XXX.md | .feature | AC → Gherkin 場景 |
|
|
69
|
-
| `/derive-tdd` | SPEC-XXX.md | .test.ts | AC → 測試骨架 |
|
|
70
|
-
| `/derive-atdd` | SPEC-XXX.md | acceptance.md | AC → 驗收測試表格 |
|
|
71
|
-
| `/derive-all` | SPEC-XXX.md | 以上全部 | 完整推演管道 |
|
|
72
|
-
|
|
73
|
-
## 核心原則
|
|
74
|
-
|
|
75
|
-
### 1. 規格限定生成
|
|
76
|
-
|
|
77
|
-
**關鍵**:只推演規格中存在的內容。不添加 AC 未明確定義的場景、測試或功能。
|
|
78
|
-
|
|
79
|
-
```
|
|
80
|
-
# 反幻覺規則
|
|
81
|
-
輸入:SPEC 有 N 個驗收條件
|
|
82
|
-
輸出:恰好 N 個場景(BDD)
|
|
83
|
-
恰好 N 個測試群組(TDD)
|
|
84
|
-
恰好 N 個驗收測試(ATDD)
|
|
85
|
-
|
|
86
|
-
若任何輸出數量 ≠ 輸入數量 → 違規
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### 2. 來源標註
|
|
90
|
-
|
|
91
|
-
每個生成項目必須包含可追溯性:
|
|
92
|
-
|
|
93
|
-
```gherkin
|
|
94
|
-
# Generated from: specs/SPEC-001.md
|
|
95
|
-
# AC: AC-1
|
|
96
|
-
|
|
97
|
-
@SPEC-001 @AC-1
|
|
98
|
-
Scenario: 使用者以有效憑證登入
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
### 3. 確定性標籤
|
|
102
|
-
|
|
103
|
-
| 標籤 | 使用時機 | 範例 |
|
|
104
|
-
|------|----------|------|
|
|
105
|
-
| `[來源]` | 直接來自 SPEC 的內容 | 功能標題、AC 文字 |
|
|
106
|
-
| `[推演]` | 從 SPEC 內容轉換 | 從條列 AC 推演的 GWT |
|
|
107
|
-
| `[生成]` | AI 生成的結構 | 測試骨架 |
|
|
108
|
-
| `[TODO]` | 需要人類實作 | 斷言、步驟定義 |
|
|
109
|
-
|
|
110
|
-
## 工作流程階段
|
|
111
|
-
|
|
112
|
-
### 階段 1:SPEC 解析
|
|
113
|
-
|
|
114
|
-
**輸入**:已批准的規格檔案
|
|
115
|
-
**輸出**:結構化的驗收條件列表
|
|
116
|
-
|
|
117
|
-
**動作**:
|
|
118
|
-
1. 讀取規格檔案
|
|
119
|
-
2. 識別驗收條件區塊
|
|
120
|
-
3. 解析 AC 格式(Given-When-Then 或條列式)
|
|
121
|
-
4. 驗證 AC 完整性
|
|
122
|
-
|
|
123
|
-
**驗證清單**:
|
|
124
|
-
- [ ] SPEC 狀態為「已批准」或「就緒」
|
|
125
|
-
- [ ] 驗收條件區塊存在
|
|
126
|
-
- [ ] 每個 AC 有唯一識別碼(AC-1、AC-2 等)
|
|
127
|
-
- [ ] AC 格式可解析(GWT 或條列式)
|
|
128
|
-
|
|
129
|
-
### 階段 2:BDD 推演
|
|
130
|
-
|
|
131
|
-
**輸入**:已解析的驗收條件
|
|
132
|
-
**輸出**:Gherkin .feature 檔案
|
|
133
|
-
|
|
134
|
-
**轉換規則**:
|
|
135
|
-
|
|
136
|
-
| AC 格式 | 轉換 |
|
|
137
|
-
|---------|------|
|
|
138
|
-
| Given-When-Then | 直接對應到 Gherkin |
|
|
139
|
-
| 條列式 | 使用 GWT 模式匹配轉換 |
|
|
140
|
-
| 勾選清單 | 條件 → Given、動作 → When、結果 → Then |
|
|
141
|
-
|
|
142
|
-
### 階段 3:TDD 推演
|
|
143
|
-
|
|
144
|
-
**輸入**:已解析的驗收條件
|
|
145
|
-
**輸出**:測試骨架檔案
|
|
146
|
-
|
|
147
|
-
**參數**:
|
|
148
|
-
| 參數 | 選項 | 預設值 |
|
|
149
|
-
|------|------|--------|
|
|
150
|
-
| `--lang` | typescript, javascript, python, java, go | typescript |
|
|
151
|
-
| `--framework` | vitest, jest, pytest, junit, go-test | vitest |
|
|
152
|
-
|
|
153
|
-
### 階段 4:ATDD 推演
|
|
154
|
-
|
|
155
|
-
**輸入**:已解析的驗收條件
|
|
156
|
-
**輸出**:驗收測試表格文件
|
|
157
|
-
|
|
158
|
-
### 階段 5:人類審查
|
|
159
|
-
|
|
160
|
-
**輸入**:生成的檔案
|
|
161
|
-
**輸出**:審查和精煉的檔案
|
|
162
|
-
|
|
163
|
-
**審查清單**:
|
|
164
|
-
- [ ] 生成的場景符合 AC 意圖
|
|
165
|
-
- [ ] 沒有超出 AC 數量的額外場景
|
|
166
|
-
- [ ] 來源標註正確
|
|
167
|
-
- [ ] [TODO] 區塊已識別供實作
|
|
168
|
-
- [ ] 步驟語言為業務層級(非技術層級)
|
|
169
|
-
|
|
170
|
-
## 輸出格式
|
|
171
|
-
|
|
172
|
-
### BDD Feature 檔案
|
|
173
|
-
|
|
174
|
-
```gherkin
|
|
175
|
-
# Generated from: specs/SPEC-001.md
|
|
176
|
-
# Generator: /derive-bdd v1.0.0
|
|
177
|
-
# Generated at: 2026-01-19T10:00:00Z
|
|
178
|
-
|
|
179
|
-
@SPEC-001
|
|
180
|
-
Feature: 使用者認證
|
|
181
|
-
[來源] 來自 SPEC-001 摘要
|
|
182
|
-
|
|
183
|
-
@AC-1 @happy-path
|
|
184
|
-
Scenario: 使用者以有效憑證登入
|
|
185
|
-
# [來源] 來自 SPEC-001 AC-1
|
|
186
|
-
Given 已註冊的使用者有有效憑證
|
|
187
|
-
When 使用者提交登入表單
|
|
188
|
-
Then 使用者被導向儀表板
|
|
189
|
-
|
|
190
|
-
@AC-2 @error-handling
|
|
191
|
-
Scenario: 無效憑證登入失敗
|
|
192
|
-
# [來源] 來自 SPEC-001 AC-2
|
|
193
|
-
Given 使用者有無效憑證
|
|
194
|
-
When 使用者提交登入表單
|
|
195
|
-
Then 顯示錯誤訊息
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
### TDD 測試骨架
|
|
199
|
-
|
|
200
|
-
```typescript
|
|
201
|
-
/**
|
|
202
|
-
* Tests for SPEC-001: 使用者認證
|
|
203
|
-
* Generated from: specs/SPEC-001.md
|
|
204
|
-
* Generated at: 2026-01-19T10:00:00Z
|
|
205
|
-
* AC Coverage: AC-1, AC-2
|
|
206
|
-
*/
|
|
207
|
-
|
|
208
|
-
describe('SPEC-001: 使用者認證', () => {
|
|
209
|
-
describe('AC-1: 使用者以有效憑證登入', () => {
|
|
210
|
-
it('should redirect to dashboard on successful login', async () => {
|
|
211
|
-
// Arrange
|
|
212
|
-
// [TODO] 設定已註冊使用者和有效憑證
|
|
213
|
-
|
|
214
|
-
// Act
|
|
215
|
-
// [TODO] 提交登入表單
|
|
216
|
-
|
|
217
|
-
// Assert
|
|
218
|
-
// [TODO] 驗證導向儀表板
|
|
219
|
-
expect(true).toBe(true); // Placeholder
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
});
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
### ATDD 驗收測試表格
|
|
226
|
-
|
|
227
|
-
```markdown
|
|
228
|
-
# SPEC-001 驗收測試
|
|
229
|
-
|
|
230
|
-
**規格**: SPEC-001
|
|
231
|
-
**生成時間**: 2026-01-19
|
|
232
|
-
**狀態**: 待審查
|
|
233
|
-
|
|
234
|
-
## AT-001: 使用者以有效憑證登入
|
|
235
|
-
**來源**: AC-1
|
|
236
|
-
|
|
237
|
-
| 步驟 | 動作 | 預期結果 | 通過/失敗 |
|
|
238
|
-
|------|------|----------|-----------|
|
|
239
|
-
| 1 | 導航到登入頁面 | 顯示登入表單 | [ ] |
|
|
240
|
-
| 2 | 輸入有效憑證 | 欄位接受輸入 | [ ] |
|
|
241
|
-
| 3 | 點擊登入 | 表單已提交 | [ ] |
|
|
242
|
-
| 4 | 驗證導向 | 顯示儀表板 | [ ] |
|
|
243
|
-
|
|
244
|
-
**測試人員**: _______________
|
|
245
|
-
**日期**: _______________
|
|
246
|
-
**結果**: [ ] 通過 / [ ] 失敗
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
## 與其他技能的整合
|
|
250
|
-
|
|
251
|
-
### 與 /sdd(規格驅動開發)
|
|
252
|
-
|
|
253
|
-
1. 使用 `/sdd` 工作流程完成 SPEC
|
|
254
|
-
2. 透過審查獲得 SPEC 批准
|
|
255
|
-
3. 執行 `/derive-all` 生成測試結構
|
|
256
|
-
4. 在 BDD/TDD 工作流程中使用生成的輸出
|
|
257
|
-
|
|
258
|
-
### 與 /bdd(行為驅動開發)
|
|
259
|
-
|
|
260
|
-
1. 使用 `/derive-bdd` 生成 BDD 場景
|
|
261
|
-
2. 與利害關係人審查和精煉場景
|
|
262
|
-
3. 使用 `/bdd` 繼續 BDD 制定
|
|
263
|
-
4. 實作步驟定義
|
|
264
|
-
|
|
265
|
-
### 與 /tdd(測試驅動開發)
|
|
266
|
-
|
|
267
|
-
1. 使用 `/derive-tdd` 生成 TDD 骨架
|
|
268
|
-
2. 填寫 [TODO] 區塊的實際斷言
|
|
269
|
-
3. 以生成的測試結構進入 TDD 紅燈階段
|
|
270
|
-
4. 實作程式碼使測試通過
|
|
271
|
-
|
|
272
|
-
### 與整合流程
|
|
273
|
-
|
|
274
|
-
正向推演適合整合流程方法論:
|
|
275
|
-
|
|
276
|
-
```
|
|
277
|
-
spec-review (已批准) → forward-derivation → discovery (BDD)
|
|
278
|
-
│
|
|
279
|
-
├─→ .feature 檔案供 BDD
|
|
280
|
-
├─→ .test.ts 骨架供 TDD
|
|
281
|
-
└─→ acceptance.md 供 ATDD
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
## 完整推演管道
|
|
285
|
-
|
|
286
|
-
```
|
|
287
|
-
┌─────────────────────────────────────────────────────────────────────────┐
|
|
288
|
-
│ 完整正向推演管道 │
|
|
289
|
-
├─────────────────────────────────────────────────────────────────────────┤
|
|
290
|
-
│ │
|
|
291
|
-
│ 已批准 SPEC │
|
|
292
|
-
│ │ │
|
|
293
|
-
│ ▼ │
|
|
294
|
-
│ /derive-all specs/SPEC-XXX.md │
|
|
295
|
-
│ │ │
|
|
296
|
-
│ ├─→ /derive-bdd │
|
|
297
|
-
│ │ └─→ features/SPEC-XXX.feature │
|
|
298
|
-
│ │ │
|
|
299
|
-
│ ├─→ /derive-tdd │
|
|
300
|
-
│ │ └─→ tests/SPEC-XXX.test.ts │
|
|
301
|
-
│ │ │
|
|
302
|
-
│ └─→ /derive-atdd │
|
|
303
|
-
│ └─→ acceptance/SPEC-XXX-acceptance.md │
|
|
304
|
-
│ │
|
|
305
|
-
│ 人類審查 │
|
|
306
|
-
│ │ │
|
|
307
|
-
│ ├─→ 驗證 1:1 AC 對應 │
|
|
308
|
-
│ ├─→ 填寫 [TODO] 區塊 │
|
|
309
|
-
│ └─→ 精煉步驟定義 │
|
|
310
|
-
│ │
|
|
311
|
-
└─────────────────────────────────────────────────────────────────────────┘
|
|
312
|
-
```
|
|
313
|
-
|
|
314
|
-
### 使用範例
|
|
315
|
-
|
|
316
|
-
```bash
|
|
317
|
-
# 生成 BDD 場景
|
|
318
|
-
/derive-bdd specs/SPEC-001.md
|
|
319
|
-
|
|
320
|
-
# 使用 Python/pytest 生成 TDD 骨架
|
|
321
|
-
/derive-tdd specs/SPEC-001.md --lang python --framework pytest
|
|
322
|
-
|
|
323
|
-
# 生成所有測試結構
|
|
324
|
-
/derive-all specs/SPEC-001.md
|
|
325
|
-
|
|
326
|
-
# 預覽不建立檔案
|
|
327
|
-
/derive-all specs/SPEC-001.md --dry-run
|
|
328
|
-
|
|
329
|
-
# 指定輸出目錄
|
|
330
|
-
/derive-all specs/SPEC-001.md --output-dir ./generated
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
## 應避免的反模式
|
|
334
|
-
|
|
335
|
-
### ❌ 不要這樣做
|
|
336
|
-
|
|
337
|
-
1. **添加額外場景**
|
|
338
|
-
- 錯誤:SPEC 有 3 個 AC,生成 5 個場景
|
|
339
|
-
- 正確:SPEC 有 3 個 AC,恰好生成 3 個場景
|
|
340
|
-
|
|
341
|
-
2. **從草稿 SPEC 推演**
|
|
342
|
-
- 錯誤:對未批准的規格執行 `/derive-all`
|
|
343
|
-
- 正確:只從已批准的規格推演
|
|
344
|
-
|
|
345
|
-
3. **跳過來源標註**
|
|
346
|
-
- 錯誤:沒有 @SPEC-XXX 標籤的場景
|
|
347
|
-
- 正確:每個場景標記來源 SPEC 和 AC
|
|
348
|
-
|
|
349
|
-
4. **過度指定技術細節**
|
|
350
|
-
- 錯誤:`Given 使用 PostgreSQL 驅動程式建立資料庫連線`
|
|
351
|
-
- 正確:`Given 系統中存在使用者資料`
|
|
352
|
-
|
|
353
|
-
5. **將骨架視為完整**
|
|
354
|
-
- 錯誤:不填寫 [TODO] 就使用生成的測試
|
|
355
|
-
- 正確:執行測試前填寫所有 [TODO] 區塊
|
|
356
|
-
|
|
357
|
-
## 最佳實踐
|
|
358
|
-
|
|
359
|
-
### 應該做的
|
|
360
|
-
|
|
361
|
-
- ✅ 只從已批准的規格推演
|
|
362
|
-
- ✅ 維持嚴格的 1:1 AC 到輸出對應
|
|
363
|
-
- ✅ 在所有輸出中包含來源標註
|
|
364
|
-
- ✅ 使用 [TODO] 標記實作區塊
|
|
365
|
-
- ✅ 與利害關係人審查生成的輸出
|
|
366
|
-
- ✅ 保持步驟語言在業務層級
|
|
367
|
-
|
|
368
|
-
### 不應該做的
|
|
369
|
-
|
|
370
|
-
- ❌ 添加 AC 未定義的場景
|
|
371
|
-
- ❌ 從草稿或未批准的規格推演
|
|
372
|
-
- ❌ 跳過對生成輸出的人類審查
|
|
373
|
-
- ❌ 將生成的骨架視為完整測試
|
|
374
|
-
- ❌ 移除來源標註註解
|
|
375
|
-
- ❌ 過度指定實作細節
|
|
376
|
-
|
|
377
|
-
---
|
|
378
|
-
|
|
379
|
-
## 設定偵測
|
|
380
|
-
|
|
381
|
-
此技能會自動偵測專案設定:
|
|
382
|
-
|
|
383
|
-
1. 檢查現有的 `specs/` 目錄結構
|
|
384
|
-
2. 從 package.json/pyproject.toml 偵測測試框架
|
|
385
|
-
3. 識別偏好的輸出目錄
|
|
386
|
-
4. 設定語言特定範本
|
|
387
|
-
|
|
388
|
-
---
|
|
389
|
-
|
|
390
|
-
## 相關規範
|
|
391
|
-
|
|
392
|
-
- [正向推演標準](../../core/forward-derivation-standards.md) - **核心方法論規範(主要參考)**
|
|
393
|
-
- [反向工程標準](../../core/reverse-engineering-standards.md) - 對稱對應
|
|
394
|
-
- [規格驅動開發](../../core/spec-driven-development.md) - 輸入規格格式
|
|
395
|
-
- [行為驅動開發](../../../../core/behavior-driven-development.md) - BDD 輸出格式
|
|
396
|
-
- [測試驅動開發](../../core/test-driven-development.md) - TDD 輸出用法
|
|
397
|
-
- [反幻覺指南](../../core/anti-hallucination.md) - 生成合規
|
|
398
|
-
|
|
399
|
-
---
|
|
400
|
-
|
|
401
|
-
## 版本歷史
|
|
402
|
-
|
|
403
|
-
| 版本 | 日期 | 變更 |
|
|
404
|
-
|------|------|------|
|
|
405
|
-
| 2.0.0 | 2026-01-25 | ATDD 從必需改為可選輸出;/derive-all 現在只輸出 BDD + TDD |
|
|
406
|
-
| 1.1.0 | 2026-01-25 | 新增:統一標籤系統參考 |
|
|
407
|
-
| 1.0.0 | 2026-01-19 | 初始發布 |
|
|
408
|
-
|
|
409
|
-
---
|
|
410
|
-
|
|
411
|
-
## 授權
|
|
412
|
-
|
|
413
|
-
此技能採用 [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) 授權。
|
|
414
|
-
|
|
415
|
-
**來源**: [universal-dev-standards](https://github.com/AsiaOstrich/universal-dev-standards)
|