sdd-mcp-server 3.5.1 → 5.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.
Files changed (124) hide show
  1. package/README.md +92 -683
  2. package/agents/architect.md +15 -93
  3. package/agents/implementer.md +16 -141
  4. package/agents/planner.md +16 -84
  5. package/agents/reviewer.md +16 -239
  6. package/agents/security-auditor.md +16 -114
  7. package/agents/tdd-guide.md +17 -228
  8. package/dist/adapters/cli/SDDToolAdapter.d.ts +14 -8
  9. package/dist/adapters/cli/SDDToolAdapter.js +188 -405
  10. package/dist/adapters/cli/SDDToolAdapter.js.map +1 -1
  11. package/dist/application/services/ContextCompactionService.d.ts +88 -16
  12. package/dist/application/services/ContextCompactionService.js +474 -187
  13. package/dist/application/services/ContextCompactionService.js.map +1 -1
  14. package/dist/application/services/ProjectService.js +3 -3
  15. package/dist/application/services/ProjectService.js.map +1 -1
  16. package/dist/application/services/SpecPathResolver.d.ts +24 -0
  17. package/dist/application/services/SpecPathResolver.js +70 -0
  18. package/dist/application/services/SpecPathResolver.js.map +1 -0
  19. package/dist/application/services/WorkflowEngineService.d.ts +214 -50
  20. package/dist/application/services/WorkflowEngineService.js +1447 -292
  21. package/dist/application/services/WorkflowEngineService.js.map +1 -1
  22. package/dist/application/services/WorkflowErrors.d.ts +16 -0
  23. package/dist/application/services/WorkflowErrors.js +53 -0
  24. package/dist/application/services/WorkflowErrors.js.map +1 -0
  25. package/dist/application/services/WorkflowValidationService.d.ts +25 -46
  26. package/dist/application/services/WorkflowValidationService.js +284 -627
  27. package/dist/application/services/WorkflowValidationService.js.map +1 -1
  28. package/dist/cli/install-skills.d.ts +3 -9
  29. package/dist/cli/install-skills.js +129 -174
  30. package/dist/cli/install-skills.js.map +1 -1
  31. package/dist/cli/install-target.d.ts +42 -8
  32. package/dist/cli/install-target.js +27 -9
  33. package/dist/cli/install-target.js.map +1 -1
  34. package/dist/cli/sdd-mcp-cli.d.ts +1 -1
  35. package/dist/cli/sdd-mcp-cli.js +7 -6
  36. package/dist/cli/sdd-mcp-cli.js.map +1 -1
  37. package/dist/cli/tool-support/claude-code.js +17 -34
  38. package/dist/cli/tool-support/claude-code.js.map +1 -1
  39. package/dist/cli/tool-support/codex.d.ts +0 -53
  40. package/dist/cli/tool-support/codex.js +10 -94
  41. package/dist/cli/tool-support/codex.js.map +1 -1
  42. package/dist/cli/tool-support/index.d.ts +3 -2
  43. package/dist/cli/tool-support/index.js +3 -1
  44. package/dist/cli/tool-support/index.js.map +1 -1
  45. package/dist/cli/tool-support/mcp-registration.d.ts +22 -0
  46. package/dist/cli/tool-support/mcp-registration.js +275 -0
  47. package/dist/cli/tool-support/mcp-registration.js.map +1 -0
  48. package/dist/cli/tool-support/omp.d.ts +5 -0
  49. package/dist/cli/tool-support/omp.js +47 -0
  50. package/dist/cli/tool-support/omp.js.map +1 -0
  51. package/dist/cli/tool-support/root-guidance.d.ts +2 -9
  52. package/dist/cli/tool-support/root-guidance.js +44 -37
  53. package/dist/cli/tool-support/root-guidance.js.map +1 -1
  54. package/dist/cli/tool-support/target-agent-renderer.d.ts +1 -0
  55. package/dist/cli/tool-support/target-agent-renderer.js +37 -4
  56. package/dist/cli/tool-support/target-agent-renderer.js.map +1 -1
  57. package/dist/cli/tool-support/target-installer.d.ts +9 -3
  58. package/dist/cli/tool-support/target-installer.js +100 -26
  59. package/dist/cli/tool-support/target-installer.js.map +1 -1
  60. package/dist/cli/utils/preserving-writer.d.ts +56 -0
  61. package/dist/cli/utils/preserving-writer.js +603 -10
  62. package/dist/cli/utils/preserving-writer.js.map +1 -1
  63. package/dist/domain/ports.d.ts +4 -0
  64. package/dist/domain/types.d.ts +52 -7
  65. package/dist/domain/types.js +5 -4
  66. package/dist/domain/types.js.map +1 -1
  67. package/dist/index.d.ts +13 -10
  68. package/dist/index.js +16 -1199
  69. package/dist/index.js.map +1 -1
  70. package/dist/infrastructure/adapters/NodeFileSystemAdapter.d.ts +3 -0
  71. package/dist/infrastructure/adapters/NodeFileSystemAdapter.js +10 -0
  72. package/dist/infrastructure/adapters/NodeFileSystemAdapter.js.map +1 -1
  73. package/dist/infrastructure/mcp/CapabilityNegotiator.js +3 -3
  74. package/dist/infrastructure/mcp/CapabilityNegotiator.js.map +1 -1
  75. package/dist/infrastructure/mcp/MCPServer.js +13 -13
  76. package/dist/infrastructure/mcp/MCPServer.js.map +1 -1
  77. package/dist/infrastructure/mcp/ToolRegistry.d.ts +5 -1
  78. package/dist/infrastructure/mcp/ToolRegistry.js +11 -4
  79. package/dist/infrastructure/mcp/ToolRegistry.js.map +1 -1
  80. package/dist/infrastructure/mcp/sddToolDefinitions.d.ts +6 -0
  81. package/dist/infrastructure/mcp/sddToolDefinitions.js +110 -0
  82. package/dist/infrastructure/mcp/sddToolDefinitions.js.map +1 -0
  83. package/dist/infrastructure/schemas/project.schema.d.ts +2 -2
  84. package/dist/infrastructure/schemas/project.schema.js +2 -2
  85. package/dist/infrastructure/schemas/project.schema.js.map +1 -1
  86. package/dist/shared/version.d.ts +3 -0
  87. package/dist/shared/version.js +4 -0
  88. package/dist/shared/version.js.map +1 -0
  89. package/dist/utils/atomicWrite.d.ts +8 -35
  90. package/dist/utils/atomicWrite.js +24 -57
  91. package/dist/utils/atomicWrite.js.map +1 -1
  92. package/dist/utils/withFilesystemLock.d.ts +22 -0
  93. package/dist/utils/withFilesystemLock.js +219 -0
  94. package/dist/utils/withFilesystemLock.js.map +1 -0
  95. package/mcp-server.js +5 -2883
  96. package/package.json +8 -3
  97. package/scripts/context-usage-report.mjs +602 -0
  98. package/sdd-entry.js +17 -6
  99. package/skills/sdd-commit/REFERENCE.md +31 -0
  100. package/skills/sdd-commit/SKILL.md +17 -273
  101. package/skills/sdd-design/REFERENCE.md +51 -0
  102. package/skills/sdd-design/SKILL.md +25 -262
  103. package/skills/sdd-implement/REFERENCE.md +30 -0
  104. package/skills/sdd-implement/SKILL.md +27 -284
  105. package/skills/sdd-requirements/REFERENCE.md +39 -0
  106. package/skills/sdd-requirements/SKILL.md +28 -132
  107. package/skills/sdd-review/REFERENCE.md +26 -0
  108. package/skills/sdd-review/SKILL.md +17 -181
  109. package/skills/sdd-security-check/REFERENCE.md +19 -0
  110. package/skills/sdd-security-check/SKILL.md +18 -184
  111. package/skills/sdd-steering/REFERENCE.md +25 -0
  112. package/skills/sdd-steering/SKILL.md +18 -216
  113. package/skills/sdd-steering-custom/REFERENCE.md +27 -0
  114. package/skills/sdd-steering-custom/SKILL.md +19 -203
  115. package/skills/sdd-tasks/REFERENCE.md +25 -0
  116. package/skills/sdd-tasks/SKILL.md +27 -244
  117. package/skills/sdd-test-gen/REFERENCE.md +15 -0
  118. package/skills/sdd-test-gen/SKILL.md +17 -287
  119. package/skills/simple-task/REFERENCE.md +22 -0
  120. package/skills/simple-task/SKILL.md +17 -138
  121. package/templates/CLAUDE.md +13 -31
  122. package/templates/codex-AGENTS.md +7 -9
  123. package/rules/git-workflow.md +0 -92
  124. package/rules/sdd-workflow.md +0 -116
