Skip to content

Commit 4e5d7f2

Browse files
authored
Merge pull request #55 from gotalab/feature/commands-enhance
feat(spec-design): enhance technical design document generation
2 parents 95bfaf2 + d6f3f99 commit 4e5d7f2

File tree

50 files changed

+2627
-7589
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2627
-7589
lines changed

.claude/commands/kiro/spec-design.md

Lines changed: 196 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ Generate a **technical design document** for feature **$1**.
7272
- Identify configuration and setup requirements
7373
- Document any migration or integration challenges
7474

75-
**Skip if**: Using familiar technology stack in standard patterns
75+
**For ANY external dependencies (libraries, APIs, services)**:
76+
- Use WebSearch to find official documentation and community resources
77+
- Use WebFetch to analyze specific documentation pages
78+
- Document authentication flows, rate limits, and usage constraints
79+
- Note any gaps in understanding for implementation phase
80+
81+
**Skip only if**: Using well-established internal libraries with no external dependencies
7682

7783
#### F. Technical Risk Assessment
7884
- Performance/scalability risks: bottlenecks, capacity, growth
@@ -104,8 +110,8 @@ Generate a **technical design document** for feature **$1**.
104110
- Migration Strategy (for existing system modifications)
105111

106112
<structured-document>
107-
## Overview (2-3 paragraphs max)
108-
113+
## Overview
114+
2-3 paragraphs max
109115
**Purpose**: This feature delivers [specific value] to [target users].
110116
**Users**: [Target user groups] will utilize this for [specific workflows].
111117
**Impact** (if applicable): Changes the current [system state] by [specific modifications].
@@ -139,138 +145,222 @@ When modifying existing systems:
139145
- Technology alignment: [how it fits current stack]
140146
- Steering compliance: [principles maintained]
141147

142-
### Data Flow
143-
**RECOMMENDED**: Include sequence diagram or flowchart showing data flow when data interactions are complex or span multiple systems
144-
145148
### Technology Stack and Design Decisions
146149

147-
**Technology Stack**:
148-
- **Frontend**: [Framework/Library] - rationale, alternatives considered
149-
- **Backend**: [Framework/Runtime] - rationale, alternatives considered
150-
- **Database**: [Type/Technology] - rationale, alternatives considered
151-
- **Infrastructure**: [Deployment/Hosting] - rationale, alternatives considered
150+
**Generation Instructions** (DO NOT include this section in design.md):
151+
Adapt content based on feature classification from Discovery & Analysis Phase:
152+
153+
**For New Features (greenfield)**:
154+
Generate Technology Stack section with ONLY relevant layers:
155+
- Include only applicable technology layers (e.g., skip Frontend for CLI tools, skip Infrastructure for libraries)
156+
- For each technology choice, provide: selection, rationale, and alternatives considered
157+
- Include Architecture Pattern Selection if making architectural decisions
152158

153-
**Architecture Pattern Selection**:
154-
- **Chosen Pattern**: [e.g., Clean Architecture, Hexagonal, MVC]
155-
- **Rationale**: Why this pattern fits requirements and constraints
156-
- **Alternatives Considered**: Other patterns evaluated and rejection reasons
157-
- **Integration Approach**: How pattern integrates with existing systems
159+
**For Extensions/Additions to Existing Systems**:
160+
Generate Technology Alignment section instead:
161+
- Document how feature aligns with existing technology stack
162+
- Note any new dependencies or libraries being introduced
163+
- Justify deviations from established patterns if necessary
158164

159165
**Key Design Decisions**:
166+
Generate 1-3 critical technical decisions that significantly impact the implementation.
167+
Each decision should follow this format:
168+
- **Decision**: [Specific technical choice made]
169+
- **Context**: [Problem or requirement driving this decision]
170+
- **Alternatives**: [2-3 other approaches considered]
171+
- **Selected Approach**: [What was chosen and how it works]
172+
- **Rationale**: [Why this is optimal for the specific context]
173+
- **Trade-offs**: [What we gain vs. what we sacrifice]
160174

