ai-specflow
v0.1.1
Published
Specification-driven AI delivery bootstrapper and template
Maintainers
Readme
AI SPECFLOW
A Specification-Driven Development (SDD) governance framework for AI-assisted software delivery.
It treats User Stories as first-class artifacts and enforces traceability from requirements to code, tests, and PRs.
Adoption Paths
Option A: Install into an Existing Project (npx)
Use the installer when you want to add AI SpecFlow into an existing repository without replacing its current README:
npx ai-specflow initUseful options:
--dry-run: preview changes without writing files--force: overwrite existing scaffold files in.ai/anddocs/sdd/--with-claude: includeCLAUDE.mdand.claude/--with-cursor: includeAGENTS.mdand.cursor/--with-codex: includecodex.md--with-gemini: includeGEMINI.md--with-all: include all providers above
By default, init installs .ai/ and docs/sdd/. Provider-specific root and tool folders are opt-in via flags and use managed merge blocks for root wrappers.
Option B: Use as a Base Template (No Installer)
Use this mode if you prefer manual setup and full control.
Copy these into your target project root:
.ai/docs/sdd/- Optional root bridge files:
AGENTS.md,CLAUDE.md,codex.md,GEMINI.md - Optional project docs:
CONVENTIONS.md,QUICKSTART.md
Do not copy framework runtime/publishing files:
bin/scripts/package.json- This repository
README.md(keep your project's own README)
1) What This Project Is
This repository provides a structured operating model to deliver software with AI support while preserving engineering control:
- Specification-first workflow
- Progressive artifact generation per User Story
- Explicit quality gates
- Human approval at key decision points
It is designed to scale from small teams to complex systems without changing the core method.
2) Who This Is Not For
This framework may be a poor fit for:
- Teams seeking fully autonomous AI coding without human review gates.
- Fast throwaway prototypes where governance and traceability are unnecessary.
- Very small one-off scripts with no lifecycle, ownership, or release needs.
3) Project Philosophy and Principles
- Spec first, implementation second
Behavior changes start inspec.md. - Requirements must be testable
Acceptance criteria map to test cases (AC -> TC). - Risk-aware execution
MediumandHighrisks require explicit mitigation in planning. - Decision transparency
Major architectural changes follow RFC -> ADR. - End-to-end traceability
Requirements link to code, tests, and PR evidence. - Human accountability with AI acceleration
AI drafts and assists; humans approve and own decisions.
4) Governance Layers
- Requirement Governance —
spec.md,acceptance-criteria.md - Contract Governance —
contracts/(OpenAPI, schema, events) - Execution Governance —
plan.md - Quality Governance —
risk-matrix.md,test-plan.md, quality checklists - Traceability Governance —
traceability.md - Architectural Governance — RFC -> ADR
For low-complexity stories (for example CRUDL), use lean quality governance: keep risk-matrix.md concise (1-3 risks), but do not skip it.
5) Complete Workflow (Diagram + Explanation)
The workflow is progressive: do not create every file on day one.
Each step creates or updates only the artifacts needed for that stage.
flowchart TD
A[Create User Story Folder] --> B["/create-spec"]
B --> C[spec.md initial draft]
C --> D["/enrich-user-story"]
D --> E[Update spec.md + create acceptance-criteria.md + risk-matrix.md + contract proposal]
E --> F[Human validates/refines contracts/]
F --> G["/plan-ticket"]
G --> H[Create plan.md + test-plan.md]
H --> I{Human plan approval}
I -->|Approved| J["/develop-from-plan"]
J --> K[Update code + traceability.md + changelog.md]
K --> L["/review-ticket"]
L --> M{Quality gates pass?}
M -->|Yes| N[Merge and close: plan.md status done]
M -->|No| O[Fix gaps and re-run review]
O --> LWorkflow Narrative
- Create a user story folder in
docs/sdd/specs/user-stories/. - Generate an initial
spec.md. - Refine the story and generate acceptance criteria and risk matrix.
- Generate an AI contract proposal (
contracts/) and validate/refine it with a human owner. - Generate
plan.mdandtest-plan.mdfrom approved inputs. - Human approves plan, then implementation starts.
- Implementation updates code plus traceability and changelog artifacts.
- Review validates alignment with AC, risks, contracts, and tests.
- Close only when quality gates pass and traceability is complete.
6) Quick Start Guide
- Read
CONVENTIONS.mdanddocs/sdd/quality/guardrails.md. - Create a folder:
docs/sdd/specs/user-stories/US-000X-short-slug/. - Run
create-spec. - Run
enrich-user-story. - Review and refine the AI contract proposal in
contracts/. - Run
plan-ticketand setplan.mdtostatus: pending. - Human approval -> set
plan.mdtostatus: approved. - Run
develop-from-plan(moves plan toin-progress). - Run
review-ticketbefore merge. - After release checks, set
plan.mdtostatus: done.
For a longer onboarding walkthrough, see QUICKSTART.md.
7) Core Commands and How to Use Them
These commands are defined under .ai/commands/ and can be invoked via your assistant adapters.
| Command | Purpose | Primary inputs | Main outputs |
| ------------------- | ------------------------------------------------- | ------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| create-spec | Create initial story spec | Story folder path + problem/outcome/constraints | spec.md |
| enrich-user-story | Refine existing spec and derive quality artifacts | Story folder containing spec.md | Updated spec.md, acceptance-criteria.md, risk-matrix.md, draft contracts/ |
| plan-ticket | Build executable plan from approved artifacts | Spec, AC, contracts, risks, relevant ADRs | plan.md, test-plan.md |
| develop-from-plan | Implement approved plan with traceability | Story folder with approved/in-progress plan.md | Code changes, traceability.md, changelog.md, updated plan.md |
| review-ticket | Validate implementation against source artifacts | Spec, AC, plan, risk matrix, traceability, test plan, PR diff | Findings by severity + recommendation |
Chat-style Examples
Use .ai/commands/create-spec.md for docs/sdd/specs/user-stories/US-0012-my-feature.Use .ai/commands/enrich-user-story.md for docs/sdd/specs/user-stories/US-0012-my-feature.Use .ai/commands/plan-ticket.md for docs/sdd/specs/user-stories/US-0012-my-feature/spec.md.Use .ai/commands/develop-from-plan.md for docs/sdd/specs/user-stories/US-0012-my-feature/plan.md.Use .ai/commands/review-ticket.md against the current PR and report findings by severity.
8) Project Structure Explanation
docs/sdd/
specs/
user-stories/ # Real active stories (source of functional truth)
templates/ # Reusable artifact templates
examples/ # Educational references
decisions/
rfc/ # Proposals
adr/ # Final architectural decisions
quality/
guardrails.md
checklists/
pr-checklist.md
release-checklist.md
risk-matrix.md
test-strategy.md
.ai/
specs/ # Base AI standards
agents/ # Role-based guidance
commands/ # Workflow command definitions
adapters/ # Tool bridges
lessons/ # Reusable lessons learned9) Team Collaboration Model (PR Flow, Traceability, Story Lifecycle)
PR Flow
- Implement only from approved plan and defined contracts.
- Update
traceability.mdrows for implemented requirements. - Run quality checks (
pr-checklist.md, test strategy, risk mitigation verification). - Run review command and address findings.
- Merge when AC coverage, risk mitigations, and contracts are verified.
Traceability Policy
Use traceability.md to map:
Requirement -> Code Reference -> Test Reference -> PR/Commit
PR placeholder values:
DRAFTfor not-yet-executed rowsAUTO_PRfor rows that must be linked to the active PR- Final PR URL/number or commit SHA after merge
Story Lifecycle (Plan Status)
| Status | Meaning |
| ------------- | ---------------------------------------- |
| pending | Plan drafted, waiting for human approval |
| approved | Approved for implementation |
| in-progress | Implementation is active |
| done | Delivered, validated, and closed |
10) Typical User Story Folder Example
docs/sdd/specs/user-stories/US-0007-user-invitation/
spec.md
acceptance-criteria.md
risk-matrix.md
contracts/
openapi.yaml
plan.md
test-plan.md
traceability.md
changelog.mdConcrete Example
For a complete end-to-end reference, see:
docs/sdd/specs/examples/US-0001-crudl-countries/
This example includes all key artifacts working together:
spec.mdacceptance-criteria.mdrisk-matrix.mdcontracts/openapi.yamlplan.mdtest-plan.mdtraceability.mdchangelog.md
11) Contribution Guidelines Overview
Before opening a PR:
- Ensure behavior changes are reflected in
spec.md. - Keep acceptance criteria testable and mapped to tests.
- Confirm
Medium/Highrisks have mitigation tasks in plan. - Maintain contract consistency with implementation.
- Update traceability and changelog artifacts.
- Pass quality checklists and tests.
For ownership and governance:
- Follow
CONVENTIONS.md - Follow
OWNERS.mdcascade rules - Keep
.github/CODEOWNERSaligned with real teams
12) Project Profile (Placeholder)
Team-specific runtime and domain context should be documented in:
.ai/project-profile.md(create from.ai/project-profile.template.md)
Use CONVENTIONS.md as the baseline for naming, lifecycle, and governance rules, and keep .ai/project-profile.md for team/project-specific stack constraints and domain glossary details.