@@ -0,0 +1,30 @@
1
+ # Implementation Reference
2
+
3
+ Read only when a detailed checklist is needed for the current task.
4
+
5
+ ## Progress Recording Example
6
+
7
+ For a TDD-required task, persist the observed sequence: start; RED with the exact command, non-zero exit code, and failure summary; GREEN with command, zero exit code, and passing summary; final zero-exit verification plus affected project-relative artifacts. If interrupted, status supplies the persisted state and next action; never reconstruct it from conversation history.
8
+
9
+ ## Design Prompts
10
+
11
+ - SRP: does each unit own one reason to change?
12
+ - OCP: is a real extension point needed, or is direct code simpler?
13
+ - LSP: can every subtype preserve the advertised contract?
14
+ - ISP: can consumers depend on a smaller capability?
15
+ - DIP: do policy decisions avoid depending on infrastructure details?
16
+ - Prefer KISS and YAGNI over speculative abstraction; eliminate special cases through better data shape when possible.
17
+
18
+ ## Security Prompts
19
+
20
+ Check only relevant risks, but never skip the analysis: authorization/ownership, validation and canonicalization, parameterized queries and command arguments, output encoding, safe URL handling, cryptographic primitives, secret storage, session state, dependency integrity, error disclosure, and sensitive logging. Default deny at trust boundaries and clean up resources on every failure path.
21
+
22
+ ## Completion Checklist
23
+
24
+ - acceptance criteria have observable tests;
25
+ - RED failure was caused by missing behavior, not broken setup;
26
+ - GREEN and post-refactor focused results were observed;
27
+ - all affected callers and schemas were migrated;
28
+ - concurrency, errors, cancellation, and rollback were considered;
29
+ - no dead compatibility alias, debug output, placeholder, or secret remains;
30
+ - task record names exact evidence rather than estimated coverage.
@@ -1,302 +1,45 @@
1
1
  ---
