opencode-metis 0.1.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 (156) hide show
  1. package/README.md +140 -0
  2. package/dist/cli.cjs +63 -0
  3. package/dist/mcp-server.cjs +51 -0
  4. package/dist/plugin.cjs +4 -0
  5. package/dist/worker.cjs +224 -0
  6. package/opencode/agent/the-analyst/feature-prioritization.md +66 -0
  7. package/opencode/agent/the-analyst/market-research.md +77 -0
  8. package/opencode/agent/the-analyst/project-coordination.md +81 -0
  9. package/opencode/agent/the-analyst/requirements-analysis.md +77 -0
  10. package/opencode/agent/the-architect/compatibility-review.md +138 -0
  11. package/opencode/agent/the-architect/complexity-review.md +137 -0
  12. package/opencode/agent/the-architect/quality-review.md +67 -0
  13. package/opencode/agent/the-architect/security-review.md +127 -0
  14. package/opencode/agent/the-architect/system-architecture.md +119 -0
  15. package/opencode/agent/the-architect/system-documentation.md +83 -0
  16. package/opencode/agent/the-architect/technology-research.md +85 -0
  17. package/opencode/agent/the-chief.md +79 -0
  18. package/opencode/agent/the-designer/accessibility-implementation.md +101 -0
  19. package/opencode/agent/the-designer/design-foundation.md +74 -0
  20. package/opencode/agent/the-designer/interaction-architecture.md +75 -0
  21. package/opencode/agent/the-designer/user-research.md +70 -0
  22. package/opencode/agent/the-meta-agent.md +155 -0
  23. package/opencode/agent/the-platform-engineer/ci-cd-pipelines.md +109 -0
  24. package/opencode/agent/the-platform-engineer/containerization.md +106 -0
  25. package/opencode/agent/the-platform-engineer/data-architecture.md +81 -0
  26. package/opencode/agent/the-platform-engineer/dependency-review.md +144 -0
  27. package/opencode/agent/the-platform-engineer/deployment-automation.md +81 -0
  28. package/opencode/agent/the-platform-engineer/infrastructure-as-code.md +107 -0
  29. package/opencode/agent/the-platform-engineer/performance-tuning.md +82 -0
  30. package/opencode/agent/the-platform-engineer/pipeline-engineering.md +81 -0
  31. package/opencode/agent/the-platform-engineer/production-monitoring.md +105 -0
  32. package/opencode/agent/the-qa-engineer/exploratory-testing.md +66 -0
  33. package/opencode/agent/the-qa-engineer/performance-testing.md +81 -0
  34. package/opencode/agent/the-qa-engineer/quality-assurance.md +77 -0
  35. package/opencode/agent/the-qa-engineer/test-execution.md +66 -0
  36. package/opencode/agent/the-software-engineer/api-development.md +78 -0
  37. package/opencode/agent/the-software-engineer/component-development.md +79 -0
  38. package/opencode/agent/the-software-engineer/concurrency-review.md +141 -0
  39. package/opencode/agent/the-software-engineer/domain-modeling.md +66 -0
  40. package/opencode/agent/the-software-engineer/performance-optimization.md +113 -0
  41. package/opencode/command/analyze.md +149 -0
  42. package/opencode/command/constitution.md +178 -0
  43. package/opencode/command/debug.md +194 -0
  44. package/opencode/command/document.md +178 -0
  45. package/opencode/command/implement.md +225 -0
  46. package/opencode/command/refactor.md +207 -0
  47. package/opencode/command/review.md +229 -0
  48. package/opencode/command/simplify.md +267 -0
  49. package/opencode/command/specify.md +191 -0
  50. package/opencode/command/validate.md +224 -0
  51. package/opencode/skill/accessibility-design/SKILL.md +566 -0
  52. package/opencode/skill/accessibility-design/checklists/wcag-checklist.md +435 -0
  53. package/opencode/skill/agent-coordination/SKILL.md +224 -0
  54. package/opencode/skill/api-contract-design/SKILL.md +550 -0
  55. package/opencode/skill/api-contract-design/templates/graphql-schema-template.md +818 -0
  56. package/opencode/skill/api-contract-design/templates/rest-api-template.md +417 -0
  57. package/opencode/skill/architecture-design/SKILL.md +160 -0
  58. package/opencode/skill/architecture-design/examples/architecture-examples.md +170 -0
  59. package/opencode/skill/architecture-design/template.md +749 -0
  60. package/opencode/skill/architecture-design/validation.md +99 -0
  61. package/opencode/skill/architecture-selection/SKILL.md +522 -0
  62. package/opencode/skill/architecture-selection/examples/adrs/001-example-adr.md +71 -0
  63. package/opencode/skill/architecture-selection/examples/architecture-patterns.md +239 -0
  64. package/opencode/skill/bug-diagnosis/SKILL.md +235 -0
  65. package/opencode/skill/code-quality-review/SKILL.md +337 -0
  66. package/opencode/skill/code-quality-review/examples/anti-patterns.md +629 -0
  67. package/opencode/skill/code-quality-review/reference.md +322 -0
  68. package/opencode/skill/code-review/SKILL.md +363 -0
  69. package/opencode/skill/code-review/reference.md +450 -0
  70. package/opencode/skill/codebase-analysis/SKILL.md +139 -0
  71. package/opencode/skill/codebase-navigation/SKILL.md +227 -0
  72. package/opencode/skill/codebase-navigation/examples/exploration-patterns.md +263 -0
  73. package/opencode/skill/coding-conventions/SKILL.md +178 -0
  74. package/opencode/skill/coding-conventions/checklists/accessibility-checklist.md +176 -0
  75. package/opencode/skill/coding-conventions/checklists/performance-checklist.md +154 -0
  76. package/opencode/skill/coding-conventions/checklists/security-checklist.md +127 -0
  77. package/opencode/skill/constitution-validation/SKILL.md +315 -0
  78. package/opencode/skill/constitution-validation/examples/CONSTITUTION.md +202 -0
  79. package/opencode/skill/constitution-validation/reference/rule-patterns.md +328 -0
  80. package/opencode/skill/constitution-validation/template.md +115 -0
  81. package/opencode/skill/context-preservation/SKILL.md +445 -0
  82. package/opencode/skill/data-modeling/SKILL.md +385 -0
  83. package/opencode/skill/data-modeling/templates/schema-design-template.md +268 -0
  84. package/opencode/skill/deployment-pipeline-design/SKILL.md +579 -0
  85. package/opencode/skill/deployment-pipeline-design/templates/pipeline-template.md +633 -0
  86. package/opencode/skill/documentation-extraction/SKILL.md +259 -0
  87. package/opencode/skill/documentation-sync/SKILL.md +431 -0
  88. package/opencode/skill/domain-driven-design/SKILL.md +509 -0
  89. package/opencode/skill/domain-driven-design/examples/ddd-patterns.md +688 -0
  90. package/opencode/skill/domain-driven-design/reference.md +465 -0
  91. package/opencode/skill/drift-detection/SKILL.md +383 -0
  92. package/opencode/skill/drift-detection/reference.md +340 -0
  93. package/opencode/skill/error-recovery/SKILL.md +162 -0
  94. package/opencode/skill/error-recovery/examples/error-patterns.md +484 -0
  95. package/opencode/skill/feature-prioritization/SKILL.md +419 -0
  96. package/opencode/skill/feature-prioritization/examples/rice-template.md +139 -0
  97. package/opencode/skill/feature-prioritization/reference.md +256 -0
  98. package/opencode/skill/git-workflow/SKILL.md +453 -0
  99. package/opencode/skill/implementation-planning/SKILL.md +215 -0
  100. package/opencode/skill/implementation-planning/examples/phase-examples.md +217 -0
  101. package/opencode/skill/implementation-planning/template.md +220 -0
  102. package/opencode/skill/implementation-planning/validation.md +88 -0
  103. package/opencode/skill/implementation-verification/SKILL.md +272 -0
  104. package/opencode/skill/knowledge-capture/SKILL.md +265 -0
  105. package/opencode/skill/knowledge-capture/reference/knowledge-capture.md +402 -0
  106. package/opencode/skill/knowledge-capture/reference.md +444 -0
  107. package/opencode/skill/knowledge-capture/templates/domain-template.md +325 -0
  108. package/opencode/skill/knowledge-capture/templates/interface-template.md +255 -0
  109. package/opencode/skill/knowledge-capture/templates/pattern-template.md +144 -0
  110. package/opencode/skill/observability-design/SKILL.md +291 -0
  111. package/opencode/skill/observability-design/references/monitoring-patterns.md +461 -0
  112. package/opencode/skill/pattern-detection/SKILL.md +171 -0
  113. package/opencode/skill/pattern-detection/examples/common-patterns.md +359 -0
  114. package/opencode/skill/performance-analysis/SKILL.md +266 -0
  115. package/opencode/skill/performance-analysis/references/profiling-tools.md +499 -0
  116. package/opencode/skill/requirements-analysis/SKILL.md +139 -0
  117. package/opencode/skill/requirements-analysis/examples/good-prd.md +66 -0
  118. package/opencode/skill/requirements-analysis/template.md +177 -0
  119. package/opencode/skill/requirements-analysis/validation.md +69 -0
  120. package/opencode/skill/requirements-elicitation/SKILL.md +518 -0
  121. package/opencode/skill/requirements-elicitation/examples/interview-questions.md +226 -0
  122. package/opencode/skill/requirements-elicitation/examples/user-stories.md +414 -0
  123. package/opencode/skill/safe-refactoring/SKILL.md +312 -0
  124. package/opencode/skill/safe-refactoring/reference/code-smells.md +347 -0
  125. package/opencode/skill/security-assessment/SKILL.md +421 -0
  126. package/opencode/skill/security-assessment/checklists/security-review-checklist.md +285 -0
  127. package/opencode/skill/specification-management/SKILL.md +143 -0
  128. package/opencode/skill/specification-management/readme-template.md +32 -0
  129. package/opencode/skill/specification-management/reference.md +115 -0
  130. package/opencode/skill/specification-management/spec.py +229 -0
  131. package/opencode/skill/specification-validation/SKILL.md +397 -0
  132. package/opencode/skill/specification-validation/reference/3cs-framework.md +306 -0
  133. package/opencode/skill/specification-validation/reference/ambiguity-detection.md +132 -0
  134. package/opencode/skill/specification-validation/reference/constitution-validation.md +301 -0
  135. package/opencode/skill/specification-validation/reference/drift-detection.md +383 -0
  136. package/opencode/skill/task-delegation/SKILL.md +607 -0
  137. package/opencode/skill/task-delegation/examples/file-coordination.md +495 -0
  138. package/opencode/skill/task-delegation/examples/parallel-research.md +337 -0
  139. package/opencode/skill/task-delegation/examples/sequential-build.md +504 -0
  140. package/opencode/skill/task-delegation/reference.md +825 -0
  141. package/opencode/skill/tech-stack-detection/SKILL.md +89 -0
  142. package/opencode/skill/tech-stack-detection/references/framework-signatures.md +598 -0
  143. package/opencode/skill/technical-writing/SKILL.md +190 -0
  144. package/opencode/skill/technical-writing/templates/adr-template.md +205 -0
  145. package/opencode/skill/technical-writing/templates/system-doc-template.md +380 -0
  146. package/opencode/skill/test-design/SKILL.md +464 -0
  147. package/opencode/skill/test-design/examples/test-pyramid.md +724 -0
  148. package/opencode/skill/testing/SKILL.md +213 -0
  149. package/opencode/skill/testing/examples/test-pyramid.md +724 -0
  150. package/opencode/skill/user-insight-synthesis/SKILL.md +576 -0
  151. package/opencode/skill/user-insight-synthesis/templates/research-plan-template.md +217 -0
  152. package/opencode/skill/user-research/SKILL.md +508 -0
  153. package/opencode/skill/user-research/examples/interview-questions.md +265 -0
  154. package/opencode/skill/user-research/examples/personas.md +267 -0
  155. package/opencode/skill/vibe-security/SKILL.md +654 -0
  156. package/package.json +45 -0
