當接收到新需求或 Event Storming 產出後觸發。分析問題類別(CBF/IDF/RIF),生成完整的規格目錄結構。實現「需求與實作分離」、「規格即文檔、文檔即規格」。
Analyzes new requirements or Event Storming outputs to classify problems into CBF/IDF/RIF frames and generates complete specification directories. Triggers on new requirements, Event Storming outputs, or explicit analysis requests.
/plugin marketplace add knowlet/skills/plugin install knowlet-skills@knowlet/skillsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
scripts/validate_spec.pytemplates/acceptance.yamltemplates/controlled-domain/aggregate.yamltemplates/cross-context/authorization.yamltemplates/frame.yamltemplates/machine/controller.yamltemplates/machine/machine.yamltemplates/machine/query.yamltemplates/machine/reactor.yamltemplates/machine/use-case.yamltemplates/requirements/req-template.yamltemplates/runbook/execute.md將需求分析為 Problem Frames 的五種基本類別,並輸出結構化的規格目錄。
command-sub-agentquery-sub-agentreactor-sub-agent在 docs/specs/{feature-name}/ 目錄下生成完整規格:
docs/specs/{feature-name}/
├── frame.yaml # 問題框架定義 (核心)
├── acceptance.yaml # 驗收測試規格 (在根目錄)
│
├── requirements/ # 需求層 (What) - 純業務語言
│ └── cbf-req-1-{feature}.yaml
│
├── machine/ # 機器層 (How) - Application 層
│ ├── machine.yaml # Machine 定義
│ ├── controller.yaml # API 入口規格
│ └── use-case.yaml # Use Case 規格
│
├── controlled-domain/ # 領域層 - Domain 層
│ └── aggregate.yaml # Aggregate + Entities + Value Objects
│
├── cross-context/ # 跨 Bounded Context 依賴 (若有)
│ └── {context-name}.yaml # ACL 定義
│
└── runbook/ # 執行指南 (選用)
└── execute.md
{frame-type}-req-{n}-{feature}.yaml
cbf-req-1-create-workflow.yamlcbf | idf | rif | wpf | tf# docs/specs/{feature-name}/frame.yaml
problem_frame: "{FeatureName}"
frame_type: CommandedBehaviorFrame # | InformationDisplayFrame | RequiredBehaviorFrame
intent: |
{一句話描述問題意圖}
{使用 "When ... the Machine shall ..." 格式}
# ---------------------------------------------------------------------------
# Problem Frame Components
# ---------------------------------------------------------------------------
operator:
name: "{Actor}"
description: "{Actor 描述}"
machine:
name: "{FeatureName}Machine"
machine_spec: machine/machine.yaml
controlled_domain:
domain: "{DomainName}"
entity: "{AggregateRoot} (Aggregate Root)"
aggregate_spec: controlled-domain/aggregate.yaml
# ---------------------------------------------------------------------------
# Frame Concerns(問題框架關注點)
# ---------------------------------------------------------------------------
frame_concerns:
- id: FC1
name: "{Concern Name}"
description: |
{描述這個關注點的業務規則或技術約束}
satisfied_by:
- controlled-domain/aggregate.yaml#invariants.{name}
- tests#{test-id}
- id: FC2
name: "Interference / Concurrency"
description: |
{描述並發或干擾問題}
satisfied_by:
- machine/use-case.yaml#transaction_boundary
- machine/use-case.yaml#idempotency
# ---------------------------------------------------------------------------
# Cross-Context Dependencies(跨限界上下文依賴)
# ---------------------------------------------------------------------------
cross_context_dependencies:
- id: XC1
name: "{DependencyName}"
source_context: "{SourceBC}"
target_context: "{CurrentBC}"
interface_type: "AntiCorruption Layer"
contract_spec: cross-context/{context-name}.yaml
# ---------------------------------------------------------------------------
# Generation Metadata(生成元數據)
# ---------------------------------------------------------------------------
generation:
version: "1.0.0"
created_at: "{ISO-8601}"
last_generated: null
history: []
output_paths:
application: "src/application/use-cases/"
domain: "src/domain/"
infrastructure: "src/infrastructure/"
# 需求層:純業務語言,不含任何實作細節
requirement:
id: REQ-{NNN}
title: "{Feature Title}"
type: functional # | non-functional | constraint
priority: high # | medium | low
# User Story 格式
description: |
As a {Actor}
I want to {Action}
So that {Benefit}
# 業務規則(仍在需求層,無實作)
business_rules:
- id: BR1
rule: "{Business Rule 1}"
- id: BR2
rule: "{Business Rule 2}"
# 連結到 Frame Concerns
addresses_concerns:
- FC1
- FC2
# 驗收條件(高層次)
acceptance_conditions:
- "AC1: {Condition 1}"
- "AC2: {Condition 2}"
# Machine 層:Application 層規格
use_case:
name: "{FeatureName}UseCase"
type: command # | query
# Input/Output 定義
input:
name: "{FeatureName}Input"
fields:
- name: "{fieldName}"
type: "{Type}"
required: true
validation: "{validation rule}"
output:
name: "{FeatureName}Output"
fields:
- name: "{fieldName}"
type: "{Type}"
# Design by Contract
contracts:
pre_conditions:
- id: PRE1
condition: "{condition}"
error: "{ErrorType}"
post_conditions:
- id: POST1
condition: "{condition}"
# 技術約束
transaction_boundary:
type: "RequiresNew"
isolation: "ReadCommitted"
idempotency:
enabled: true
key: "{idempotencyKeyField}"
# 發布的 Domain Events
publishes_events:
- "{FeatureName}CreatedEvent"
# Domain 層:Aggregate 規格
aggregate:
name: "{AggregateName}"
root: true
# 身份識別
identity:
name: "{AggregateName}Id"
type: "UUID"
# 屬性
properties:
- name: "{propertyName}"
type: "{Type}"
mutable: false
# 內部 Entities
entities:
- name: "{EntityName}"
identity: "{EntityName}Id"
# Value Objects
value_objects:
- name: "{ValueObjectName}"
properties:
- name: "{prop}"
type: "{Type}"
# Invariants(不變量)
invariants:
shared:
- id: INV1
name: "{InvariantName}"
rule: "{Rule description}"
enforced_in:
- "constructor"
- "method:{methodName}"
# Domain Events
domain_events:
- name: "{AggregateName}CreatedEvent"
properties:
- name: "{prop}"
type: "{Type}"
當有多個 Aggregate 和 Use Case 時,建議按以下方式排序:
Phase 1: 核心 Aggregate 建立 (Create)
├── create-product.json ✅ 已完成
├── create-pbi.json ✅ 已完成
└── create-sprint.json ✅ 已完成
Phase 2: 完成第一個 Aggregate 生命週期
├── start-sprint → Command | Medium
├── complete-sprint → Command | Medium
├── cancel-sprint → Command | Low
├── get-sprint → Query | Low
├── get-sprints-by-product → Query | Low
└── delete-sprint → Command | Medium
Phase 3: 擴展其他 Aggregate
├── Product Aggregate (6 use cases)
├── PBI Aggregate (15 use cases) - 最大 backlog
└── Scrum Team Aggregate (5 use cases) - 新 aggregate
| 複雜度 | 標準 | 估計時間 |
|---|---|---|
| Low | 單一 Aggregate,無跨 BC | 1-2 小時 |
| Medium | 有驗證邏輯或狀態轉換 | 2-4 小時 |
| High | 跨多個 Aggregate 或 BC | 4-8 小時 |
analyze-frame (本 Skill)
│
├── 輸出 → frame.yaml + 目錄結構
│
├── spec-template → 生成各層 YAML 模板
│
├── cross-context → 處理跨 BC 依賴
│
└── 觸發 Sub-agents
├── command-sub-agent (CBF)
├── query-sub-agent (IDF)
└── reactor-sub-agent (RIF)
本 Skill 提供驗證工具,位於 scripts/ 目錄:
用於驗證規格目錄的完整性與正確性。
使用方式:
# 驗證單一功能規格
python ~/.claude/skills/analyze-frame/scripts/validate_spec.py docs/specs/create-workflow/
# 驗證多個規格
python ~/.claude/skills/analyze-frame/scripts/validate_spec.py docs/specs/create-workflow/ docs/specs/query-dashboard/
# 在 CI/CD 中使用
python ~/.claude/skills/analyze-frame/scripts/validate_spec.py docs/specs/*/ || exit 1
驗證項目:
| 檢查項目 | 類型 | 說明 |
|---|---|---|
| 目錄結構 | ERROR | 必要目錄是否存在 |
| frame.yaml | ERROR | 問題框架定義是否存在且有效 |
| YAML 語法 | ERROR | 所有 YAML 檔案語法正確性 |
| Frame Concerns | WARNING | 是否有 satisfied_by 連結 |
| Cross-Context | INFO | ACL 規格是否存在 |
| Acceptance | WARNING | 測試覆蓋率檢查 |
Exit Codes:
0: 驗證通過1: 有 ERROR 級別錯誤2: 參數錯誤本 Skill 提供完整的 YAML 規格範本,位於 templates/ 目錄:
templates/
├── frame.yaml # 問題框架範本
├── requirements/
│ └── req-template.yaml # 需求規格範本 (純業務語言)
├── machine/
│ └── use-case.yaml # Use Case 規格範本
├── controlled-domain/
│ └── aggregate.yaml # Aggregate 規格範本
├── acceptance/
│ └── acceptance.yaml # 驗收測試範本
├── cross-context/
│ └── authorization.yaml # ACL 規格範本
└── runbook/
└── execute.md # 執行指南範本
初始化新功能規格:
# 建立目錄結構
mkdir -p docs/specs/{feature-name}/{requirements,machine,controlled-domain,cross-context,acceptance,runbook}
# 複製範本
cp ~/.claude/skills/analyze-frame/templates/frame.yaml docs/specs/{feature-name}/
在 Claude 中使用:
請根據 ~/.claude/skills/analyze-frame/templates/ 的範本
為「建立工作流程」功能生成規格目錄
| 範本 | 用途 | 特點 |
|---|---|---|
frame.yaml | 問題框架定義 | 包含 frame_concerns + satisfied_by |
req-template.yaml | 需求規格 | 純業務語言,禁止實作細節 |
use-case.yaml | Application 層 | Design by Contract、冪等性 |
aggregate.yaml | Domain 層 | Invariants 含 enforced_in |
acceptance.yaml | 測試規格 | BDD 格式,ezSpec 相容 |
authorization.yaml | ACL 規格 | 容錯、重試、Circuit Breaker |
execute.md | 執行指南 | 生成步驟、品質驗證 |
1. 需求輸入
↓
2. 分析問題框架 (analyze-frame)
↓
3. 生成規格目錄 (使用 templates/)
↓
4. 驗證規格完整性 (scripts/validate_spec.py)
↓
5. 分派至 Sub-agent
├── command-sub-agent (CBF)
├── query-sub-agent (IDF)
└── reactor-sub-agent (RIF)
↓
6. 生成程式碼
↓
7. 生成驗收測試 (generate-acceptance-test)
↓
8. 品質檢查 (arch-guard, enforce-contract)
↓
9. 執行測試驗證
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.