Coding standards
SpecDrive is not a two-line style guide. On setup, each stack gets a full
.specdrive/coding-style.md that Cursor/Claude must follow when generating
design.md, tasks.md, and implementation.
Where it lives
After npx -y @specdrive/mcp setup --stack <stack>, open
.specdrive/coding-style.md in your app. MCP generation bundles include this
file as steering context.
Flutter — Clean Architecture + BLoC
Blocking rules for production Flutter PRs:
- Layers:
presentation / domain / data— UI → BLoC → UseCase → Repository - Dumb widgets: no filtering, pricing, or API calls in
build() - Domain purity: entities have no JSON; repositories are interfaces only
- BLoC: sealed states (Initial/Loading/Loaded/Error), complete Equatable
props, descriptive events - SOLID: depend on abstractions; one use case per operation; no god-BLoCs
- UI:
const, extract long builds,ListView.builder,mountedafter async, noprint - Tests: every new bloc/usecase/helper needs
_test.dart
Next.js — App Router + feature modules
- Thin
page.tsx; feature modules withdomain/+data/ - Server Components by default;
'use client'only when required - No DTOs in UI; mappers in
data/ - URL/server/Zustand slices — no business filters in JSX
- Vitest + Testing Library for domain/hooks
React Native — Expo + feature modules
- Screens compose hooks/stores — no fetch in JSX
- Discrete status unions, not boolean soup
FlatList/FlashListwith stable keys- Domain has zero RN imports; DTOs stay in
data/ - A11y labels on CTAs; platform diffs in
design.md
How SpecDrive enforces this
setupwrites stack-specificcoding-style.md+structure.md+tech-stack.md- MCP
generate_*bundles include those steering files tasks.mdmust tag UI vs logic so Design2Code never owns BLoC/state/testsreview_code/ host AI should reject PRs that violate layer boundaries