2
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>.
3
+ description: Implement approved SDD tasks test-first with focused verification and security checks.
4
+ disable-model-invocation: true
4
5
  ---
5
6
 
6
- # SDD Implementation Guidelines
7
+ # SDD Implementation
7
8
 
8
- Execute implementation following TDD methodology, SOLID principles, and security best practices.
9
+ Work inline in the current turn. Do not create a serial implementation specialist. Delegate only when at least two genuinely independent slices can run concurrently. Backend lifecycle calls are internal; never ask the user to operate raw MCP tools.
9
10
 
10
- ## Prerequisites
11
+ ## Restore Durable Progress
11
12
 
12
- Before implementing:
13
- 1. Tasks must be approved (use `sdd-status` to verify)
14
- 2. If the TDD test-case review checkpoint is enabled, test cases must be reviewed first (`sdd-review-test-cases`)
15
- 3. Review tasks in `.spec/specs/{feature}/tasks.md`
16
- 4. Understand the design in `.spec/specs/{feature}/design.md`
13
+ 1. Internally resolve status and load compact implementation context. Requirements, design, tasks, and any required test-case review must be approved.
14
+ 2. If invoked too early or state is blocked, present the persisted blocker and make no workflow or source change.
15
+ 3. Internally begin implementation when status requests it. Otherwise follow the returned next action: continue the exact active task, ask the user to select among resumable candidates, or select only a dependency-ready pending task.
16
+ 4. Read the approved task, acceptance criteria, design interfaces, and relevant steering before editing. Never infer progress from chat or Markdown checkboxes.
17
17
 