161-
**Decision**: Brief decision description
162-
- **Context**: Problem that needed solving
163-
- **Alternatives**: Other approaches considered
164-
- **Selected Approach**: Chosen solution
165-
- **Rationale**: Why optimal based on trade-off analysis
166-
- **Trade-offs**: Benefits gained vs. costs incurred
175+
Skip this entire section for simple CRUD operations or when following established patterns without deviation.
167176

168-
## Components and Interfaces
177+
## System Flows
169178

170-
**Implementation Strategy** (when existing code exists):
171-
- Existing components to modify vs. create new
172-
- Integration with existing architecture
173-
- File mapping for updates
174-
- Dependency impact assessment
179+
**Flow Design Generation Instructions** (DO NOT include this section in design.md):
180+
Generate appropriate flow diagrams ONLY when the feature requires flow visualization. Select from:
181+
- **Sequence Diagrams**: For user interactions across multiple components
182+
- **Process Flow Charts**: For complex algorithms, decision branches, or state machines
183+
- **Data Flow Diagrams**: For data transformations, ETL processes, or data pipelines
184+
- **State Diagrams**: For complex state transitions
185+
- **Event Flow**: For async/event-driven architectures
175186

176-
### Component Name
187+
Skip this section entirely for simple CRUD operations or features without complex flows.
188+
When included, provide concise Mermaid diagrams specific to the actual feature requirements.
177189

178-
**Implementation Approach**:
179-
- If modifying: file path and changes description
180-
- If new: justification for not extending existing
181-
- DDD compliance: aggregate boundaries, domain services
190+
## Requirements Traceability
182191

183-
**Function**: Component's core responsibility.
192+
**Traceability Generation Instructions** (DO NOT include this section in design.md):
193+
Generate traceability mapping ONLY for complex features with multiple requirements or when explicitly needed for compliance/validation.
184194

185-
**Key Features**:
186-
- Core capability 1 - brief description
187-
- Core capability 2 - brief description
188-
- Unique differentiator - what makes it special
195+
When included, create a mapping table showing how each EARS requirement is realized:
196+
| Requirement | Requirement Summary | Components | Interfaces | Flows |
197+
|---------------|-------------------|------------|------------|-------|
198+
| 1.1 | Brief description | Component names | API/Methods | Relevant flow diagrams |
189199

190-
**API Endpoints** (if applicable):
200+
Alternative format for simpler cases:
201+
- **1.1**: Realized by [Component X] through [Interface Y]
202+
- **1.2**: Implemented in [Component Z] with [Flow diagram reference]
191203

192-
| Method | Route | Purpose | Auth | Status Codes |
193-
|--------|-------|---------|------|--------------|
194-
| GET | /api/users | Retrieve user list | Required | 200, 401, 403 |
195-
| POST | /api/users | Create new user | Required | 201, 400, 401 |
204+
Skip this section for simple features with straightforward 1:1 requirement-to-component mappings.
196205

197-
**API Specification Details**:
206+
## Components and Interfaces
198207

199-
**GET /api/users**
200-
- **Query Parameters**: `limit` (number, max 100), `offset` (number), `filter` (string)
201-
- **Response Headers**: `X-Total-Count`, `Content-Type: application/json`
202-
- **Success Response** (200):
203-
```json
204-
{
205-
"users": [{ "id": "uuid", "email": "string", "name": "string", "role": "enum" }],
206-
"pagination": { "total": "number", "limit": "number", "offset": "number" }
207-
}
208-
```
208+
**Component Design Generation Instructions** (DO NOT include this section in design.md):
209+
Structure components by domain boundaries or architectural layers. Generate only relevant subsections based on component type.
210+
Group related components under domain/layer headings for clarity.
209211

210-
**POST /api/users**
211-
- **Request Headers**: `Content-Type: application/json`, `Authorization: Bearer {token}`
212-
- **Request Body**:
213-
```json
214-
{ "email": "string (required)", "name": "string (required)", "role": "admin|user|guest" }
215-
```
216-
- **Success Response** (201):
217-
```json
218-
{ "id": "uuid", "email": "string", "name": "string", "role": "enum", "createdAt": "ISO8601" }
219-
```
220-
221-
**Interface Design** (core methods only, use technology stack language):
222-
```typescript
223-
// Core methods only - NO implementation details
224-
// NEVER use 'any' type - define specific types instead
225-
interface UserService {
226-
findAll(): Promise<User[]>;
227-
create(userData: CreateUserRequest): Promise<User>;
228-
}
229-
```
212+
### [Domain/Layer Name]
230213

