Spec Driven Workflow
Use when the user asks to write specs before code, define acceptance criteria, plan features before implementation, generate tests from specifications
What Is Spec Driven Workflow?
Spec Driven Workflow is a development methodology that mandates the creation of detailed specifications before any code is written. Unlike traditional approaches where specifications might be loosely documented or written in parallel with code, spec-driven workflow treats the specification as a binding contract. It explicitly defines what the system must, should, and will not do. Every code artifact, from implementation to tests, is directly traceable to requirements and acceptance criteria outlined in the specification. This approach brings structure and predictability to the development process, minimizing ambiguity and ensuring that all stakeholders share a common understanding of the desired outcome.
Why Use Spec Driven Workflow?
Adopting a spec-driven workflow offers several compelling advantages:
- Eliminates Rework: The majority of software defects—estimated at 60-80%—originate from misunderstood or incomplete requirements. By clarifying expectations before any coding begins, teams can resolve ambiguities early, drastically reducing costly rework later in the cycle.
- Forces Clarity: Articulating requirements in plain language exposes gaps in understanding. If a feature cannot be clearly specified, it is not ready for implementation. This discipline prevents teams from moving forward based on assumptions.
- Enables Parallelism: Once a specification is approved, different teams—frontend, backend, QA, documentation—can proceed in parallel, referencing the same authoritative contract.
- Creates Accountability: The specification becomes the definition of done. There is no room for subjective interpretation; features are either compliant with the acceptance criteria or not.
- Feeds Test-Driven Development (TDD): Acceptance criteria written in Given/When/Then format can be directly translated into automated tests, creating a seamless bridge between requirements and validation.
How to Get Started
Implementing a spec-driven workflow involves a sequence of deliberate steps:
-
Draft the Specification: Before writing any code, capture the desired behavior, boundaries, and non-goals of the system. Use clear and unambiguous language.
-
Define Acceptance Criteria: For each feature or requirement, specify how success will be measured, usually in the form of Given/When/Then scenarios.
-
Review and Approve the Spec: Stakeholders—including product owners, developers, and QA—must review and sign off on the specification before implementation begins.
-
Develop Tests from the Spec: Translate acceptance criteria directly into automated tests. For example, using a framework like Cucumber:
Feature: User Login Scenario: Successful login with valid credentials Given a registered user exists When the user logs in with correct credentials Then the user should be redirected to the dashboard -
Code to the Specification: Begin implementation, ensuring all code corresponds to elements defined in the spec.
-
Validate Against Acceptance Criteria: Continuously verify that the code meets the acceptance criteria through automated and manual testing.
Key Features
- Specification-First Approach: No code is written until the specification is complete and approved.
- Traceability: Every code and test artifact is linked to a specific requirement or acceptance criterion.
- Contractual Clarity: The specification is treated as a contract, not merely documentation.
- Parallel Development: Teams can work simultaneously, referencing the shared specification.
- Automated Test Generation: Acceptance criteria are structured to support direct conversion into executable tests.
Practical Example
Suppose you are implementing a feature for password reset. The spec might include:
- Must: Allow users to request a password reset via email.
- Should: Ensure the password reset token expires after 30 minutes.
- Will Not: Allow password reset via SMS.
Corresponding acceptance criteria:
Scenario: Password reset email is sent
Given a user has forgotten their password
When the user requests a password reset
Then a password reset email is sent to the user
Scenario: Token expires after 30 minutes
Given a user has received a password reset token
When 30 minutes have elapsed
Then the token is no longer validImplementation and tests proceed only after these specs are approved.
Best Practices
- Involve Stakeholders Early: Ensure that product managers, developers, and QA collaborate on writing and reviewing specs.
- Avoid Ambiguity: Use precise language and detailed acceptance criteria to eliminate misinterpretation.
- Keep Specs Up to Date: If requirements change, update the specification first, then revise implementation and tests.
- Automate Where Possible: Use tools that support spec-based test generation and validation.
- Enforce the Rule: Do not allow code to be written for features not in the specification.
Important Notes
- Spec-driven workflow is not just about documentation; it is about accountability and quality assurance.
- This methodology may require a cultural shift, especially in organizations accustomed to rapid prototyping or informal requirements.
- The upfront investment in specification pays dividends in reduced defects, improved predictability, and easier maintenance.
- Specs should be living documents, evolving as requirements change, but always serving as the single source of truth for implementation and testing.
- Adhering strictly to writing specs before code is essential; relaxing this rule undermines the workflow’s effectiveness.
For implementation details and examples, see the Claude Code Spec Driven Workflow skill on GitHub.
More Skills You Might Like
Explore similar skills to enhance your workflow
Auditing AWS S3 Bucket Permissions
Systematically audit AWS S3 bucket permissions to identify publicly accessible buckets, overly permissive ACLs,
DOTNET Devcert Trust
Configure and trust .NET development certificates for local HTTPS testing
Axiom Xcode MCP
iOS and xOS development guidance for Xcode MCP patterns and best practices
Breakdown Feature Implementation
breakdown-feature-implementation skill for programming & development
Create Implementation Plan
create-implementation-plan skill for programming & development
Analyzing Memory Forensics with LiME and Volatility
Performs Linux memory acquisition using LiME (Linux Memory Extractor) kernel module and analysis with Volatility