18
- ## Implementation Workflow
18
+ If the runtime is unavailable because of host permission, report an actionable reload/trust or policy blocker; never substitute manual backend instructions.
19
19
 
20
- ### Step 1: Load Context
20
+ ## Governed Task Loop
21
21
 
22
- 1. Use `sdd-status` MCP tool to verify all phases approved
23
- 2. Confirm `TDD Test Case Review` is reviewed when that checkpoint appears in status
24
- 3. Read the tasks document for current implementation
25
- 4. Identify the next task to implement
22
+ For each selected task, internally record `start` with the exact implementation revision. Then:
26
23
 
27
- ### Step 2: Execute TDD Cycle
24
+ 1. **RED:** for TDD-required work, write a focused observable test and run it to prove the expected failure. Record the observed command, non-zero exit code, and concise summary before production changes.
25
+ 2. **GREEN:** implement only enough to pass and run the focused test. Record the observed command, zero exit code, and summary.
26
+ 3. **REFACTOR:** simplify without changing behavior; rerun focused verification.
27
+ 4. **COMPLETE:** run final verification. Only after a zero exit code and all acceptance/security checks, record completion with the observed affected project-relative artifacts.
28
28
 
29
- For each task:
29
+ For `not-applicable` TDD tasks, start, implement, verify, then complete with zero-exit verification evidence. If work cannot continue after start, internally record the blocker and reason; do not fabricate evidence. On resume, continue from persisted `in-progress`, `red-observed`, `green-observed`, or `blocked` state without replaying completed transitions. Reread status after every progress record.
30
30
 
31
- ```
32
- ┌─────────────────────────────────────────────────────────────┐
33
- │ 1. RED: Write Failing Test │
34
- │ - Define expected behavior │
35
- │ - Run test, confirm it FAILS │
36
- │ │
37
- │ 2. GREEN: Write Minimal Code │
38
- │ - Just enough to pass the test │
39
- │ - No extra features │
40
- │ - Run test, confirm it PASSES │
41
- │ │
42
- │ 3. REFACTOR: Improve Code │
43
- │ - Clean up without changing behavior │
44
- │ - Run tests, confirm still PASSING │
45
- │ │
46
- │ REPEAT for each test case │
47
- └─────────────────────────────────────────────────────────────┘
48
- ```
31
+ ## Mandatory Checks
49
32
 
50
- ### Step 3: Apply SOLID Principles
33
+ - Preserve approved interfaces and existing conventions; update every affected caller.
34
+ - Test relevant boundaries, errors, invariants, transitions, and precedence—not implementation plumbing.
35
+ - Validate untrusted input, enforce authorization, avoid injection, protect secrets and sensitive logs, and fail safely.
36
+ - Consider concurrency, cleanup, compatibility, cancellation, rollback, and error propagation where applicable.
37
+ - Run only relevant verification while iterating, then all affected checks. Never fabricate test, coverage, lint, or build results.
51
38
 
52
- #### S - Single Responsibility Principle
53
- ```typescript
54
- // GOOD: One class, one job
55
- class UserValidator {
56
- validate(user: User): ValidationResult { ... }
57
- }
39
+ ## Output
58
40
 
59
- class UserRepository {
60
- save(user: User): Promise<void> { ... }
61
- }
41
+ Report persisted task numbers/states, observed affected artifacts, RED/GREEN/final verification evidence, security decisions, next action, and blockers. Do not expose backend JSON or present raw MCP operations as user steps.
62
42
 
63
- // BAD: Class doing too much
64
- class UserManager {
65
- validate(user: User) { ... }
66
- save(user: User) { ... }
67
- sendEmail(user: User) { ... }
68
- generateReport() { ... }
69
- }
70
- ```
43
+ ## Optional Reference
71
44
 
