sdd-mcp-server 1.8.0 → 2.0.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.
@@ -0,0 +1,262 @@
1
+ ---
2
+ name: sdd-design
3
+ description: Create technical design specifications for SDD workflow. Use when designing architecture, defining components, or creating system design documents after requirements are approved. Invoked via /sdd-design <feature-name>.
4
+ ---
5
+
6
+ # SDD Technical Design Generation
7
+
8
+ Generate comprehensive technical design documents that translate approved requirements into actionable architecture specifications.
9
+
10
+ ## Prerequisites
11
+
12
+ Before generating design:
13
+ 1. Requirements must be generated using `/sdd-requirements`
14
+ 2. Requirements phase should be approved (use `sdd-approve requirements` MCP tool)
15
+ 3. Review existing architecture in `.spec/steering/tech.md` and `.spec/steering/structure.md`
16
+
17
+ ## Workflow
18
+
19
+ ### Step 1: Verify Prerequisites
20
+
21
+ Use `sdd-status` MCP tool to verify:
22
+ - `requirements.generated: true`
23
+ - `requirements.approved: true` (recommended before design)
24
+
25
+ ### Step 2: Review Requirements
26
+
27
+ 1. Read `.spec/specs/{feature}/requirements.md`
28
+ 2. Identify all functional requirements (FR-*)
29
+ 3. Identify all non-functional requirements (NFR-*)
30
+ 4. Note constraints and assumptions
31
+
32
+ ### Step 3: Choose Architecture Pattern
33
+
34
+ Select appropriate patterns based on requirements:
35
+
36
+ | Pattern | Use When | Key Characteristics |
37
+ |---------|----------|---------------------|
38
+ | **Clean Architecture** | Domain-heavy apps | Layers: Domain → Use Cases → Interface → Infrastructure |
39
+ | **MVC/MVP** | Web applications | Model-View-Controller separation |
40
+ | **Microservices** | Distributed systems | Independent deployable services |
41
+ | **Event-Driven** | Async processing | Event producers and consumers |
42
+ | **Hexagonal** | Testable business logic | Ports and Adapters pattern |
43
+
44
+ ### Step 4: Design Components
45
+
46
+ For each component, specify:
47
+
48
+ ```markdown
49
+ ## Component: {ComponentName}
50
+
51
+ **Type:** Service | Controller | Repository | Adapter | Provider
52
+
53
+ **Purpose:** {Single responsibility description}
54
+
55
+ **Responsibilities:**
56
+ - {Responsibility 1}
57
+ - {Responsibility 2}
58
+
59
+ **Interface:**
60
+ ```typescript
61
+ interface I{ComponentName} {
62
+ methodName(input: InputType): Promise<OutputType>;
63
+ }
64
+ ```
65
+
66
+ **Dependencies:**
67
+ - {Dependency 1 via interface}
68
+ - {Dependency 2 via interface}
69
+
70
+ **Error Handling:**
71
+ - {Error scenario 1}: {How to handle}
72
+ ```
73
+
74
+ ### Step 5: Define Data Models
75
+
76
+ ```markdown
77
+ ## Data Models
78
+
79
+ ### Model: {EntityName}
80
+
81
+ **Purpose:** {What this entity represents}
82
+
83
+ | Property | Type | Required | Description | Validation |
84
+ |----------|------|----------|-------------|------------|
85
+ | id | string | Yes | Unique identifier | UUID format |
86
+ | name | string | Yes | Display name | 1-100 chars |
87
+ | createdAt | Date | Yes | Creation timestamp | ISO 8601 |
88
+
89
+ **Relationships:**
90
+ - Has many: {RelatedEntity} (one-to-many)
91
+ - Belongs to: {ParentEntity} (many-to-one)
92
+
93
+ **Invariants:**
94
+ - {Business rule 1}
95
+ - {Business rule 2}
96
+ ```
97
+
98
+ ### Step 6: Specify Interfaces
99
+
100
+ ```markdown
101
+ ## API Interfaces
102
+
103
+ ### REST Endpoints
104
+
105
+ | Method | Path | Description | Request | Response | Auth |
106
+ |--------|------|-------------|---------|----------|------|
107
+ | POST | /api/v1/resource | Create resource | CreateDTO | Resource | Bearer |
108
+ | GET | /api/v1/resource/:id | Get by ID | - | Resource | Bearer |
109
+
110
+ ### Internal Service Interfaces
111
+
112
+ Following Interface Segregation Principle:
113
+
114
+ ```typescript
115
+ // Read operations
116
+ interface IResourceReader {
117
+ getById(id: string): Promise<Resource>;
118
+ list(filter: Filter): Promise<Resource[]>;
119
+ }
120
+
121
+ // Write operations
122
+ interface IResourceWriter {
123
+ create(data: CreateDTO): Promise<Resource>;
124
+ update(id: string, data: UpdateDTO): Promise<Resource>;
125
+ delete(id: string): Promise<void>;
126
+ }
127
+ ```
128
+ ```
129
+
130
+ ### Step 7: Document Error Handling
131
+
132
+ ```markdown
133
+ ## Error Handling Strategy
134
+
135
+ ### Error Categories
136
+
137
+ | Category | HTTP Status | Retry | Log Level |
138
+ |----------|-------------|-------|-----------|
139
+ | Validation | 400 | No | WARN |
140
+ | Not Found | 404 | No | INFO |
141
+ | Conflict | 409 | No | WARN |
142
+ | Rate Limit | 429 | Yes (backoff) | WARN |
143
+ | Internal | 500 | Yes (limited) | ERROR |
144
+
145
+ ### Error Response Format
146
+
147
+ ```json
148
+ {
149
+ "error": {
150
+ "code": "VALIDATION_ERROR",
151
+ "message": "Human-readable message",
152
+ "details": [{ "field": "email", "issue": "Invalid format" }],
153
+ "requestId": "uuid-for-tracing"
154
+ }
155
+ }
156
+ ```
157
+ ```
158
+
159
+ ### Step 8: Apply Linus-Style Quality Review
160
+
161
+ Before finalizing, validate against these principles:
162
+
163
+ #### 1. Taste - Is it elegant?
164
+ - Does the design feel natural and intuitive?
165
+ - Are there unnecessary complications?
166
+
167
+ #### 2. Complexity - Is it simple?
168
+ - Can any component be simplified?
169
+ - Are there too many abstractions?
170
+
171
+ #### 3. Special Cases - Are edge cases handled?
172
+ - What happens at boundaries?
173
+ - How does it fail gracefully?
174
+
175
+ #### 4. Data Structures - Are they optimal?
176
+ - Is the right data structure chosen?
177
+ - Does data flow make sense?
178
+
179
+ #### 5. Code Organization - Is it maintainable?
180
+ - Can new developers understand it?
181
+ - Is it easy to modify?
182
+
183
+ ### Step 9: Save and Validate
184
+
185
+ 1. Save design to `.spec/specs/{feature}/design.md`
186
+ 2. Use `sdd-validate-design` MCP tool for GO/NO-GO review
187
+ 3. If GO, use `sdd-approve design` MCP tool
188
+
189
+ ## Design Document Template
190
+
191
+ ```markdown
192
+ # Design: {Feature Name}
193
+
194
+ ## Overview
195
+ {Brief summary of the design approach}
196
+
197
+ ## Architecture Pattern
198
+ {Selected pattern and rationale}
199
+
200
+ ## Component Diagram
201
+ ```
202
+ [Component A] ──> [Component B]
203
+
204
+ └──> [Component C]
205
+ ```
206
+
207
+ ## Components
208
+
209
+ ### {Component 1}
210
+ {Component details as described above}
211
+
212
+ ## Data Models
213
+
214
+ ### {Entity 1}
215
+ {Model details as described above}
216
+
217
+ ## Interfaces
218
+
219
+ ### External APIs
220
+ {API specifications}
221
+
222
+ ### Internal Interfaces
223
+ {Service interfaces}
224
+
225
+ ## Error Handling
226
+ {Error strategy}
227
+
228
+ ## Security Considerations
229
+ - Authentication: {approach}
230
+ - Authorization: {approach}
231
+ - Data protection: {approach}
232
+
233
+ ## Testing Strategy
234
+ - Unit tests: {coverage target}
235
+ - Integration tests: {scope}
236
+ - E2E tests: {critical paths}
237
+
238
+ ## Dependencies
239
+ - External: {list}
240
+ - Internal: {list}
241
+ ```
242
+
243
+ ## MCP Tool Integration
244
+
245
+ | Tool | When to Use |
246
+ |------|-------------|
247
+ | `sdd-status` | Verify requirements phase complete |
248
+ | `sdd-validate-design` | Perform GO/NO-GO review |
249
+ | `sdd-approve` | Mark design phase as approved |
250
+
251
+ ## Quality Checklist
252
+
253
+ - [ ] All FR-* requirements have corresponding components
254
+ - [ ] All NFR-* requirements have technical solutions
255
+ - [ ] SOLID principles are followed
256
+ - [ ] Interfaces are well-defined (ISP)
257
+ - [ ] Dependencies flow inward (DIP)
258
+ - [ ] Data models are complete with invariants
259
+ - [ ] Error handling strategy is comprehensive
260
+ - [ ] Security considerations are addressed
261
+ - [ ] Testing approach is specified
262
+ - [ ] Linus-style review passed
@@ -0,0 +1,281 @@
1
+ ---
2
+ name: sdd-implement
3
+ description: Implementation guidelines for SDD workflow. Use when implementing features, applying TDD, checking security, or ensuring code quality. Invoked via /sdd-implement <feature-name>.
4
+ ---
5
+
6
+ # SDD Implementation Guidelines
7
+
8
+ Execute implementation following TDD methodology, SOLID principles, and security best practices.
9
+
10
+ ## Prerequisites
11
+
12
+ Before implementing:
13
+ 1. Tasks must be approved (use `sdd-status` to verify)
14
+ 2. Review tasks in `.spec/specs/{feature}/tasks.md`
15
+ 3. Understand the design in `.spec/specs/{feature}/design.md`
16
+
17
+ ## Implementation Workflow
18
+
19
+ ### Step 1: Load Context
20
+
21
+ 1. Use `sdd-status` MCP tool to verify all phases approved
22
+ 2. Read the tasks document for current implementation
23
+ 3. Identify the next task to implement
24
+
25
+ ### Step 2: Execute TDD Cycle
26
+
27
+ For each task:
28
+
29
+ ```
30
+ ┌─────────────────────────────────────────────────────────────┐
31
+ │ 1. RED: Write Failing Test │
32
+ │ - Define expected behavior │
33
+ │ - Run test, confirm it FAILS │
34
+ │ │
35
+ │ 2. GREEN: Write Minimal Code │
36
+ │ - Just enough to pass the test │
37
+ │ - No extra features │
38
+ │ - Run test, confirm it PASSES │
39
+ │ │
40
+ │ 3. REFACTOR: Improve Code │
41
+ │ - Clean up without changing behavior │
42
+ │ - Run tests, confirm still PASSING │
43
+ │ │
44
+ │ REPEAT for each test case │
45
+ └─────────────────────────────────────────────────────────────┘
46
+ ```
47
+
48
+ ### Step 3: Apply SOLID Principles
49
+
50
+ #### S - Single Responsibility Principle
51
+ ```typescript
52
+ // GOOD: One class, one job
53
+ class UserValidator {
54
+ validate(user: User): ValidationResult { ... }
55
+ }
56
+
57
+ class UserRepository {
58
+ save(user: User): Promise<void> { ... }
59
+ }
60
+
61
+ // BAD: Class doing too much
62
+ class UserManager {
63
+ validate(user: User) { ... }
64
+ save(user: User) { ... }
65
+ sendEmail(user: User) { ... }
66
+ generateReport() { ... }
67
+ }
68
+ ```
69
+
70
+ #### O - Open/Closed Principle
71
+ ```typescript
72
+ // GOOD: Open for extension, closed for modification
73
+ interface PaymentProcessor {
74
+ process(amount: number): Promise<Result>;
75
+ }
76
+
77
+ class StripeProcessor implements PaymentProcessor { ... }
78
+ class PayPalProcessor implements PaymentProcessor { ... }
79
+
80
+ // BAD: Modifying existing code for new payment types
81
+ class PaymentService {
82
+ process(type: string, amount: number) {
83
+ if (type === 'stripe') { ... }
84
+ else if (type === 'paypal') { ... }
85
+ // Adding new type requires modifying this class
86
+ }
87
+ }
88
+ ```
89
+
90
+ #### L - Liskov Substitution Principle
91
+ ```typescript
92
+ // GOOD: Subtypes are substitutable
93
+ class Bird {
94
+ move(): void { /* fly or walk */ }
95
+ }
96
+
97
+ class Sparrow extends Bird {
98
+ move(): void { this.fly(); }
99
+ }
100
+
101
+ class Penguin extends Bird {
102
+ move(): void { this.walk(); }
103
+ }
104
+
105
+ // BAD: Subtype breaks expected behavior
106
+ class Bird {
107
+ fly(): void { ... }
108
+ }
109
+
110
+ class Penguin extends Bird {
111
+ fly(): void { throw new Error("Can't fly!"); }
112
+ }
113
+ ```
114
+
115
+ #### I - Interface Segregation Principle
116
+ ```typescript
117
+ // GOOD: Specific interfaces
118
+ interface Readable {
119
+ read(): Data;
120
+ }
121
+
122
+ interface Writable {
123
+ write(data: Data): void;
124
+ }
125
+
126
+ class FileHandler implements Readable, Writable { ... }
127
+ class ReadOnlyFile implements Readable { ... }
128
+
129
+ // BAD: Fat interface forcing unnecessary implementation
130
+ interface FileOperations {
131
+ read(): Data;
132
+ write(data: Data): void;
133
+ delete(): void;
134
+ execute(): void;
135
+ }
136
+ ```
137
+
138
+ #### D - Dependency Inversion Principle
139
+ ```typescript
140
+ // GOOD: Depend on abstractions
141
+ interface IUserRepository {
142
+ findById(id: string): Promise<User>;
143
+ }
144
+
145
+ class UserService {
146
+ constructor(private repo: IUserRepository) {}
147
+ }
148
+
149
+ // BAD: Depend on concrete implementations
150
+ class UserService {
151
+ private repo = new PostgresUserRepository();
152
+ }
153
+ ```
154
+
155
+ ### Step 4: Security Checklist (OWASP Top 10)
156
+
157
+ Before marking implementation complete, verify:
158
+
159
+ #### 1. Broken Access Control
160
+ - [ ] Enforce access control on every request
161
+ - [ ] Deny by default
162
+ - [ ] Validate user owns the resource
163
+
164
+ #### 2. Cryptographic Failures
165
+ - [ ] Use strong encryption (AES-256, RSA-2048+)
166
+ - [ ] Never store passwords in plain text (use bcrypt/argon2)
167
+ - [ ] Use HTTPS for all communications
168
+
169
+ #### 3. Injection
170
+ - [ ] Use parameterized queries for database
171
+ - [ ] Validate and sanitize all user inputs
172
+ - [ ] Escape output in templates
173
+
174
+ #### 4. Insecure Design
175
+ - [ ] Apply threat modeling
176
+ - [ ] Implement defense in depth
177
+ - [ ] Fail securely
178
+
179
+ #### 5. Security Misconfiguration
180
+ - [ ] Remove default credentials
181
+ - [ ] Disable unnecessary features
182
+ - [ ] Keep dependencies updated
183
+
184
+ #### 6. Vulnerable Components
185
+ - [ ] Use dependency audit tools (e.g., `npm audit`, `pip-audit`, `cargo audit`, `snyk`)
186
+ - [ ] Update vulnerable packages
187
+ - [ ] Remove unused dependencies
188
+
189
+ #### 7. Authentication Failures
190
+ - [ ] Implement proper session management
191
+ - [ ] Use MFA where appropriate
192
+ - [ ] Implement account lockout
193
+
194
+ #### 8. Software Integrity
195
+ - [ ] Verify package integrity
196
+ - [ ] Use lockfiles (e.g., `package-lock.json`, `Cargo.lock`, `poetry.lock`, `go.sum`)
197
+ - [ ] Sign commits if required
198
+
199
+ #### 9. Logging & Monitoring
200
+ - [ ] Log security events
201
+ - [ ] Don't log sensitive data
202
+ - [ ] Implement alerting
203
+
204
+ #### 10. SSRF (Server-Side Request Forgery)
205
+ - [ ] Validate and sanitize URLs
206
+ - [ ] Use allowlists for external calls
207
+ - [ ] Disable redirects or validate them
208
+
209
+ ### Step 5: Code Quality Standards
210
+
211
+ #### Naming
212
+ ```typescript
213
+ // GOOD
214
+ const userEmail = user.email;
215
+ function calculateTotalPrice(items: Item[]): number { ... }
216
+
217
+ // BAD
218
+ const e = user.email;
219
+ function calc(i: any): any { ... }
220
+ ```
221
+
222
+ #### Comments
223
+ ```typescript
224
+ // GOOD: Explain WHY, not WHAT
225
+ // Use retry because the external API has rate limits
226
+ const result = await retryWithBackoff(fetchData);
227
+
228
+ // BAD: Obvious comments
229
+ // Get the user
230
+ const user = getUser(id);
231
+ ```
232
+
233
+ #### Error Handling
234
+ ```typescript
235
+ // GOOD: Specific, informative errors
236
+ class UserNotFoundError extends Error {
237
+ constructor(userId: string) {
238
+ super(`User with ID ${userId} not found`);
239
+ this.name = 'UserNotFoundError';
240
+ }
241
+ }
242
+
243
+ // BAD: Generic errors
244
+ throw new Error('Error');
245
+ ```
246
+
247
+ ### Step 6: Update Task Status
248
+
249
+ After implementing each task:
250
+ 1. Mark task as complete in tasks.md
251
+ 2. Verify test coverage >= 80%
252
+ 3. Run `sdd-quality-check` MCP tool on new code
253
+
254
+ ## MCP Tool Integration
255
+
256
+ | Tool | When to Use |
257
+ |------|-------------|
258
+ | `sdd-status` | Check all phases approved before implementing |
259
+ | `sdd-spec-impl` | Execute specific tasks with TDD |
260
+ | `sdd-quality-check` | Validate code quality after implementation |
261
+
262
+ ## Definition of Done
263
+
264
+ - [ ] All acceptance criteria met
265
+ - [ ] All tests pass
266
+ - [ ] Code coverage >= 80%
267
+ - [ ] No lint/type errors
268
+ - [ ] Security checklist verified
269
+ - [ ] SOLID principles applied
270
+ - [ ] Code self-documenting or commented where needed
271
+
272
+ ## Common Anti-Patterns to Avoid
273
+
274
+ | Anti-Pattern | Problem | Solution |
275
+ |--------------|---------|----------|
276
+ | **God Class** | Class does too much | Split by responsibility |
277
+ | **Feature Envy** | Method uses another class's data extensively | Move method to that class |
278
+ | **Primitive Obsession** | Using primitives for domain concepts | Create value objects |
279
+ | **Magic Numbers** | Unexplained numeric literals | Use named constants |
280
+ | **Deep Nesting** | Multiple levels of if/loops | Extract methods, early returns |
281
+ | **Long Methods** | Methods doing too much | Split into smaller methods |
@@ -0,0 +1,140 @@
1
+ ---
2
+ name: sdd-requirements
3
+ description: Generate EARS-formatted requirements for SDD workflow. Use when starting a new feature specification, creating requirements documents, or defining acceptance criteria. Invoked via /sdd-requirements <feature-name>.
4
+ ---
5
+
6
+ # SDD Requirements Generation
7
+
8
+ Generate comprehensive, EARS-formatted requirements documents that integrate with the SDD (Spec-Driven Development) workflow.
9
+
10
+ ## Prerequisites
11
+
12
+ Before generating requirements:
13
+ 1. Feature must be initialized with `sdd-init` MCP tool
14
+ 2. Check current phase with `sdd-status` MCP tool
15
+ 3. Review project steering documents in `.spec/steering/`
16
+
17
+ ## Workflow
18
+
19
+ ### Step 1: Gather Context
20
+
21
+ 1. Use `sdd-status` MCP tool to verify feature exists and check current phase
22
+ 2. Read project context from `.spec/steering/product.md` if available
23
+ 3. Review the feature description from `.spec/specs/{feature}/spec.json`
24
+
25
+ ### Step 2: Analyze Requirements
26
+
27
+ Identify and document:
28
+ - **Primary user goal**: What problem are we solving?
29
+ - **Target users**: Who will use this feature?
30
+ - **Core functionality**: What must the system do?
31
+ - **Success criteria**: How do we know it works?
32
+
33
+ ### Step 3: Generate EARS-Formatted Requirements
34
+
35
+ Use the **EARS (Easy Approach to Requirements Syntax)** format for all requirements.
36
+
37
+ #### EARS Patterns
38
+
39
+ | Pattern | Syntax | Use When |
40
+ |---------|--------|----------|
41
+ | **Ubiquitous** | `The <system> SHALL <action>` | Always true requirement |
42
+ | **Event-Driven** | `WHEN <trigger> THEN the <system> SHALL <action>` | Response to event |
43
+ | **State-Driven** | `WHILE <state> THE <system> SHALL <action>` | During specific state |
44
+ | **Optional** | `WHERE <feature enabled> THE <system> SHALL <action>` | Configurable feature |
45
+ | **Unwanted Behavior** | `IF <condition> THEN the <system> SHALL <action>` | Exception handling |
46
+
47
+ #### Examples
48
+
49
+ ```markdown
50
+ ## FR-1: User Authentication
51
+ WHEN a user submits valid credentials
52
+ THEN the system SHALL authenticate the user and return a session token
53
+
54
+ ## FR-2: Session Management
55
+ WHILE a user session is active
56
+ THE system SHALL maintain the session for up to 24 hours of inactivity
57
+
58
+ ## NFR-1: Performance
59
+ The system SHALL respond to authentication requests within 200ms
60
+ ```
61
+
62
+ ### Step 4: Structure the Document
63
+
64
+ Generate requirements.md with this structure:
65
+
66
+ ```markdown
67
+ # Requirements: {Feature Name}
68
+
69
+ ## Overview
70
+ Brief description of the feature and its purpose.
71
+
72
+ ## Functional Requirements
73
+
74
+ ### FR-1: {Requirement Name}
75
+ **Objective:** As a {user type}, I want {goal}, so that {benefit}
76
+
77
+ **EARS Specification:**
78
+ WHEN {trigger}
79
+ THEN the system SHALL {action}
80
+
81
+ **Acceptance Criteria:**
82
+ 1. {Specific, testable criterion}
83
+ 2. {Specific, testable criterion}
84
+
85
+ ### FR-2: {Next Requirement}
86
+ ...
87
+
88
+ ## Non-Functional Requirements
89
+
90
+ ### NFR-1: Performance
91
+ {Performance requirements with specific metrics}
92
+
93
+ ### NFR-2: Security
94
+ {Security requirements aligned with OWASP guidelines}
95
+
96
+ ### NFR-3: Scalability
97
+ {Scalability requirements if applicable}
98
+
99
+ ## Constraints
100
+ {Technical or business constraints}
101
+
102
+ ## Assumptions
103
+ {Assumptions made during requirements gathering}
104
+ ```
105
+
106
+ ### Step 5: Validate and Save
107
+
108
+ After generating requirements:
109
+ 1. Ensure all requirements are testable
110
+ 2. Verify EARS format is correctly applied
111
+ 3. Save to `.spec/specs/{feature}/requirements.md`
112
+ 4. Use `sdd-approve` MCP tool to mark phase complete when ready
113
+
114
+ ## MCP Tool Integration
115
+
116
+ This skill works with these MCP tools:
117
+
118
+ | Tool | When to Use |
119
+ |------|-------------|
120
+ | `sdd-status` | Check current workflow phase before starting |
121
+ | `sdd-validate-gap` | Validate requirements against existing codebase |
122
+ | `sdd-approve` | Mark requirements phase as approved |
123
+
124
+ ## Quality Checklist
125
+
126
+ Before completing requirements:
127
+ - [ ] All requirements use EARS format
128
+ - [ ] Each requirement is independently testable
129
+ - [ ] Acceptance criteria are specific and measurable
130
+ - [ ] Security requirements align with OWASP Top 10
131
+ - [ ] Performance requirements have specific metrics
132
+ - [ ] Requirements are traceable to user stories
133
+ - [ ] No ambiguous terms (avoid "should", "may", "might")
134
+ - [ ] Each FR has clear acceptance criteria
135
+
136
+ ## Coding Principles Applied
137
+
138
+ - **SOLID**: Single Responsibility - each requirement addresses one concern
139
+ - **KISS**: Keep requirements simple and unambiguous
140
+ - **YAGNI**: Only specify what's actually needed now