Purpose: Provide sufficient detail to ensure implementation consistency across different implementers, preventing interpretation drift.
Approach:
Sections may be reordered (e.g., surfacing Requirements Traceability earlier or moving Data Models nearer Architecture) when it improves clarity. Within each section, keep the flow Summary → Scope → Decisions → Impacts/Risks so reviewers can scan consistently.
2-3 paragraphs max Purpose: This feature delivers [specific value] to [target users]. Users: [Target user groups] will utilize this for [specific workflows]. Impact (if applicable): Changes the current [system state] by [specific modifications].
State the responsibility boundary of this spec in concrete terms. Treat this as the anchor for architecture, tasks, and later validation.
List the kinds of changes that should force dependent specs or consumers to re-check integration.
Reference detailed discovery notes in
research.mdonly for background; keep design.md self-contained for reviewers by capturing all decisions and contracts here. Capture key decisions in text and let diagrams carry structural detail—avoid repeating the same information in prose. Supporting sections below should remain as light as possible unless they materially clarify the responsibility boundary, dependency rules, or integration seams.
When modifying existing systems:
RECOMMENDED: Include Mermaid diagram showing the chosen architecture pattern and system boundaries (required for complex features, optional for simple additions)
Architecture Integration:
| Layer | Choice / Version | Role in Feature | Notes |
|---|---|---|---|
| Frontend / CLI | |||
| Backend / Services | |||
| Data / Storage | |||
| Messaging / Events | |||
| Infrastructure / Runtime |
Keep rationale concise here and, when more depth is required (trade-offs, benchmarks), add a short summary plus pointer to the Supporting References section and
research.mdfor raw investigation notes.
Map the directory structure and file responsibilities for this feature. This section directly drives task _Boundary:_ annotations and implementation Task Briefs. Use the appropriate level of detail:
src/
├── domain-a/ # Domain A responsibility
│ ├── controller.ts # Endpoint handlers
│ ├── service.ts # Business logic
│ └── types.ts # Domain types
├── domain-b/ # Domain B (same pattern as domain-a)
└── shared/
└── cross-cutting.ts # Non-obvious: why this exists
For repeated structures, describe the pattern once (e.g., "domain-b follows same pattern as domain-a"). List individual files only when their responsibility isn't obvious from the path.
path/to/existing.ts — What changes and whyEach file should have one clear responsibility. Group files that change together. For repeated structures, describe the pattern once rather than listing every file. Avoid duplicating what Components and Interfaces already describes — focus on the physical file layout that Components maps to.
Provide only the diagrams needed to explain non-trivial flows. Use pure Mermaid syntax. Common patterns:
Skip this section entirely for simple CRUD changes.
Describe flow-level decisions (e.g., gating conditions, retries) briefly after the diagram instead of restating each step.
Use this section for complex or compliance-sensitive features where requirements span multiple domains. Straightforward 1:1 mappings can rely on the Components summary table.
Map each requirement ID (e.g., 2.1) to the design elements that realize it.
| Requirement | Summary | Components | Interfaces | Flows |
|---|---|---|---|---|
| 1.1 | ||||
| 1.2 |
Omit this section only when a single component satisfies a single requirement without cross-cutting concerns.
Provide a quick reference before diving into per-component details.
Group detailed blocks by domain or architectural layer. For each detailed component, list requirement IDs as 2.1, 2.3 (omit “Requirement”). When multiple UI components share the same contract, reference a base interface/props definition instead of duplicating code blocks.
| Field | Detail |
|---|---|
| Intent | 1-line description of the responsibility |
| Requirements | 2.1, 2.3 |
| Owner / Reviewers | (optional) |
Responsibilities & Constraints
Dependencies
Summarize external dependency findings here; deeper investigation (API signatures, rate limits, migration notes) lives in research.md.
Contracts: Service [ ] / API [ ] / Event [ ] / Batch [ ] / State [ ] ← check only the ones that apply.
interface [ComponentName]Service {
methodName(input: InputType): Result<OutputType, ErrorType>;
}
| Method | Endpoint | Request | Response | Errors |
|---|---|---|---|---|
| POST | /api/resource | CreateRequest | Resource | 400, 409, 500 |
Implementation Notes
Focus on the portions of the data landscape that change with this feature.
Structure Definition:
Consistency & Integrity:
When to include: When implementation requires specific storage design decisions
For Relational Databases:
For Document Stores:
For Event Stores:
For Key-Value/Wide-Column Stores:
API Data Transfer
Event Schemas
Cross-Service Data Management
Skip subsections that are not relevant to this feature.
Concrete error handling patterns and recovery mechanisms for each error type.
User Errors (4xx): Invalid input → field-level validation; Unauthorized → auth guidance; Not found → navigation help
System Errors (5xx): Infrastructure failures → graceful degradation; Timeouts → circuit breakers; Exhaustion → rate limiting
Business Logic Errors (422): Rule violations → condition explanations; State conflicts → transition guidance
Process Flow Visualization (when complex business logic exists): Include Mermaid flowchart only for complex error scenarios with business workflows.
Error tracking, logging, and health monitoring implementation.
Use this section for features handling auth, sensitive data, external integrations, or user permissions. Capture only decisions unique to this feature; defer baseline controls to steering docs.
Use this section when performance targets, high load, or scaling concerns exist. Record only feature-specific targets or trade-offs and rely on steering documents for general practices.
Include a Mermaid flowchart showing migration phases when schema/data movement is required.
research.md, but their conclusions must be summarized in the main design.