Skip to content

Commit 830238b

Browse files
author
薛華慶, james.hsueh
committed
feat: setup workflow package
1 parent 30cb8a3 commit 830238b

26 files changed

+5627
-0
lines changed

.claude/commands/sdd-arch.md

Lines changed: 308 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,308 @@
1+
---
2+
description: Phase 2 - Design data models and interfaces from Gherkin specification (Architect role)
3+
---
4+
5+
# SDD Phase 2: Structural Design (The Skeleton)
6+
7+
**Role:** System Architect
8+
9+
**Goal:** Design the technical skeleton (data models and interfaces) required to support the Gherkin scenarios from Phase 1.
10+
11+
**This phase is language and framework agnostic.** Adapt your output to the target language and its idioms while maintaining the core SDD principles.
12+
13+
## Input
14+
15+
Gherkin specification file: {{prompt}}
16+
17+
## Your Constraints
18+
19+
- You are an Architect. Read and analyze the Gherkin specification.
20+
- Define ONLY the structure: Data Models and Interfaces.
21+
- NO business logic implementation allowed in this phase.
22+
- Only define method signatures, not implementations.
23+
- Extract nouns from Gherkin → Data Models
24+
- Extract verbs from Gherkin → Service Interfaces
25+
26+
## Language Detection
27+
28+
Before proceeding:
29+
1. Check if user specified a language in their prompt
30+
2. Look at the project context (existing files)
31+
3. If unclear, ask the user: "Which language would you like for this implementation? (Python, TypeScript, Go, Java, Rust, C#, etc.)"
32+
4. Use the determined language consistently
33+
34+
## Your Task
35+
36+
1. **Read the Gherkin file** specified by the user
37+
38+
2. **Noun Analysis** - Extract entities and create Data Models:
39+
- Identify all nouns in the Gherkin scenarios
40+
- Create strongly-typed models using language-appropriate patterns
41+
- Define all fields with appropriate types
42+
- Include enums/constants for categorical values
43+
44+
3. **Verb Analysis** - Extract actions and create Service Interfaces:
45+
- Identify all actions/verbs in the Gherkin scenarios
46+
- Create abstract interfaces/protocols/traits
47+
- Define method signatures with type hints
48+
- Add docstrings/comments that reference the Gherkin scenarios
49+
50+
4. **Choose appropriate idioms for your target language:**
51+
52+
- **Python:** dataclasses, Pydantic models, or Protocol/ABC
53+
- **TypeScript:** interfaces and types
54+
- **Go:** structs and interfaces
55+
- **Java:** interfaces and POJOs
56+
- **Rust:** structs and traits
57+
- **C#:** interfaces and records/classes
58+
- **Ruby:** modules and duck typing
59+
- **Kotlin:** interfaces and data classes
60+
61+
## Output Examples by Language
62+
63+
### Python (dataclasses + ABC)
64+
65+
```python
66+
"""
67+
Structural design for <Feature Name>
68+
Source: features/<feature>.feature
69+
"""
70+
71+
from dataclasses import dataclass
72+
from abc import ABC, abstractmethod
73+
from enum import Enum
74+
from typing import Optional
75+
76+
# Enums (from categorical nouns)
77+
class UserType(str, Enum):
78+
VIP = "VIP"
79+
NORMAL = "NORMAL"
80+
81+
# Data Models (from nouns)
82+
@dataclass
83+
class User:
84+
"""From Scenario: '<scenario name>'"""
85+
id: str
86+
user_type: UserType
87+
points: int = 0
88+
89+
@dataclass
90+
class Result:
91+
success: bool
92+
value: Optional[float] = None
93+
error: Optional[str] = None
94+
95+
# Interfaces (from verbs)
96+
class IDiscountService(ABC):
97+
"""Satisfies: features/<feature>.feature"""
98+
99+
@abstractmethod
100+
def calculate_discount(self, user: User, amount: float) -> Result:
101+
"""
102+
From Scenarios:
103+
- "Apply discount to VIP" (line X)
104+
- "No discount for normal" (line Y)
105+
"""
106+
pass
107+
```
108+
109+
### TypeScript
110+
111+
```typescript
112+
/**
113+
* Structural design for <Feature Name>
114+
* Source: features/<feature>.feature
115+
*/
116+
117+
// Enums (from categorical nouns)
118+
export enum UserType {
119+
VIP = "VIP",
120+
NORMAL = "NORMAL"
121+
}
122+
123+
// Data Models (from nouns)
124+
export interface User {
125+
/** From Scenario: '<scenario name>' */
126+
id: string;
127+
userType: UserType;
128+
points: number;
129+
}
130+
131+
export interface Result {
132+
success: boolean;
133+
value?: number;
134+
error?: string;
135+
}
136+
137+
// Interfaces (from verbs)
138+
export interface IDiscountService {
139+
/**
140+
* From Scenarios:
141+
* - "Apply discount to VIP" (line X)
142+
* - "No discount for normal" (line Y)
143+
*/
144+
calculateDiscount(user: User, amount: number): Result;
145+
}
146+
```
147+
148+
### Go
149+
150+
```go
151+
// Structural design for <Feature Name>
152+
// Source: features/<feature>.feature
153+
154+
package discount
155+
156+
// Enums (from categorical nouns)
157+
type UserType string
158+
159+
const (
160+
UserTypeVIP UserType = "VIP"
161+
UserTypeNormal UserType = "NORMAL"
162+
)
163+
164+
// Data Models (from nouns)
165+
// From Scenario: '<scenario name>'
166+
type User struct {
167+
ID string
168+
UserType UserType
169+
Points int
170+
}
171+
172+
type Result struct {
173+
Success bool
174+
Value *float64
175+
Error *string
176+
}
177+
178+
// Interfaces (from verbs)
179+
// Satisfies: features/<feature>.feature
180+
type DiscountService interface {
181+
// From Scenarios:
182+
// - "Apply discount to VIP" (line X)
183+
// - "No discount for normal" (line Y)
184+
CalculateDiscount(user User, amount float64) Result
185+
}
186+
```
187+
188+
### Java
189+
190+
```java
191+
/**
192+
* Structural design for <Feature Name>
193+
* Source: features/<feature>.feature
194+
*/
195+
196+
// Enums (from categorical nouns)
197+
public enum UserType {
198+
VIP,
199+
NORMAL
200+
}
201+
202+
// Data Models (from nouns)
203+
/** From Scenario: '<scenario name>' */
204+
public class User {
205+
private String id;
206+
private UserType userType;
207+
private int points;
208+
209+
// Constructor, getters, setters
210+
}
211+
212+
public class Result {
213+
private boolean success;
214+
private Double value;
215+
private String error;
216+
217+
// Constructor, getters, setters
218+
}
219+
220+
// Interfaces (from verbs)
221+
/** Satisfies: features/<feature>.feature */
222+
public interface IDiscountService {
223+
/**
224+
* From Scenarios:
225+
* - "Apply discount to VIP" (line X)
226+
* - "No discount for normal" (line Y)
227+
*/
228+
Result calculateDiscount(User user, double amount);
229+
}
230+
```
231+
232+
### Rust
233+
234+
```rust
235+
//! Structural design for <Feature Name>
236+
//! Source: features/<feature>.feature
237+
238+
// Enums (from categorical nouns)
239+
#[derive(Debug, Clone, PartialEq)]
240+
pub enum UserType {
241+
Vip,
242+
Normal,
243+
}
244+
245+
// Data Models (from nouns)
246+
/// From Scenario: '<scenario name>'
247+
#[derive(Debug, Clone)]
248+
pub struct User {
249+
pub id: String,
250+
pub user_type: UserType,
251+
pub points: i32,
252+
}
253+
254+
#[derive(Debug, Clone)]
255+
pub struct Result {
256+
pub success: bool,
257+
pub value: Option<f64>,
258+
pub error: Option<String>,
259+
}
260+
261+
// Traits (from verbs)
262+
/// Satisfies: features/<feature>.feature
263+
pub trait DiscountService {
264+
/// From Scenarios:
265+
/// - "Apply discount to VIP" (line X)
266+
/// - "No discount for normal" (line Y)
267+
fn calculate_discount(&self, user: &User, amount: f64) -> Result;
268+
}
269+
```
270+
271+
## Language-Agnostic Principles
272+
273+
Regardless of the target language, your structure design must:
274+
275+
1. **Traceability:** Every model and interface references its source Gherkin scenario
276+
2. **Strong Typing:** Use the strongest typing available in the language
277+
3. **No Implementation:** Only signatures/definitions, no logic
278+
4. **Completeness:** All nouns → models, all verbs → interfaces
279+
5. **Documentation:** Comments/docstrings link to specific Gherkin lines
280+
281+
## Quality Checklist
282+
283+
Before completing, ensure:
284+
- [ ] All nouns from Gherkin are represented as data structures
285+
- [ ] All verbs from Gherkin are represented as interface methods
286+
- [ ] All categorical values use enums/constants
287+
- [ ] Types are as strict as the language allows
288+
- [ ] Each element references its source Gherkin scenario
289+
- [ ] NO implementation logic exists (only definitions)
290+
- [ ] File uses appropriate extension for target language
291+
- [ ] Follows language-specific naming conventions
292+
293+
## Naming Conventions by Language
294+
295+
- **Python:** `snake_case` for functions/variables, `PascalCase` for classes
296+
- **TypeScript/JavaScript:** `camelCase` for functions/variables, `PascalCase` for types/interfaces
297+
- **Go:** `PascalCase` for exported, `camelCase` for private
298+
- **Java/C#:** `camelCase` for methods/variables, `PascalCase` for classes/interfaces
299+
- **Rust:** `snake_case` for functions/variables, `PascalCase` for types
300+
301+
## Next Steps
302+
303+
After completing this phase:
304+
- Save the structure file with appropriate extension
305+
- Proceed to Phase 3: `/sdd-impl features/<feature>.feature structure/<feature>_structure.<ext>`
306+
- Or return to user for architecture review
307+
308+
Now read the Gherkin file and create the structural design in the appropriate language.

0 commit comments

Comments
 (0)