231-
**Integration Points**: Interaction with existing modules, dependencies, interface changes
214+
#### [Component Name]
232215

233-
**Rationale**: Design choices and trade-offs
216+
**Responsibility & Boundaries**
217+
- **Primary Responsibility**: Single, clear statement of what this component does
218+
- **Domain Boundary**: Which domain/subdomain this belongs to
219+
- **Data Ownership**: What data this component owns and manages
220+
- **Transaction Boundary**: Scope of transactional consistency (if applicable)
234221

235-
## Data Models
222+
**Dependencies**
223+
- **Inbound**: Components/services that depend on this component
224+
- **Outbound**: Components/services this component depends on
225+
- **External**: Third-party services, libraries, or external systems
236226

237-
**IMPORTANT**: Only include sections relevant to the project. Skip Database Schema for API-only or frontend-only features.
227+
**External Dependencies Investigation** (when using external libraries/services):
228+
- Use WebSearch to locate official documentation, GitHub repos, and community resources
229+
- Use WebFetch to retrieve and analyze documentation pages, API references, and usage examples
230+
- Verify API signatures, authentication methods, and rate limits
231+
- Check version compatibility, breaking changes, and migration guides
232+
- Investigate common issues, best practices, and performance considerations
233+
- Document any assumptions, unknowns, or risks for implementation phase
234+
- If critical information is missing, clearly note "Requires investigation during implementation: [specific concern]"
238235

239-
### Domain Model
240-
Core entities and their relationships.
241-
242-
**RECOMMENDED**: Include ER diagram for complex relationships:
243-
```mermaid
244-
erDiagram
245-
Customer ||--o{ Order : places
246-
Order ||--|{ OrderItem : contains
247-
Product ||--o{ OrderItem : "ordered in"
248-
```
236+
**Contract Definition**
249237

250-
### User
251-
**Function**: User data storage and validation
252-
**Constraints**: Email uniqueness, role enumeration
238+
Select and generate ONLY the relevant contract types for each component:
253239

240+
**Service Interface** (for business logic components):
254241
```typescript
255-
// Use technology stack language
256-
interface User {
257-
id: string;
258-
email: string;
259-
role: 'admin' | 'user' | 'guest';
242+
interface [ComponentName]Service {
243+
// Method signatures with clear input/output types
244+
// Include error types in return signatures
245+
methodName(input: InputType): Result<OutputType, ErrorType>;
260246
}
261247
```
248+
- **Preconditions**: What must be true before calling
249+
- **Postconditions**: What is guaranteed after successful execution
250+
- **Invariants**: What remains true throughout
251+
252+
**API Contract** (for REST/GraphQL endpoints):
253+
| Method | Endpoint | Request | Response | Errors |
254+
|--------|----------|---------|----------|--------|
255+
| POST | /api/resource | CreateRequest | Resource | 400, 409, 500 |
256+
257+
With detailed schemas only for complex payloads
258+
259+
**Event Contract** (for event-driven components):
260+
- **Published Events**: Event name, schema, trigger conditions
261+
- **Subscribed Events**: Event name, handling strategy, idempotency
262+
- **Ordering**: Guaranteed order requirements
263+
- **Delivery**: At-least-once, at-most-once, or exactly-once
264+
265+
**Batch/Job Contract** (for scheduled/triggered processes):
266+
- **Trigger**: Schedule, event, or manual trigger conditions
267+
- **Input**: Data source and validation rules
268+
- **Output**: Results destination and format
269+
- **Idempotency**: How repeat executions are handled
270+
- **Recovery**: Failure handling and retry strategy
271+
272+
**State Management** (only if component maintains state):
273+
- **State Model**: States and valid transitions
274+
- **Persistence**: Storage strategy and consistency model
275+
- **Concurrency**: Locking, optimistic/pessimistic control
276+
277+
**Integration Strategy** (when modifying existing systems):
278+
- **Modification Approach**: Extend, wrap, or refactor existing code
279+
- **Backward Compatibility**: What must be maintained
280+
- **Migration Path**: How to transition from current to target state
281+
282+
## Data Models
262283

