Skip to content
guidePhase: BuildDeliveryGuide 4 of 16

Roles: developer · architect · qa

Guide: Spec-Driven Development ​

Decision: How tightly should specifications bind AI-generated implementation?

Related: developer-workflow.md · SOP-004


Contract formats ​

FormatProsCons
OpenAPI 3.1HTTP APIs; tooling-rich; Schemathesis/PactNot ideal for gRPC-primary shops
AsyncAPIEvents, queues, WebSocketsSecond spec to maintain
Protobuf + bufStrong typing; gRPCSteeper curve for REST teams
Gherkin / BDD onlyPO-friendly acceptanceAmbiguous for AI codegen without API schema
JSON Schema filesFlexibleNo single operation map

Recommended: OpenAPI for REST/HTTP; AsyncAPI when events are first-class; BDD scenarios linked to OpenAPI operations.


AI codegen binding levels ​

LevelDescriptionProsCons
StrictNo code until spec approvedHighest quality barSlower for tiny fixes
ModerateSpec approved for new endpoints; patches can lag 1 sprintBalancedRequires discipline
LooseSpec optional; AI free-formMaximum vibe velocityArchitecture and test debt

Recommended for enterprise: Strict for T1/T2 external APIs; moderate for internal tools.


Test binding ​

ApproachProsCons
Contract tests from OpenAPICatches spec/code driftDoesn't cover all business logic
AI-generated tests from specFast coverageMay assert implementation bugs
Human-written tests onlyTrustedDoesn't scale with AI output volume

Recommended: AI generates from spec; human reviews test PR; contract tests are merge gate.


Pitfalls ​

PitfallWhy it hurtsMitigation
Spec after codeContract tests pass wrong behaviorBlock impl PR without approved spec
AI tests from implementationTests encode the bugGenerate from OpenAPI, not from code
Underspecified error modelsAI invents inconsistent errorsStandard error schema in OpenAPI
Breaking change without versionConsumers break silentlyURL or header versioning policy in ADR
Spec too large for agent contextPartial implementationPer-service specs; MCP get_spec by file
"Just fix it in code" cultureSpec becomes fictionCI diff checks spec vs route registration
No link to ADRsSame debate every quarterx-adr on operations

Approved OpenAPI per service → AI scaffolds handler + contract tests → developer steers within operation IDs → PR requires spec link.


Reference template only — no production code. Adapt in your own project.