72
- #### O - Open/Closed Principle
73
- ```typescript
74
- // GOOD: Open for extension, closed for modification
75
- interface PaymentProcessor {
76
- process(amount: number): Promise<Result>;
77
- }
78
-
79
- class StripeProcessor implements PaymentProcessor { ... }
80
- class PayPalProcessor implements PaymentProcessor { ... }
81
-
82
- // BAD: Modifying existing code for new payment types
83
- class PaymentService {
84
- process(type: string, amount: number) {
85
- if (type === 'stripe') { ... }
86
- else if (type === 'paypal') { ... }
87
- // Adding new type requires modifying this class
88
- }
89
- }
90
- ```
91
-
92
- #### L - Liskov Substitution Principle
93
- ```typescript
94
- // GOOD: Subtypes are substitutable
95
- class Bird {
96
- move(): void { /* fly or walk */ }
97
- }
98
-
99
- class Sparrow extends Bird {
100
- move(): void { this.fly(); }
101
- }
102
-
103
- class Penguin extends Bird {
104
- move(): void { this.walk(); }
105
- }
106
-
107
- // BAD: Subtype breaks expected behavior
108
- class Bird {
109
- fly(): void { ... }
110
- }
111
-
112
- class Penguin extends Bird {
113
- fly(): void { throw new Error("Can't fly!"); }
114
- }
115
- ```
116
-
117
- #### I - Interface Segregation Principle
118
- ```typescript
119
- // GOOD: Specific interfaces
120
- interface Readable {
121
- read(): Data;
122
- }
123
-
124
- interface Writable {
125
- write(data: Data): void;
126
- }
127
-
128
- class FileHandler implements Readable, Writable { ... }
129
- class ReadOnlyFile implements Readable { ... }
130
-
131
- // BAD: Fat interface forcing unnecessary implementation
132
- interface FileOperations {
133
- read(): Data;
134
- write(data: Data): void;
135
- delete(): void;
136
- execute(): void;
137
- }
138
- ```
139
-
140
- #### D - Dependency Inversion Principle
141
- ```typescript
142
- // GOOD: Depend on abstractions
143
- interface IUserRepository {
144
- findById(id: string): Promise<User>;
145
- }
146
-
147
- class UserService {
148
- constructor(private repo: IUserRepository) {}
149
- }
150
-
151
- // BAD: Depend on concrete implementations
152
- class UserService {
153
- private repo = new PostgresUserRepository();
154
- }
155
- ```
156
-
157
- ### Step 4: Security Checklist (OWASP Top 10)
158
-
159
- Before marking implementation complete, verify:
160
-
161
- #### 1. Broken Access Control
162
- - [ ] Enforce access control on every request
163
- - [ ] Deny by default
164
- - [ ] Validate user owns the resource
165
-
166
- #### 2. Cryptographic Failures
167
- - [ ] Use strong encryption (AES-256, RSA-2048+)
168
- - [ ] Never store passwords in plain text (use bcrypt/argon2)
169
- - [ ] Use HTTPS for all communications
170
-
171
- #### 3. Injection
172
- - [ ] Use parameterized queries for database
173
- - [ ] Validate and sanitize all user inputs
174
- - [ ] Escape output in templates
175
-
176
- #### 4. Insecure Design
177
- - [ ] Apply threat modeling
178
- - [ ] Implement defense in depth
179
- - [ ] Fail securely
180
-
181
- #### 5. Security Misconfiguration
182
- - [ ] Remove default credentials
183
- - [ ] Disable unnecessary features
184
- - [ ] Keep dependencies updated
185
-
186
- #### 6. Vulnerable Components
187
- - [ ] Use dependency audit tools (e.g., `npm audit`, `pip-audit`, `cargo audit`, `snyk`)
188
- - [ ] Update vulnerable packages
189
- - [ ] Remove unused dependencies
190
-
191
- #### 7. Authentication Failures
192
- - [ ] Implement proper session management
193
- - [ ] Use MFA where appropriate
194
- - [ ] Implement account lockout
195
-
196
- #### 8. Software Integrity
197
- - [ ] Verify package integrity
198
- - [ ] Use lockfiles (e.g., `package-lock.json`, `Cargo.lock`, `poetry.lock`, `go.sum`)
199
- - [ ] Sign commits if required
200
-
201
- #### 9. Logging & Monitoring
202
- - [ ] Log security events
203
- - [ ] Don't log sensitive data
204
- - [ ] Implement alerting
205
-
206
- #### 10. SSRF (Server-Side Request Forgery)
207
- - [ ] Validate and sanitize URLs
208
- - [ ] Use allowlists for external calls
209
- - [ ] Disable redirects or validate them
210
-
211
- ### Step 5: Code Quality Standards
212
-
213
- #### Naming
214
- ```typescript
215
- // GOOD
216
- const userEmail = user.email;
217
- function calculateTotalPrice(items: Item[]): number { ... }
218
-
219
- // BAD
220
- const e = user.email;
221
- function calc(i: any): any { ... }
222
- ```
223
-
224
- #### Comments
225
- ```typescript
226
- // GOOD: Explain WHY, not WHAT
227
- // Use retry because the external API has rate limits
228
- const result = await retryWithBackoff(fetchData);
229
-
230
- // BAD: Obvious comments
231
- // Get the user
232
- const user = getUser(id);
233
- ```
234
-
235
- #### Error Handling
236
- ```typescript
237
- // GOOD: Specific, informative errors
238
- class UserNotFoundError extends Error {
239
- constructor(userId: string) {
240
- super(`User with ID ${userId} not found`);
241
- this.name = 'UserNotFoundError';
242
- }
243
- }
244
-
245
- // BAD: Generic errors
246
- throw new Error('Error');
247
- ```
248
-
249
- ### Step 6: Update Task Status
250
-
251
- After implementing each task:
252
- 1. Mark task as complete in tasks.md
253
- 2. Verify test coverage >= 80%
254
- 3. Run `sdd-quality-check` MCP tool on new code
255
-
256
- ## MCP Tool Integration
257
-
258
- | Tool | When to Use |
259
- |------|-------------|
260
- | `sdd-status` | Check all phases approved before implementing |
261
- | `sdd-spec-impl` | Execute specific tasks with TDD |
262
- | `sdd-quality-check` | Validate code quality after implementation |
263
-
264
- ## Definition of Done
265
-
266
- - [ ] All acceptance criteria met
267
- - [ ] All tests pass
268
- - [ ] Code coverage >= 80%
269
- - [ ] No lint/type errors
270
- - [ ] Security checklist verified
271
- - [ ] SOLID principles applied
272
- - [ ] Code self-documenting or commented where needed
273
-
274
- ## Steering Document References
275
-
276
- Apply these steering documents during implementation:
277
-
278
- | Document | Purpose | Key Application |
279
- |----------|---------|-----------------|
280
- | `.spec/steering/tdd-guideline.md` | Test-Driven Development | Follow Red-Green-Refactor cycle for all code |
281
- | `.spec/steering/principles.md` | SOLID, DRY, KISS, YAGNI | Apply SOLID principles, keep code simple and focused |
282
- | `.spec/steering/owasp-top10-check.md` | Security checklist | Verify all OWASP Top 10 security requirements before completion |
283
-
284
- **Critical Implementation Rules:**
285
- 1. **TDD First**: Never write production code without a failing test
286
- 2. **SOLID Always**: Apply all five principles (SRP, OCP, LSP, ISP, DIP)
287
- 3. **Security Required**: Complete OWASP checklist before marking done
288
-
289
- ## Common Anti-Patterns to Avoid
290
-
291
- | Anti-Pattern | Problem | Solution |
292
- |--------------|---------|----------|
293
- | **God Class** | Class does too much | Split by responsibility |
294
- | **Feature Envy** | Method uses another class's data extensively | Move method to that class |
295
- | **Primitive Obsession** | Using primitives for domain concepts | Create value objects |
296
- | **Magic Numbers** | Unexplained numeric literals | Use named constants |
297
- | **Deep Nesting** | Multiple levels of if/loops | Extract methods, early returns |
298
- | **Long Methods** | Methods doing too much | Split into smaller methods |
299
-
300
- ## Specialist Delegation
301
-
302
- When the host supports subagents, delegate implementation slices to the `implementer` role with a compact handoff containing only the approved task, acceptance criteria, relevant interfaces, and focused test command. Wait for the specialist and then integrate its result before advancing task status. If specialist delegation is unavailable, state the fallback and continue in the current agent.
45
+ Read [REFERENCE.md](REFERENCE.md) only when detailed progress examples, SOLID, OWASP, anti-pattern, or completion checklists are needed.
@@ -0,0 +1,39 @@
1
+ # Requirements Reference
2
+
3
+ Read only for examples or document formatting.
4
+
5
+ ## EARS Examples
6
+
7
+ ```text
8
+ The service SHALL reject an absolute feature name.
9
+ WHEN a valid approval request is committed THEN the service SHALL publish the derived handoff.
10
+ WHILE a phase is unapproved THE service SHALL exclude its draft from compact context.
11
+ WHERE test-case review is enabled THE service SHALL require review before tasks approval.
12
+ IF handoff publication fails after approval THEN the service SHALL retain the approved state and report pending regeneration.
13
+ ```
14
+
15
+ ## Exact Document Shape
16
+
17
+ ```markdown
18
+ # Requirements: Feature
19
+
20
+ ## Functional Requirements
21
+
22
+ ### FR-1: Observable outcome
23
+ **Objective:** Why this behavior matters.
24
+ **EARS Specification:** WHEN an event occurs THEN the system SHALL produce an observable result.
25
+ **Acceptance Criteria:**
26
+ 1. A measurable result is observed.
27
+
28
+ ## Non-functional Requirements
29
+
30
+ ### NFR-1: Bounded quality
31
+ **Objective:** The quality attribute and stakeholder value.
32
+ **EARS Specification:** The system SHALL satisfy a measurable bound.
33
+ **Acceptance Criteria:**
34
+ 1. The bound is verified under stated conditions.
35
+ ```
36
+
37
+ ## Quality Checklist
38
+
39
+ Each requirement has one concern, a stable ID, normative SHALL wording, measurable bounds, positive and failure behavior, and acceptance criteria that do not prescribe incidental implementation. Requirements do not conflict, duplicate one another, hide an undefined actor, or depend on ambiguous timing. Security and compatibility requirements identify an asset or existing contract rather than repeating a generic checklist.
@@ -1,151 +1,47 @@
1
1
  ---
