Spec-Driven Development
Overview
Write a structured specification before writing code. The spec becomes the shared source of truth — a development contract that prevents misalignment, scope creep, and wasted effort. Every implementation decision traces back to the spec.
When to Use
- Starting a new Android project or module
- Adding a feature that spans multiple files or layers
- Requirements are ambiguous or come from multiple stakeholders
- Before writing a
tasks/plan.md
Skip when: Single-line fixes or changes that are unambiguous and self-contained.
Core Process
Phase 1: Specify
Ask clarifying questions before writing anything:
- What problem does this solve? Who is the user?
- Which features are in scope? Which are explicitly out?
- What is the tech stack? (minSdk, target SDK, Compose vs XML, DI framework)
- What are the boundaries? (offline support? accessibility? tablet?)
Write SPEC.md with these sections:
# Feature Name — Specification
## Objective
What we're building and why. One paragraph.
## Commands
Key Gradle tasks and how to use them:
- `./gradlew assembleDebug` — build debug APK
- `./gradlew test` — run unit tests
- `./gradlew connectedAndroidTest` — run instrumented tests
- `./gradlew lint` — run Android Lint
## Project Structure
Where new code lives in the module hierarchy:
- `:app` — main application module
- `:feature:feature-name` — new feature module
- `:core:data` — data layer (repositories, data sources)
- `:core:domain` — domain layer (use cases, models)
## Code Style
- Kotlin with Jetpack Compose for UI
- MVVM/MVI architecture with ViewModel + StateFlow
- Hilt for dependency injection
- Coroutines + Flow for async operations
- Material 3 design system
## Testing Strategy
- Unit tests: JUnit5 + MockK for ViewModels, use cases, repositories
- UI tests: Compose test rules for screen-level testing
- Integration tests: Room in-memory database, MockWebServer
- Target: critical paths covered, not arbitrary coverage %
## Boundaries
What is explicitly NOT in scope:
- [ ] List exclusions here
- Save as
SPEC.md in the project or module root
Phase 2: Plan
- Review spec with human — get explicit approval before continuing
- Use
planning-and-task-breakdown to create implementation tasks from the spec
Phase 3: Tasks
- Break spec into vertical slices (see
planning-and-task-breakdown)
- Each task references the spec section it implements
Phase 4: Implement
- Build incrementally (see
incremental-implementation)
- Every PR references the spec section it addresses
- Spec evolves with the project — update it when requirements change
Common Rationalizations
| Shortcut |
Why It Fails |
| "The feature is simple, no spec needed" |
Simple features have hidden edge cases (configuration changes, process death, deep links). A brief spec still beats none. |
| "We'll figure it out as we go" |
Without a spec, each developer builds a different mental model. Alignment costs compound. |
| "The ticket/issue IS the spec" |
Tickets describe what to build. Specs describe how it fits into the system, what's excluded, and how to verify. |
| "Writing specs slows us down" |
Rework from misalignment costs 3–10x more than a spec. |
Red Flags
- Implementation started without written spec
- Spec has no "Boundaries" or exclusions section
- Spec doesn't specify testing strategy
- Multiple developers have different understandings of scope
- Spec never updated after requirement changes
Verification
1---2name: spec-driven-development3description: Use when starting new Android projects, features, or changes with unclear requirements. Guides writing a structured spec (SPEC.md) that becomes the shared source of truth before any code is written.4---56# Spec-Driven Development78## Overview910Write a structured specification before writing code. The spec becomes the shared source of truth — a development contract that prevents misalignment, scope creep, and wasted effort. Every implementation decision traces back to the spec.1112## When to Use1314- Starting a new Android project or module15- Adding a feature that spans multiple files or layers16- Requirements are ambiguous or come from multiple stakeholders17- Before writing a `tasks/plan.md`1819**Skip when:** Single-line fixes or changes that are unambiguous and self-contained.2021## Core Process2223### Phase 1: Specify24251. **Ask clarifying questions** before writing anything:26 - What problem does this solve? Who is the user?27 - Which features are in scope? Which are explicitly out?28 - What is the tech stack? (minSdk, target SDK, Compose vs XML, DI framework)29 - What are the boundaries? (offline support? accessibility? tablet?)30312. **Write SPEC.md** with these sections:3233```markdown34# Feature Name — Specification3536## Objective37What we're building and why. One paragraph.3839## Commands40Key Gradle tasks and how to use them:41- `./gradlew assembleDebug` — build debug APK42- `./gradlew test` — run unit tests43- `./gradlew connectedAndroidTest` — run instrumented tests44- `./gradlew lint` — run Android Lint4546## Project Structure47Where new code lives in the module hierarchy:48- `:app` — main application module49- `:feature:feature-name` — new feature module50- `:core:data` — data layer (repositories, data sources)51- `:core:domain` — domain layer (use cases, models)5253## Code Style54- Kotlin with Jetpack Compose for UI55- MVVM/MVI architecture with ViewModel + StateFlow56- Hilt for dependency injection57- Coroutines + Flow for async operations58- Material 3 design system5960## Testing Strategy61- Unit tests: JUnit5 + MockK for ViewModels, use cases, repositories62- UI tests: Compose test rules for screen-level testing63- Integration tests: Room in-memory database, MockWebServer64- Target: critical paths covered, not arbitrary coverage %6566## Boundaries67What is explicitly NOT in scope:68- [ ] List exclusions here69```70713. **Save as `SPEC.md`** in the project or module root7273### Phase 2: Plan74754. Review spec with human — get explicit approval before continuing765. Use `planning-and-task-breakdown` to create implementation tasks from the spec7778### Phase 3: Tasks79806. Break spec into vertical slices (see `planning-and-task-breakdown`)817. Each task references the spec section it implements8283### Phase 4: Implement84858. Build incrementally (see `incremental-implementation`)869. Every PR references the spec section it addresses8710. Spec evolves with the project — update it when requirements change8889## Common Rationalizations9091| Shortcut | Why It Fails |92|----------|-------------|93| "The feature is simple, no spec needed" | Simple features have hidden edge cases (configuration changes, process death, deep links). A brief spec still beats none. |94| "We'll figure it out as we go" | Without a spec, each developer builds a different mental model. Alignment costs compound. |95| "The ticket/issue IS the spec" | Tickets describe what to build. Specs describe how it fits into the system, what's excluded, and how to verify. |96| "Writing specs slows us down" | Rework from misalignment costs 3–10x more than a spec. |9798## Red Flags99100- Implementation started without written spec101- Spec has no "Boundaries" or exclusions section102- Spec doesn't specify testing strategy103- Multiple developers have different understandings of scope104- Spec never updated after requirement changes105106## Verification107108- [ ] SPEC.md exists in version control109- [ ] All six sections filled in (Objective, Commands, Structure, Style, Testing, Boundaries)110- [ ] Human has reviewed and approved the spec111- [ ] Implementation tasks reference spec sections112- [ ] Spec updated when requirements changed during development