@@ -0,0 +1,749 @@
1
+ ---
2
+ title: "[NEEDS CLARIFICATION: Feature title]"
3
+ status: draft
4
+ version: "1.0"
5
+ ---
6
+
7
+ # Solution Design Document
8
+
9
+ ## Validation Checklist
10
+
11
+ ### CRITICAL GATES (Must Pass)
12
+
13
+ - [ ] All required sections are complete
14
+ - [ ] No [NEEDS CLARIFICATION] markers remain
15
+ - [ ] Architecture pattern is clearly stated with rationale
16
+ - [ ] **All architecture decisions confirmed by user**
17
+ - [ ] Every interface has specification
18
+
19
+ ### QUALITY CHECKS (Should Pass)
20
+
21
+ - [ ] All context sources are listed with relevance ratings
22
+ - [ ] Project commands are discovered from actual project files
23
+ - [ ] Constraints → Strategy → Design → Implementation path is logical
24
+ - [ ] Every component in diagram has directory mapping
25
+ - [ ] Error handling covers all error types
26
+ - [ ] Quality requirements are specific and measurable
27
+ - [ ] Component names consistent across diagrams
28
+ - [ ] A developer could implement from this design
29
+ - [ ] Implementation examples use actual schema column names (not pseudocode), verified against migration files
30
+ - [ ] Complex queries include traced walkthroughs with example data showing how the logic evaluates
31
+
32
+ ---
33
+
34
+ ## Constraints
35
+
36
+ [NEEDS CLARIFICATION: What constraints limit the solution space?]
37
+
38
+ CON-1 [Language/framework requirements, performance targets, browser support]
39
+ CON-2 [Coding standards, deployment restrictions, team capabilities]
40
+ CON-3 [Auth requirements, data protection needs, regulatory compliance]
41
+
42
+ ## Implementation Context
43
+
44
+ **IMPORTANT**: You MUST read and analyze ALL listed context sources to understand constraints, patterns, and existing architecture.
45
+
46
+ ### Required Context Sources
47
+
48
+ [NEEDS CLARIFICATION: What documentation, patterns, and external resources apply?]
49
+
50
+ #### Documentation Context
51
+ ```yaml
52
+ # Internal documentation and patterns
53
+ - doc: docs/patterns/pattern-name.md
54
+ relevance: HIGH
55
+ why: "Existing pattern that must be followed"
56
+
57
+ - doc: docs/interfaces/interface-name.md
58
+ relevance: MEDIUM
59
+ why: "External service integration requirements"
60
+
61
+ # External documentation and APIs (if applicable)
62
+ - url: https://docs.library.com/api
63
+ relevance: MEDIUM
64
+ why: "Third-party API constraints"
65
+ ```
66
+
67
+ #### Code Context
68
+ ```yaml
69
+ # Source code files that must be understood
70
+ - file: src/components/placeholder/example.tsx
71
+ relevance: HIGH
72
+ why: "Explanation of why this file matters"
73
+
74
+ - file: @package.json
75
+ relevance: MEDIUM
76
+ why: "Dependencies and build scripts"
77
+ ```
78
+
79
+ #### External APIs (if applicable)
80
+ ```yaml
81
+ # Third-party services this feature integrates with
82
+ - service: [Service Name]
83
+ doc: [URL or internal reference]
84
+ relevance: [HIGH/MEDIUM/LOW]
85
+ why: "[Integration requirements]"
86
+ ```
87
+
88
+ ### Implementation Boundaries
89
+
90
+ [NEEDS CLARIFICATION: What are the boundaries for this implementation?]
91
+ - **Must Preserve**: [Critical behavior/interfaces to maintain]
92
+ - **Can Modify**: [Areas open for refactoring]
93
+ - **Must Not Touch**: [Files/systems that are off-limits]
94
+
95
+ ### External Interfaces
96
+
97
+ [NEEDS CLARIFICATION: What are all the external communication partners and system boundaries?]
98
+
99
+ #### System Context Diagram
100
+
101
+ ```mermaid
102
+ graph TB
103
+ System[Your System]
104
+
105
+ User1[User Type 1] --> System
106
+ User2[User Type 2] --> System
107
+
108
+ System --> ExtAPI1[External API 1]
109
+ System --> ExtAPI2[External Service 2]
110
+
111
+ ExtSystem[External System] --> System
112
+ System --> Database[(Database)]
113
+ System --> MessageQueue[Message Queue]
114
+ ```
115
+
116
+ #### Interface Specifications
117
+
118
+ ```yaml
119
+ # Inbound Interfaces (what calls this system)
120
+ inbound:
121
+ - name: "User Web Interface"
122
+ type: HTTP/HTTPS
123
+ format: REST/GraphQL
124
+ authentication: [OAuth2/JWT/Session]
125
+ doc: @docs/interfaces/web-api.md
126
+ data_flow: "User actions and queries"
127
+
128
+ - name: "Mobile App API"
129
+ type: HTTPS
130
+ format: REST
131
+ authentication: JWT
132
+ doc: @docs/interfaces/mobile-api.md
133
+ data_flow: "Mobile-specific operations"
134
+
135
+ - name: "Webhook Receiver"
136
+ type: HTTPS
137
+ format: JSON
138
+ authentication: HMAC signature
139
+ doc: @docs/interfaces/webhook-spec.md
140
+ data_flow: "Event notifications from external systems"
141
+
142
+ # Outbound Interfaces (what this system calls)
143
+ outbound:
144
+ - name: "Payment Gateway"
145
+ type: HTTPS
146
+ format: REST
147
+ authentication: API Key
148
+ doc: @docs/interfaces/payment-gateway.md
149
+ data_flow: "Transaction processing"
150
+ criticality: HIGH
151
+
152
+ - name: "Notification Service"
153
+ type: AMQP/HTTPS
154
+ format: JSON
155
+ authentication: Service Token
156
+ doc: @docs/interfaces/notification-service.md
157
+ data_flow: "User notifications"
158
+ criticality: MEDIUM
159
+
160
+ - name: "Analytics Platform"
161
+ type: HTTPS
162
+ format: JSON
163
+ authentication: API Key
164
+ doc: @docs/interfaces/analytics.md
165
+ data_flow: "Event tracking"
166
+ criticality: LOW
167
+
168
+ # Data Interfaces
169
+ data:
170
+ - name: "Primary Database"
171
+ type: PostgreSQL/MySQL/MongoDB
172
+ connection: Connection Pool
173
+ doc: @docs/interfaces/database-schema.md
174
+ data_flow: "Application state persistence"
175
+
176
+ - name: "Cache Layer"
177
+ type: Redis/Memcached
178
+ connection: Client Library
179
+ doc: @docs/interfaces/cache-strategy.md
180
+ data_flow: "Temporary data and sessions"
181
+
182
+ - name: "File Storage"
183
+ type: S3/Azure Blob/GCS
184
+ connection: SDK
185
+ doc: @docs/interfaces/storage-api.md
186
+ data_flow: "Media and document storage"
187
+ ```
188
+
189
+ ### Cross-Component Boundaries (if applicable)
190
+
191
+ [NEEDS CLARIFICATION: What are the boundaries between components/teams?]
192
+
193
+ - **API Contracts**: [Which interfaces are public contracts that cannot break]
194
+ - **Team Ownership**: [Which team owns which component]
195
+ - **Shared Resources**: [Databases, queues, caches used by multiple components]
196
+ - **Breaking Change Policy**: [How to handle changes that affect other components]
197
+
198
+ ### Project Commands
199
+
200
+ [NEEDS CLARIFICATION: What are the project-specific commands? Discover from package.json, Makefile, or build configs.]
201
+
202
+ ```bash
203
+ # Core Commands (discovered from project files)
204
+ Install: [npm install / pip install / go mod download]
205
+ Dev: [npm run dev / python manage.py runserver]
206
+ Test: [npm test / pytest / go test]
207
+ Lint: [npm run lint / flake8 / golint]
208
+ Build: [npm run build / python setup.py / go build]
209
+
210
+ # Database (if applicable)
211
+ Migrate: [migration command]
212
+ Seed: [seed command]
213
+ ```
214
+
215
+ ## Solution Strategy
216
+
217
+ [NEEDS CLARIFICATION: What is the high-level approach to solving this problem?]
218
+
219
+ - Architecture Pattern: [Describe the approach (e.g., layered, modular, microservice)]
220
+ - Integration Approach: [How this feature integrates with the current system]
221
+ - Justification: [Why this approach fits given the constraints and scope]
222
+ - Key Decisions: [Major technical decisions and their rationale]
223
+
224
+ ## Building Block View
225
+
226
+ ### Components
227
+
228
+ [NEEDS CLARIFICATION: What are the main components and how do they interact? Create a component diagram showing the relationships]
229
+ ```mermaid
230
+ graph LR
231
+ User --> Component
232
+ Component --> Hook
233
+ Hook --> API
234
+ API --> Database
235
+ ```
236
+
237
+ ### Directory Map
238
+
239
+ [NEEDS CLARIFICATION: Where will new code be added and existing code modified? For multi-component features, provide directory structure for each component.]
240
+
241
+ **Component**: [component-name]
242
+ ```
243
+ .
244
+ ├── src/
245
+ │ ├── feature_area/
246
+ │ │ ├── [discovered structure] # NEW/MODIFY: Description
247
+ │ │ └── [discovered structure] # NEW/MODIFY: Description
248
+ │ └── shared/
249
+ │ └── [discovered structure] # NEW/MODIFY: Description
250
+ ```
251
+
252
+ **Component**: [another-component-name] (if applicable)
253
+ ```
254
+ .
255
+ ├── [discovered structure]
256
+ │ └── [discovered structure]
257
+ ```
258
+
259
+ ### Interface Specifications
260
+
261
+ **Note**: Interfaces can be documented by referencing external documentation files OR specified inline. Choose the approach that best fits your project's documentation structure.
262
+
263
+ #### Interface Documentation References
264
+
265
+ [NEEDS CLARIFICATION: What interface documentation already exists that should be referenced?]
266
+ ```yaml
267
+ # Reference existing interface documentation
268
+ interfaces:
269
+ - name: "User Authentication API"
270
+ doc: @docs/interfaces/auth-api.md
271
+ relevance: CRITICAL
272
+ sections: [authentication_flow, token_management]
273
+ why: "Core authentication flow must be followed"
274
+
275
+ - name: "Payment Processing Interface"
276
+ doc: @docs/interfaces/payment-gateway.md
277
+ relevance: HIGH
278
+ sections: [transaction_processing, webhook_handling]
279
+ why: "Integration with payment provider constraints"
280
+
281
+ - name: "Event Bus Interface"
282
+ doc: @docs/interfaces/event-bus.md (NEW)
283
+ relevance: MEDIUM
284
+ sections: [event_format, subscription_model]
285
+ why: "New event-driven communication pattern"
286
+ ```
287
+
288
+ #### Data Storage Changes
289
+
290
+ [NEEDS CLARIFICATION: Are database schema changes needed? If yes, specify tables, columns, and relationships. If no, remove this section]
291
+ ```yaml
292
+ # Database/storage schema modifications
293
+ Table: primary_entity_table
294
+ ADD COLUMN: new_field (data_type, constraints)
295
+ MODIFY COLUMN: existing_field (new_constraints)
296
+ ADD INDEX: performance_index (fields)
297
+
298
+ Table: supporting_entity_table (NEW)
299
+ id: primary_key
300
+ related_id: foreign_key
301
+ business_field: data_type, constraints
302
+
303
+ # Reference detailed schema documentation if available
304
+ schema_doc: @docs/interfaces/database-schema.md
305
+ migration_scripts: @migrations/v2.1.0/
306
+ ```
307
+
308
+ #### Internal API Changes
309
+
310
+ [NEEDS CLARIFICATION: What API endpoints are being added or modified? Specify methods, paths, request/response formats]
311
+
312
+ ```yaml
313
+ # Application endpoints being added/modified
314
+ Endpoint: Feature Operation
315
+ Method: HTTP_METHOD
316
+ Path: /api/version/resource/operation
317
+ Request:
318
+ required_field: data_type, validation_rules
319
+ optional_field: data_type, default_value
320
+ Response:
321
+ success:
322
+ result_field: data_type
323
+ metadata: object_structure
324
+ error:
325
+ error_code: string
326
+ message: string
327
+ details: object (optional)
328
+
329
+ # Reference comprehensive API documentation if available
330
+ api_doc: @docs/interfaces/internal-api.md
331
+ openapi_spec: @specs/openapi.yaml
332
+ ```
333
+
334
+ #### Application Data Models
335
+
336
+ [NEEDS CLARIFICATION: What data models/entities are being created or modified? Define fields and behaviors]
337
+
338
+ ```pseudocode
339
+ # Core business objects being modified/created
340
+ ENTITY: PrimaryEntity (MODIFIED/NEW)
341
+ FIELDS:
342
+ existing_field: data_type
343
+ + new_field: data_type (NEW)
344
+ ~ modified_field: updated_type (CHANGED)
345
+
346
+ BEHAVIORS:
347
+ existing_method(): return_type
348
+ + new_method(parameters): return_type (NEW)
349
+ ~ modified_method(): updated_return_type (CHANGED)
350
+
351
+ ENTITY: SupportingEntity (NEW)
352
+ FIELDS: [field_definitions]
353
+ BEHAVIORS: [method_definitions]
354
+
355
+ # Reference domain model documentation if available
356
+ domain_doc: @docs/domain/entity-model.md
357
+ ```
358
+
359
+ #### Integration Points
360
+
361
+ [NEEDS CLARIFICATION: What external systems does this feature connect to? For multi-component features, also document inter-component communication.]
362
+
363
+ ```yaml
364
+ # Inter-Component Communication (between your components)
365
+ - from: [source-component]
366
+ to: [target-component]
367
+ - protocol: [REST/GraphQL/gRPC/WebSocket/MessageQueue]
368
+ - doc: @docs/interfaces/internal-api.md
369
+ - endpoints: [specific endpoints or topics]
370
+ - data_flow: "Description of what data flows between components"
371
+
372
+ # External System Integration (third-party services)
373
+ External_Service_Name:
374
+ - doc: @docs/interfaces/service-name.md
375
+ - sections: [relevant_endpoints, data_formats]
376
+ - integration: "Brief description of how systems connect"
377
+ - critical_data: [data_elements_exchanged]
378
+ ```
379
+
380
+ ### Implementation Examples
381
+
382
+ **Purpose**: Provide strategic code examples to clarify complex logic, critical algorithms, or integration patterns. These examples are for guidance, not prescriptive implementation.
383
+
384
+ **Include examples for**:
385
+ - Complex business logic that needs clarification
386
+ - Critical algorithms or calculations
387
+ - Non-obvious integration patterns
388
+ - Security-sensitive implementations
389
+ - Performance-critical sections
390
+
391
+ **When examples include raw SQL or direct database access**:
392
+
393
+ 1. **Schema Reference** -- List actual column names for every table in the query. Point to the migration file as source of truth. Call out columns that DON'T exist (common: pseudocode names like `status` for date-computed fields, `code` on junction tables where it lives on a catalog table, `period_start` when only a timestamp like `settled_at` exists).
394
+
395
+ 2. **Traced Walkthrough** -- For queries with conditional logic, show example rows and trace how the condition evaluates for each variant. Include concrete numbers. The reader should understand *why* the query produces different results for different inputs without having to mentally execute the SQL.
396
+
397
+ 3. **Edge Cases** -- Document what happens when the query returns no rows, NULL values, or zero. Map each case to the Python/TypeScript code path that handles it.
398
+
399
+ **Why this matters**: Pseudocode column names in SQL examples look plausible but cause immediate implementation failures. A new session cannot verify column names from the SDD alone -- it must cross-reference migration files. Including the schema reference eliminates this round-trip and prevents wrong-column bugs.
400
+
401
+ [NEEDS CLARIFICATION: Are there complex areas that would benefit from code examples? If not, remove this section]
402
+
403
+ #### Example: [Complex Business Logic Name]
404
+
405
+ **Why this example**: [Explain why this specific example helps clarify the implementation]
406
+
407
+ ```typescript
408
+ // Example: Discount calculation with multiple rules
409
+ // This demonstrates the expected logic flow, not the exact implementation
410
+ function calculateDiscount(order: Order, user: User): Discount {
411
+ // Business rule: VIP users get additional benefits
412
+ const baseDiscount = order.subtotal * getBaseDiscountRate(user.tier);
413
+
414
+ // Complex rule: Stacking discounts with limits
415
+ const promotionalDiscount = Math.min(
416
+ order.promotions.reduce((sum, promo) => sum + promo.value, 0),
417
+ order.subtotal * MAX_PROMO_PERCENTAGE
418
+ );
419
+
420
+ // Edge case: Never exceed maximum discount
421
+ return Math.min(
422
+ baseDiscount + promotionalDiscount,
423
+ order.subtotal * MAX_TOTAL_DISCOUNT
424
+ );
425
+ }
426
+ ```
427
+
428
+ #### Example: [Integration Pattern Name]
429
+
430
+ **Why this example**: [Explain why this pattern is important to document]
431
+
432
+ ```python
433
+ # Example: Retry pattern for external service integration
434
+ # Shows expected error handling approach
435
+ async def call_payment_service(transaction):
436
+ """
437
+ Demonstrates resilient integration pattern.
438
+ Actual implementation may use circuit breaker library.
439
+ """
440
+ for attempt in range(MAX_RETRIES):
441
+ try:
442
+ response = await payment_client.process(transaction)
443
+ if response.requires_3ds:
444
+ # Critical: Handle 3D Secure flow
445
+ return await handle_3ds_flow(response)
446
+ return response
447
+ except TransientError as e:
448
+ if attempt == MAX_RETRIES - 1:
449
+ # Final attempt failed, escalate
450
+ raise PaymentServiceUnavailable(e)
451
+ await exponential_backoff(attempt)
452
+ except PermanentError as e:
453
+ # Don't retry permanent failures
454
+ raise PaymentFailed(e)
455
+ ```
456
+
457
+ #### Test Examples as Interface Documentation
458
+
459
+ [NEEDS CLARIFICATION: Can unit tests serve as interface documentation?]
460
+
461
+ ```javascript
462
+ // Example: Unit test as interface contract
463
+ describe('PromoCodeValidator', () => {
464
+ it('should validate promo code format and availability', async () => {
465
+ // This test documents expected interface behavior
466
+ const validator = new PromoCodeValidator(mockRepository);
467
+
468
+ // Valid code passes all checks
469
+ const validResult = await validator.validate('SUMMER2024');
470
+ expect(validResult).toEqual({
471
+ valid: true,
472
+ discount: { type: 'percentage', value: 20 },
473
+ restrictions: { minOrder: 50, maxUses: 1 }
474
+ });
475
+
476
+ // Expired code returns specific error
477
+ const expiredResult = await validator.validate('EXPIRED2023');
478
+ expect(expiredResult).toEqual({
479
+ valid: false,
480
+ error: 'PROMO_EXPIRED',
481
+ message: 'This promotional code has expired'
482
+ });
483
+ });
484
+ });
485
+ ```
486
+
487
+ ## Runtime View
488
+
489
+ ### Primary Flow
490
+
491
+ [NEEDS CLARIFICATION: What is the main user action and how does the system respond? Document the step-by-step flow]
492
+
493
+ #### Primary Flow: [Main User Action]
494
+ 1. User triggers [action]
495
+ 2. System validates [what]
496
+ 3. Process executes [how]
497
+ 4. Result displays [where]
498
+
499
+ ```mermaid
500
+ sequenceDiagram
501
+ actor User
502
+ participant UI
503
+ participant PromoCodeController
504
+ participant PromoCodeValidator
505
+ participant OrderDiscountService
506
+
507
+ User->>UI: Apply promo code
508
+ UI->>PromoCodeController: POST /apply-code
509
+ PromoCodeController->>PromoCodeValidator: validate(code)
510
+ PromoCodeValidator-->>PromoCodeController: ValidationResult
511
+ PromoCodeController->>OrderDiscountService: applyDiscount()
512
+ OrderDiscountService-->>PromoCodeController: DiscountedOrder
513
+ PromoCodeController-->>UI: Response
514
+ ```
515
+
516
+ ### Error Handling
517
+
518
+ [NEEDS CLARIFICATION: How are different error types handled?]
519
+
520
+ - Invalid input: [specific error message and user guidance]
521
+ - Network failure: [retry strategy or fallback behavior]
522
+ - Business rule violation: [user feedback and recovery options]
523
+
524
+ ### Complex Logic (if applicable)
525
+
526
+ [NEEDS CLARIFICATION: Is there complex algorithmic logic that needs documentation? If yes, detail the algorithm. If no, remove this section]
527
+
528
+ ```
529
+ ALGORITHM: Process Feature Request
530
+ INPUT: user_request, current_state
531
+ OUTPUT: processed_result
532
+
533
+ 1. VALIDATE: input_parameters, user_permissions, system_state
534
+ 2. TRANSFORM: raw_input -> structured_data
535
+ 3. APPLY_BUSINESS_RULES:
536
+ - Check constraints and limits
537
+ - Calculate derived values
538
+ - Apply conditional logic
539
+ 4. INTEGRATE: update_external_systems, notify_stakeholders
540
+ 5. PERSIST: save_changes, log_activities
541
+ 6. RESPOND: return_result, update_user_interface
542
+ ```
543
+
544
+ ## Deployment View
545
+
546
+ [NEEDS CLARIFICATION: What are the deployment requirements and considerations? For multi-application features, consider coordination and dependencies. If there is no change to existing deployment, them remove sub-sections and just comment it as "no change"]
547
+
548
+ ### Single Application Deployment
549
+ - **Environment**: [Where this runs - client/server/edge/cloud]
550
+ - **Configuration**: [Required env vars or settings]
551
+ - **Dependencies**: [External services or APIs needed]
552
+ - **Performance**: [Expected load, response time targets, caching strategy]
553
+
554
+ ### Multi-Component Coordination (if applicable)
555
+
556
+ [NEEDS CLARIFICATION: How do multiple components coordinate during deployment?]
557
+ - **Deployment Order**: [Which components must deploy first?]
558
+ - **Version Dependencies**: [Minimum versions required between components]
559
+ - **Feature Flags**: [How to enable/disable features during rollout]
560
+ - **Rollback Strategy**: [How to handle partial deployment failures]
561
+ - **Data Migration Sequencing**: [Order of database changes across services]
562
+
563
+ ## Cross-Cutting Concepts
564
+
565
+ ### Pattern Documentation
566
+
567
+ [NEEDS CLARIFICATION: What existing patterns will be used and what new patterns need to be created?]
568
+ ```yaml
569
+ # Existing patterns used in this feature
570
+ - pattern: @docs/patterns/[pattern-name].md
571
+ relevance: [CRITICAL|HIGH|MEDIUM|LOW]
572
+ why: "[Brief explanation of why this pattern is needed]"
573
+
574
+ # New patterns created for this feature
575
+ - pattern: @docs/patterns/[new-pattern-name].md (NEW)
576
+ relevance: [CRITICAL|HIGH|MEDIUM|LOW]
577
+ why: "[Brief explanation of why this pattern was created]"
578
+ ```
579
+
580
+ ### User Interface & UX (if applicable)
581
+
582
+ [NEEDS CLARIFICATION: What UI/UX architecture decisions apply to this feature?]
583
+
584
+ **Information Architecture:**
585
+ - Navigation: [Site structure, menu hierarchy, breadcrumbs]
586
+ - Content Organization: [Page layouts, content grouping, user mental models]
587
+ - User Flows: [Task completion paths, entry/exit points]
588
+
589
+ **Design System:**
590
+ - Components: [Which design system components to use/extend]
591
+ - Tokens: [Colors, typography, spacing from design system]
592
+ - Patterns: [Form patterns, feedback patterns, loading states]
593
+
594
+ **Interaction Design:**
595
+ - State Management: [UI state, form state, optimistic updates]
596
+ - Feedback: [Loading indicators, success/error states, notifications]
597
+ - Accessibility: [WCAG level, keyboard navigation, screen reader support]
598
+
599
+ #### UI Visualization Guide
600
+
601
+ **Entry Points** — Use ASCII wireframes to show where features live:
602
+ ```
603
+ ┌─────────────────────────────────────────┐
604
+ │ Workspace Switcher Dropdown │
605
+ ├─────────────────────────────────────────┤
606
+ │ ✓ Current Workspace │
607
+ │ Other Workspace │
608
+ │ ───────────────────────────── │
609
+ │ ⚙️ Settings │
610
+ │ 🔑 API Keys ← NEW │
611
+ └─────────────────────────────────────────┘
612
+ ```
613
+
614
+ **Screen Flows** — Use Mermaid flowcharts for navigation:
615
+ ```mermaid
616
+ flowchart LR
617
+ A[Entry Point] -->|Action| B[Screen 2]
618
+ B -->|Action| C[Screen 3]
619
+ C -->|Complete| A
620
+ C -->|Cancel| B
621
+ ```
622
+
623
+ **Component States** — Use Mermaid state diagrams for interactions:
624
+ ```mermaid
625
+ stateDiagram-v2
626
+ [*] --> Idle
627
+ Idle --> Loading: Submit
628
+ Loading --> Success: 200 OK
629
+ Loading --> Error: 4xx/5xx
630
+ Error --> Idle: Retry
631
+ Success --> [*]
632
+ ```
633
+
634
+ ### System-Wide Patterns
635
+
636
+ [NEEDS CLARIFICATION: What system-wide patterns and concerns apply to this feature?]
637
+ - Security: [Authentication, authorization, encryption patterns]
638
+ - Error Handling: [Global vs local strategies, error propagation]
639
+ - Performance: [Caching strategies, batching, async patterns]
640
+ - i18n/L10n: [Multi-language support, localization approaches]
641
+ - Logging/Auditing: [Observability patterns, audit trail implementation]
642
+
643
+ ### Multi-Component Patterns (if applicable)
644
+
645
+ [NEEDS CLARIFICATION: What patterns apply across multiple components?]
646
+ - **Communication Patterns**: [Sync vs async, event-driven, request-response]
647
+ - **Data Consistency**: [Eventual consistency, distributed transactions, saga patterns]
648
+ - **Shared Code**: [Shared libraries, monorepo packages, code generation]
649
+ - **Service Discovery**: [How components find each other in different environments]
650
+ - **Circuit Breakers**: [Handling failures between components]
651
+ - **Distributed Tracing**: [Correlation IDs, trace propagation across services]
652
+
653
+ ## Architecture Decisions
654
+
655
+ [NEEDS CLARIFICATION: What key architecture decisions need to be made? Each requires user confirmation.]
656
+
657
+ - [ ] ADR-1 [Decision Name]: [Choice made]
658
+ - Rationale: [Why this over alternatives]
659
+ - Trade-offs: [What we accept]
660
+ - User confirmed: _Pending_
661
+
662
+ - [ ] ADR-2 [Decision Name]: [Choice made]
663
+ - Rationale: [Why this over alternatives]
664
+ - Trade-offs: [What we accept]
665
+ - User confirmed: _Pending_
666
+
667
+ ## Quality Requirements
668
+
669
+ [NEEDS CLARIFICATION: What are the specific, measurable quality requirements?]
670
+ - Performance: [Response time targets, throughput, resource limits]
671
+ - Usability: [User experience requirements, accessibility standards]
672
+ - Security: [Access control, data protection, audit requirements]
673
+ - Reliability: [Uptime targets, error recovery, data integrity]
674
+
675
+ ## Acceptance Criteria
676
+
677
+ [NEEDS CLARIFICATION: What system behaviors verify the PRD acceptance scenarios are met?]
678
+
679
+ Translate each critical PRD acceptance scenario into a system-level specification using EARS format. These criteria define the technical "done" for implementation.
680
+
681
+ Use the appropriate EARS pattern for each criterion:
682
+ - **UBIQUITOUS**: `THE SYSTEM SHALL [action]` - always-on behavior
683
+ - **EVENT-DRIVEN**: `WHEN [trigger], THE SYSTEM SHALL [action]` - user/system events
684
+ - **STATE-DRIVEN**: `WHILE [state], THE SYSTEM SHALL [action]` - mode-dependent
685
+ - **OPTIONAL**: `WHERE [feature enabled], THE SYSTEM SHALL [action]` - configurable
686
+ - **COMPLEX**: `IF [condition], THEN THE SYSTEM SHALL [action]` - business rules
687
+
688
+ **Main Flow Criteria: [PRD/AC-X.Y - Brief description]**
689
+ - [ ] WHEN [user/system trigger], THE SYSTEM SHALL [expected behavior]
690
+ - [ ] THE SYSTEM SHALL [always-on requirement]
691
+
692
+ **Error Handling Criteria: [PRD/AC-X.Y - Error handling]**
693
+ - [ ] WHEN [error condition occurs], THE SYSTEM SHALL [graceful handling]
694
+ - [ ] IF [invalid input], THEN THE SYSTEM SHALL [appropriate feedback]
695
+
696
+ **Edge Case Criteria: [PRD/AC-X.Y - Edge case]**
697
+ - [ ] WHILE [boundary state], THE SYSTEM SHALL [correct behavior]
698
+ - [ ] IF [limit condition], THEN THE SYSTEM SHALL [appropriate response]
699
+
700
+ ## Risks and Technical Debt
701
+
702
+ ### Known Technical Issues
703
+
704
+ [NEEDS CLARIFICATION: What current bugs, limitations, or issues affect this feature?]
705
+ - [Current bugs or limitations that affect the system]
706
+ - [Performance bottlenecks and their specific locations]
707
+ - [Memory leaks or resource management problems]
708
+ - [Integration issues with external systems]
709
+
710
+ ### Technical Debt
711
+
712
+ [NEEDS CLARIFICATION: What technical debt exists that impacts this feature?]
713
+ - [Code duplication that needs refactoring]
714
+ - [Temporary workarounds that need proper solutions]
715
+ - [Anti-patterns that shouldn't be replicated]
716
+ - [Architectural violations or deviations]
717
+
718
+ ### Implementation Gotchas
719
+
720
+ [NEEDS CLARIFICATION: What non-obvious issues might trip up implementation?]
721
+ - [Non-obvious dependencies or side effects]
722
+ - [Timing issues, race conditions, or synchronization problems]
723
+ - [Configuration quirks or environment-specific issues]
724
+ - [Known issues with third-party dependencies]
725
+
726
+ ## Glossary
727
+
728
+ [NEEDS CLARIFICATION: Define domain-specific and technical terms used throughout this document]
729
+
730
+ ### Domain Terms
731
+
732
+ | Term | Definition | Context |
733
+ |------|------------|---------|
734
+ | [Domain Term] | [Clear, concise definition] | [Where/how it's used in this feature] |
735
+ | [Business Concept] | [Explanation in plain language] | [Relevance to the implementation] |
736
+
737
+ ### Technical Terms
738
+
739
+ | Term | Definition | Context |
740
+ |------|------------|---------|
741
+ | [Technical Term] | [Technical definition] | [How it applies to this solution] |
742
+ | [Acronym/Abbreviation] | [Full form and explanation] | [Usage in the architecture] |
743
+
744
+ ### API/Interface Terms
745
+
746
+ | Term | Definition | Context |
747
+ |------|------------|---------|
748
+ | [API Term] | [Specific meaning in this context] | [Related endpoints or operations] |
749
+ | [Protocol/Format] | [Technical specification] | [Where used in integrations] |