263-
### Database Schema
264-
**Only include when database implementation is required.**
284+
**Data Model Generation Instructions** (DO NOT include this section in design.md):
285+
Generate only relevant data model sections based on the system's data requirements and chosen architecture.
286+
Progress from conceptual to physical as needed for implementation clarity.
265287

266-
#### Users Table
267-
```sql
268-
CREATE TABLE users (
269-
id UUID PRIMARY KEY,
270-
email VARCHAR UNIQUE NOT NULL,
271-
role VARCHAR CHECK (role IN ('admin', 'user', 'guest'))
272-
);
273-
```
288+
### Domain Model
289+
**When to include**: Complex business domains with rich behavior and rules
290+
291+
**Core Concepts**:
292+
- **Aggregates**: Define transactional consistency boundaries
293+
- **Entities**: Business objects with unique identity and lifecycle
294+
- **Value Objects**: Immutable descriptive aspects without identity
295+
- **Domain Events**: Significant state changes in the domain
296+
297+
**Business Rules & Invariants**:
298+
- Constraints that must always be true
299+
- Validation rules and their enforcement points
300+
- Cross-aggregate consistency strategies
301+
302+
Include conceptual diagram (Mermaid) only when relationships are complex enough to benefit from visualization
303+
304+
### Logical Data Model
305+
**When to include**: When designing data structures independent of storage technology
306+
307+
**Structure Definition**:
308+
- Entity relationships and cardinality
309+
- Attributes and their types
310+
- Natural keys and identifiers
311+
- Referential integrity rules
312+
313+
**Consistency & Integrity**:
314+
- Transaction boundaries
315+
- Cascading rules
316+
- Temporal aspects (versioning, audit)
317+
318+
### Physical Data Model
319+
**When to include**: When implementation requires specific storage design decisions
320+
321+
**For Relational Databases**:
322+
- Table definitions with data types
323+
- Primary/foreign keys and constraints
324+
- Indexes and performance optimizations
325+
- Partitioning strategy for scale
326+
327+
**For Document Stores**:
328+
- Collection structures
329+
- Embedding vs referencing decisions
330+
- Sharding key design
331+
- Index definitions
332+
333+
**For Event Stores**:
334+
- Event schema definitions
335+
- Stream aggregation strategies
336+
- Snapshot policies
337+
- Projection definitions
338+
339+
**For Key-Value/Wide-Column Stores**:
340+
- Key design patterns
341+
- Column families or value structures
342+
- TTL and compaction strategies
343+
344+
### Data Contracts & Integration
345+
**When to include**: Systems with service boundaries or external integrations
346+
347+
**API Data Transfer**:
348+
- Request/response schemas
349+
- Validation rules
350+
- Serialization format (JSON, Protobuf, etc.)
351+
352+
**Event Schemas**:
353+
- Published event structures
354+
- Schema versioning strategy
355+
- Backward/forward compatibility rules
356+
357+
**Cross-Service Data Management**:
358+
- Distributed transaction patterns (Saga, 2PC)
359+
- Data synchronization strategies
360+
- Eventual consistency handling
361+
362+
Skip any section not directly relevant to the feature being designed.
363+
Focus on aspects that influence implementation decisions.
274364

275365
## Error Handling
276366

.claude/commands/kiro/spec-tasks.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ Generate detailed implementation tasks for feature: **$1**
112112

113113
### Document Generation
114114
- Generate `.kiro/specs/$1/tasks.md` using the exact numbering format above
115+
- **Language**: Use language from `spec.json.language` field, default to English
115116
- **Task descriptions**: Use natural language for "what to do" (implementation details in design.md)
116117
- Update `.kiro/specs/$1/spec.json`:
117118
- Set `phase: "tasks-generated"`

0 commit comments

Comments
 (0)