2
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>.
3
+ description: Generate testable EARS requirements and measurable acceptance criteria for an SDD feature.
4
+ disable-model-invocation: true
4
5
  ---
5
6
 
6
- # SDD Requirements Generation
7
+ # SDD Requirements
7
8
 
8
- Generate comprehensive, EARS-formatted requirements documents that integrate with the SDD (Spec-Driven Development) workflow.
9
+ The user invokes this Skill; all MCP calls below are internal. Never ask the user to call a backend tool or expose revision, hash, fingerprint, or backend JSON except in explicit debug output.
9
10
 
10
- ## Prerequisites
11
+ ## Resolve and Restore
11
12
 
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/`
13
+ 1. Internally read status before doing method work.
14
+ 2. With a supplied missing feature, internally initialize it from the user's name and complete goal. If clarification is required, present the structured questions, collect answers, and retry initialization. Use the returned canonical feature name.
15
+ 3. With no supplied name: ask for a name and goal when no feature exists; resume the sole incomplete feature; when several are incomplete, list them and ask the user to select. Never infer identity from process memory.
16
+ 4. Load compact approved context. For a failed or unapproved requirements revision, load that draft only with full mode and explicit unapproved inclusion.
17
+ 5. If status reports an observed artifact identity for an orphan or manual edit, read that exact requirements file before revising. Never acknowledge its hash without inspecting and deliberately incorporating or replacing its content.
16
18
 
17
- ## Workflow
19
+ If durable state reports a conflict or host permission failure, present an actionable blocker and make no artifact change.
18
20
 
19
- ### Step 1: Gather Context
21
+ ## Method and Artifact Contract
20
22
 
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`
23
+ 1. Identify users, goals, scope, exclusions, constraints, assumptions, dependencies, and measurable success.
24
+ 2. Write independently testable EARS requirements. Every requirement uses a unique `### FR-N: ...` or `### NFR-N: ...` section and same-line metadata labels:
25
+ - `**Objective:** ...`
26
+ - `**EARS Specification:** ... SHALL ...`
27
+ - `**Acceptance Criteria:** 1. ...` with at least one numbered item on the same line.
28
+ 3. Replace ambiguous words with observable bounds. Include security, privacy, accessibility, compatibility, errors, and performance only when relevant.
29
+ 4. Check completeness, consistency, feasibility, traceability, and testability; run gap analysis internally when existing code is in scope.
24
30
 
