Loading...
Loading...
Use when creating or iterating on a detailed per-subsystem technical design specification from a system spec, before starting OpenSpec workflow. Triggers: "design spec", "subsystem spec", "write the spec for S1", "phase breakdown", "implementation phases", "mid-level spec", "technical design". Encodes opinionated progressive phase discipline with FP progression and contract boundaries. Do NOT use for high-level system specs (use brainstorming) or for OpenSpec artifacts (use openspec directly).
npx skill4agent add mpurbo/purbo-skills subsystem-design-specsuperpowers:brainstormingSearch: docs/conventions.md, docs/spec-conventions.mdSearch: docs/**/*-spec*.md, docs/**/*-design*.md, docs/prd/**/*.md# S{n} {Subsystem Name} — Subsystem Design Spec
**Version:** x.y
**Status:** Draft
**Date:** YYYY-MM-DD
**Parent Spec:** [System Spec Name](path) (Section N, S{n})
---
## 1. Overview
### 1.1 Goals
### 1.2 Non-Goals
## 2. Architecture
### 2.1 Component Diagram (mermaid)
### 2.2 Key Design Decisions
D1 — {Title}: rationale, tradeoffs
D2 — {Title}: rationale, tradeoffs
...
## 3. User Stories
US-1: {Story} with AC-1.1, AC-1.2, ...
US-2: {Story} with AC-2.1, AC-2.2, ...
...
## 4. Detailed Design
Per-component subsections with behavior, schemas, flows
## 5. Output Contract
Data schemas, file structures, API contracts, column definitions,
constraints — the interface downstream consumers depend on
## 6. Error Handling
Exit codes, error categories, handling strategy per category
## 7. Testing Strategy
### 7.1 Unit Tests — what's covered, key scenarios
### 7.2 Integration Tests — with mocks, full flows
### 7.3 End-to-End Tests — opt-in, real external services
## 8. Performance Considerations
## 9. Future Considerations (out of scope for v1)
## 10. Dependencies
### 10.1 Packages/Crates
### 10.2 External Dependencies
## 11. Implementation Phases
(See Phase Design Discipline below)
## 12. Acceptance Summary
Numbered list of acceptance conditions
## Appendices (optional)
Reference material, API response structures, etc.### S{n}.{m}: {Phase Name}
**Scope:** What this phase delivers — concrete, verifiable
**Size estimate:** ~N files, ~N lines
**Contracts consumed:** Prior phase contracts (or "None")
**Contracts exposed:**
- Type/trait/interface names and signatures
**Gate:** Exact command to verify (e.g., `cargo build && cargo test`)
**Verification:** How a human reviewer manually verifies this phase works
beyond the gate command — what to inspect, what to run, what output to expect.
This becomes the reviewer's checklist during the human review checkpoint.
**Review tier:** gate-only | spot-check | full-review (see Review Tiers below)
**Dependencies:** Which prior phases, and what specifically (contracts only)S{n}.1 (Types & Contracts)
|-- S{n}.2 (Component A)
|-- S{n}.3 (Component B) <- parallel with S{n}.2
|-- S{n}.4 (Component C) <- parallel with S{n}.2, S{n}.3
| |
| |-- S{n}.5 (Provider X) <- depends on S{n}.4
|
|-- S{n}.6 (Orchestration) <- depends on S{n}.2-S{n}.4 contracts
|
--- S{n}.7 (CLI Wiring) <- depends on all
Parallelizable: S{n}.2, S{n}.3, S{n}.4 can proceed in parallel after S{n}.1.| Tier | When to Use | What Happens at Checkpoint |
|---|---|---|
| gate-only | Scaffolding, boilerplate, type definitions, infrastructure. Low risk, mechanical output. | Gate command passes → auto-proceed. Human is notified but doesn't need to act. |
| spot-check | Well-constrained phases with clear contracts. Moderate risk. | Human glances at the diff, verifies gate passed, proceeds unless something looks off. |
| full-review | Orchestration, business logic, external integrations, security-sensitive code. High risk. | Human reads the diff, runs verification guide, thinks about edge cases before proceeding. |
docs/conventions.md# Project Conventions
## Naming
- Subsystem codes: S1 (Downloader), S2 (DB Sync), S3 (Stream Ingest), ...
- Phase codes: S{n}.{m} (e.g., S1.1, S1.2)
- Design decisions: D{n} — {Title} with rationale
- User stories: US-{n} with acceptance criteria AC-{n}.{y}
## Document Structure
<list the section structure established in the first subsystem spec>
## Phase Design
- Ordering: types -> pure functions -> effects -> composition
- Max tasks per phase: 8
- Each phase exposes contracts consumed/exposed
- Phase dependency graph required
## Established Contracts
<list cross-subsystem contracts defined so far>
- S1 output: CSV files at data/{market}/{ticker}/{resolution}.csv (Section 5)
- S1 types in sati-contracts: OhlcvBar, TickerInfo, Resolution, CsvRecord| Element | Format | Example |
|---|---|---|
| Subsystem code | S{n} | S1, S2, S3 |
| Phase code | S{n}.{m} | S1.1, S1.2, S2.3 |
| Design decision | D{n} | D1, D2, D3 |
| User story | US-{n} | US-1, US-2 |
| Acceptance criterion | AC-{story}.{criterion} | AC-1.1, AC-1.2, AC-3.4 |
| Spec file | {project}-s{n}-{name}-v{version}.md | sati-s1-downloader-v1.md |
| Thought | Reality |
|---|---|
| "The system spec is detailed enough" | System specs define boundaries. Design specs define internals. Different levels. |
| "I'll figure out phases during implementation" | Phases defined after coding starts are retrofitted, not designed. Contracts leak. |
| "These two phases are too small, I'll combine them" | Small phases are a feature. They enable focused review and parallel work. |
| "The contract is obvious, no need to write it" | Explicit contracts enable mock testing and subsystem isolation. Write it. |
| "I'll add the dependency graph later" | The graph exposes parallelization. Without it, phases are assumed sequential. |
| "This subsystem is simple, skip the full structure" | Simple subsystems still need contracts, phases, and testing strategy. |
| "I'll just follow the same structure as last time" | Read the existing specs and extract conventions explicitly. Memory drifts. |