1---2name: sdd-driven-development3description: Guides Specification-Driven Development (SDD) from ambiguous requests to clear, testable specs before coding. Use when the user asks for 規格驅動開發, spec-first workflow, 先寫規格再寫程式, or requests requirements/design/tasks documents with staged review gates for medium-to-large engineering changes.4---56# Conducting Specification-Driven Development (SDD)78## When to use this skill9- User asks for "規格驅動開發", "SDD", "spec-first", or "先寫規格再寫程式".10- User asks to define spec first, then implement.11- Requirement is unclear, cross-module, or high risk.12- Team needs phase-by-phase review points before coding.13- User asks for "requirements.md", "design.md", "tasks.md", "需求文件", "技術設計", or "任務拆解".1415## Workflow16170. Scope gate (avoid over-engineering)18- If change is a tiny bugfix or low-risk patch, run SDD-Lite:19 - Write minimal requirements and acceptance criteria.20 - Write atomic tasks with verification.21 - Skip heavy design docs unless user asks.22- If change is medium/large or uncertain, run full SDD below.23241. Analyze and classify25- Confirm problem, goal, constraints, and success signal.26- Classify domain to choose templates/checklists.27282. Load only required references29- Web API: `references/templates/web_api.md` + `references/checklists/web_review.md`30- Web DB: `references/templates/web_db.md` + `references/checklists/web_review.md`31- Web UI/UX: `references/templates/web_uiux.md` + `references/checklists/web_review.md`32- ML experiment: `references/templates/ml_experiment.md` + `references/checklists/ml_review.md`33- CV pipeline: `references/templates/cv_pipeline.md` + `references/checklists/ml_review.md`34- Unknown domain: `references/templates/general.md` + `references/checklists/general_review.md`35363. Phase 1 - Requirements37- Produce `requirements.md` with:38 - User stories or jobs-to-be-done39 - Scope and out-of-scope40 - Edge cases41 - Acceptance criteria in EARS style42- Pause for review and require explicit user confirmation.43444. Phase 2 - Design45- Produce `design.md` with:46 - Architecture and data flow47 - Major technical decisions and tradeoffs48 - Integration constraints and failure handling49- Pause for review and require explicit user confirmation.50515. Phase 3 - Tasks52- Produce `tasks.md` with atomic tasks.53- Each task must include a verification method (unit/integration/manual).54- Prefer TDD: test first when feasible.55- For logic-changing tasks, require explicit evidence fields:56 - `red_evidence`: failing test name and failure signal57 - `green_evidence`: passing test name and pass signal58 - `refactor_check`: confirmation that tests still pass after cleanup59- Pause for final sign-off before coding.60616. Implementation handoff62- Start code changes only after approved `tasks.md`.63- Keep spec files aligned with implementation; update stale sections immediately.6465## Instructions6667- Keep docs lean; avoid duplicate or decorative text.68- Do not output all phases at once. Complete one phase, stop, and request review.69- Do not jump into coding when core requirements or acceptance criteria are unresolved.70- Use precise, testable language. Avoid vague criteria like "works well" or "fast enough".71- Use EARS format for acceptance criteria:72 - `When <trigger>, the system shall <observable behavior>.`73 - `If <precondition>, the system shall <observable behavior>.`74- Every phase must track:75 - Open questions76 - Assumptions77 - Risks and mitigation78- Ask for missing domain constraints early (security, compliance, latency, cost).79- For destructive operations (schema drops, data deletion, irreversible migrations), require explicit approval plus rollback/backups in the design.8081## Fallback and expansion8283- If no domain template fits, use `general.md` and continue delivery.84- After first approved spec in a new domain, propose extracting a new template/checklist for reuse.85- Do not block current delivery while waiting for new template creation.8687## Deliverable contract8889- `requirements.md`: clear "what/why" and EARS acceptance criteria.90- `design.md`: clear "how" with explicit constraints/tradeoffs.91- `tasks.md`: executable sequence with verification per task, including `red_evidence`, `green_evidence`, and `refactor_check` for logic tasks.