25
- ### Step 2: Analyze Requirements
31
+ Internally submit the complete Markdown with the exact revision and artifact identity last observed. Submission, not direct file editing, is the canonical write. Present the saved path and a concise validation result. A failed validation is a durable draft: revise it using the observed draft content and identity; do not request approval.
26
32
 
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?
33
+ ## Human Gate
32
34
 
33
- ### Step 3: Generate EARS-Formatted Requirements
35
+ When validation passes, ask one explicit question: **“Approve these requirements?”** Only an unambiguous affirmative answer in this Skill flow permits the internal approval call for the exact reviewed revision and artifact. Never self-approve or treat host tool permission as approval. After approval, reread status and report the persisted outcome.
34
36
 
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
- ## Steering Document References
37
+ ## Specialist Delegation
137
38
 
138
- Apply these steering documents during requirements generation:
39
+ Target renderers provide the `planner` route. When a native advisor is required, dispatch exactly one compact handoff with `specialistDepth: 1`; include only the goal, verified context, constraints, open decisions, and output contract. The specialist must not delegate again. Keep the handoff and returned summary at or below 2,048 estimated tokens. If unavailable, record one fallback and continue in the parent without retrying or selecting a generic child.
139
40
 
140
- | Document | Purpose | Key Application |
141
- |----------|---------|-----------------|
142
- | `.spec/steering/principles.md` | SOLID, DRY, KISS, YAGNI | Ensure requirements follow KISS (simple, unambiguous) and YAGNI (only what's needed now) |
41
+ ## Output
143
42
 
144
- **Key Principles for Requirements:**
145
- - **KISS**: Keep requirements simple and unambiguous
146
- - **YAGNI**: Only specify what's actually needed now
147
- - **Single Responsibility**: Each requirement addresses one concern
43
+ Return the canonical saved path, key scope decisions, concise validation evidence, the approval question or persisted approval, and durable blockers. Do not present raw MCP operations as next steps.
148
44
 
149
- ## Specialist Delegation
45
+ ## Optional Reference
150
46
 
151
- When the host supports subagents, delegate this phase to the `planner` role with a compact handoff containing only the feature goal, approved context, constraints, and required deliverable. Wait for the specialist and then integrate its result into the current workflow. If specialist delegation is unavailable, state the fallback and continue in the current agent.
47
+ Read [REFERENCE.md](REFERENCE.md) only for EARS examples, exact document shape, or the extended quality checklist.
@@ -0,0 +1,26 @@
1
+ # Review Reference
2
+
3
+ Read only when the focused review needs extra prompts.
4
+
5
+ ## Severity
6
+
7
+ - Critical: exploitable security flaw, corruption, irreversible data loss, or broad outage.
8
+ - Important: reproducible incorrect behavior, regression, race, leak, or contract break.
9
+ - Minor: concrete maintenance cost likely to cause future defects.
10
+ - Suggestion: optional preference; omit it unless specifically requested.
11
+
12
+ ## Language-independent Prompts
13
+
14
+ Check ownership and mutation, null/empty/boundary behavior, ordering and precedence, async cancellation, retries and idempotency, resource cleanup, error identity, public API compatibility, serialization, time zones, numeric overflow, and deterministic tests.
15
+
16
+ ## Finding Shape
17
+
18
+ ```text
19
+ [severity] path:line — concise defect
20
+ Trigger: exact input/state/interleaving
21
+ Impact: observable consequence
22
+ Evidence: code path or focused reproduction
23
+ Fix: smallest source-level remedy
24
+ ```
25
+
26
+ Review tests for missing contracts, not line coverage. Reject tests that only mirror implementation, inspect source text, rely on timing sleeps, share state, or swallow real errors. End with verification actually performed and explicit residual risk.