con un clic
specflow
Spec-driven development with executable contracts
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Menú
Spec-driven development with executable contracts
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Basado en la clasificación ocupacional SOC
Selects the correct Specflow loop and forces a concrete run contract before work starts. Use when an agent is asked to start Specflow work, build a ticket, create/refine a PRD, investigate an existing product, run Gate D, choose between spec-build and feature-build, or "go find out about" Specflow loops. Compatible with Claude Code, Codex, K2.7, and other agents because it emits a plain YAML run_contract instead of relying on vendor-specific orchestration.
Audits a Specflow story/ticket for spec-compliance and surgically uplifts it — adding only the missing executable contract sections (SQL/RLS, TypeScript interfaces, invariant codes, Gherkin, acceptance criteria, Definition of Done, data-testid coverage) — then runs a pre-flight gate that refuses to mark the ticket compliant while CRITICAL or P1 findings remain. This skill should be used when the user asks to "make specflow compliant", "specflow audit", "uplift this story", "run specflow auditor", "is this story compliant", or invokes /specflow-audit on a story file or GitHub issue. It is the reliable replacement for ad-hoc inline "make it compliant" edits, which skip the gap-analysis, the section templates, and the pre-flight gate. Scope is strictly Specflow story/contract work — do NOT trigger on generic "make this code/PR compliant" requests unrelated to Specflow specs.
Simulates end-to-end usage of a Specflow story across multiple personas and divergent routes to discover gaps, edge cases, and unhandled branches BEFORE the story is built — then proposes each finding as a concrete story addition (new REQ, negative-path AC, Gherkin branch, or journey step). This is the high-value exploratory step run right after a story is created, distinct from the pre-flight compliance gate. This skill should be used when the user asks to "simulate this story", "simulate usage end to end", "find gaps and edges", "run personas through this", "stress-test this story", or invokes /specflow-simulate on a story file or GitHub issue. Scope is Specflow story exploration — it is generative (surfaces and proposes), not a build or a verification gate.
| name | specflow |
| description | Spec-driven development with executable contracts |
| version | 1.0.0 |
| author | Hulupeep |
Specs that enforce themselves. Turn requirements into contracts that break the build when violated.
Spec --> [Pre-Flight] --> Contract --> Test --> Code --> Verify
When this skill is active, Claude Code MUST:
docs/contracts/*.yml. If yes, read the contract and respect all non_negotiable rules.npm test -- contracts) and journey tests. Work is not done if tests fail.non_negotiable rules unless the user explicitly says override_contract: <contract_id>.passed, passed_with_warnings, or a human-acknowledged override:* status. A ticket with blocked, stale, or missing pre-flight section is NOT compliant..specflow/adapter-routing.yml exists, say Model routing active: and list the selected model/policy for the current stage before invoking it. Call max_budget_usd a budget cap / quota guard, not a guaranteed cost. For codex-exec, say that ChatGPT-authenticated Codex consumes Codex plan quota/credits rather than OpenAI API billing. If the routing file does not exist, stop and give the setup command:
specflow run --setup-routing.
Expensive/default routed adapters must not run until the user has confirmed the displayed model choices.A read-only simulation that catches broken specs before any code is written. Pre-flight runs at two points in the pipeline:
| Scope | Trigger | Lenses |
|---|---|---|
| Ticket | When any ticket is created or edited as a specflow ticket | Lenses 1-5 |
| Wave | Between dependency-mapper and sprint-executor, for all wave tickets simultaneously | Lenses 1-6 (includes Lens 6: Concurrent User Scenarios) |
All of the following invoke format-then-simulate, in that order, every time:
A ticket is NOT specflow-compliant until both format AND simulate have completed cleanly.
passed — no CRITICAL findings
passed_with_warnings — P1 findings present but acknowledged
blocked — CRITICAL findings unresolved; ticket cannot enter a wave
stale — ticket or referenced contract updated after last simulation
override:[reason] — human override applied; wave can proceed
Any value outside this enum is treated as blocked by waves-controller. The field is parsed directly — no regex, no interpretation.
After dependency-mapper completes and before sprint-executor fires:
blocked or stale → wave pauses, finding summary output to user, STOPblocked, STOPpassed, passed_with_warnings, or override:* → sprint-executor proceedsoverride_preflight: [ticket-id] reason: [reason text]
Sets simulation_status: override:[reason] on the ticket. Logged to docs/preflight/overrides.md with ticket-id, reason, RFC 3339 UTC timestamp, and user. board-auditor displays overrides distinctly (⚠️OVERRIDE prefix) and flags overrides older than the last contract update.
| Type | File Pattern | Enforced By | When |
|---|---|---|---|
| Architecture | feature_architecture.yml | Pattern scan (Jest/Vitest) | Before build |
| Feature | feature_*.yml | Pattern scan (Jest/Vitest) | Before build |
| Security | security_defaults.yml | Pattern scan | Before build |
| Accessibility | accessibility_defaults.yml | Pattern scan | Before build |
| Journey | journey_*.yml | Playwright E2E | After build |
contract_meta:
id: auth_feature
version: 1
covers_reqs: [AUTH-001, AUTH-002]
rules:
non_negotiable:
- id: AUTH-001
title: "API endpoints require authMiddleware"
scope: ["src/routes/**/*.ts"]
behavior:
forbidden_patterns:
- pattern: /router\.(get|post).*\/api\//
message: "Route missing authMiddleware"
required_patterns:
- pattern: /authMiddleware/
message: "Must use authMiddleware"
auto_fix:
strategy: "add_import"
import_line: "import { authMiddleware } from '@/middleware/auth'"
CONTRACT VIOLATION: AUTH-001 - API route missing authMiddleware
File: src/routes/users.ts
Line: 42
Match: router.get('/api/users', async (req, res) => {
Only humans can override non-negotiable rules. User must say:
override_contract: <contract_id>
When overriding: explain what rule is broken, warn about consequences, ask if contract should be updated permanently.
These patterns are enforced as non-negotiable in all src/**/*.{ts,js,tsx,jsx} files (excluding tests).
Forbidden patterns:
/(password|secret|api_key|apikey|token)\s*[:=]\s*['"][^'"]{8,}['"]/i
/sk_live_[a-zA-Z0-9]{20,}/
/sk_test_[a-zA-Z0-9]{20,}/
/-----BEGIN (RSA |EC )?PRIVATE KEY-----/
/ghp_[a-zA-Z0-9]{36}/
/xoxb-[0-9]{10,}-[a-zA-Z0-9]{20,}/
Fix: Use process.env.VAR_NAME instead.
Forbidden patterns:
/query\s*\(\s*['"`].*\$\{/
/query\s*\(\s*['"`].*\+\s*\w/
/execute\s*\(\s*['"`].*\$\{/
Fix: Use parameterized queries ($1, $2).
Forbidden patterns:
/dangerouslySetInnerHTML\s*=\s*\{\s*\{\s*__html:(?!\s*(sanitize|DOMPurify|purify))/
/\.innerHTML\s*=(?!\s*['"`]<)/
Fix: Sanitize with DOMPurify before rendering.
Forbidden patterns:
/\beval\s*\(/
/new\s+Function\s*\(/
Fix: Use JSON.parse or safe alternatives.
Forbidden patterns:
/readFile(Sync)?\s*\(\s*(?!path\.join|path\.resolve|__dirname)/
/writeFile(Sync)?\s*\(\s*(?!path\.join|path\.resolve|__dirname)/
Fix: Use path.join(__dirname, 'safe-dir', path.basename(input)).
Enforced in src/**/*.{tsx,jsx} files.
Forbidden: /<img\s+(?![^>]*\balt\s*=)[^>]*\/?>/
Forbidden: /<button(?![^>]*aria-label)[^>]*>\s*<(?:svg|img|[A-Z]\w*)[^>]*\/?\s*>\s*<\/button>/
Forbidden: /<input(?![^>]*(?:aria-label|aria-labelledby|id\s*=))[^>]*>/
Forbidden: /tabIndex\s*=\s*\{?\s*[1-9]/
When: Before any ticket is accepted as specflow-compliant; before each wave fires (between dependency-mapper and sprint-executor).
Recommended model: sonnet
Process:
ticket or wave) plus ticket bodies and contracts_dirdocs/contracts/ before running any lens (proof-of-work: list every file loaded)## Pre-flight Findings section in each ticket body (via specflow-writer for writes)docs/preflight/[ticket-id]-[timestamp].md without blockingThis agent is read-only. It never modifies source files, contract YAMLs, or migrations.
When: New feature needs acceptance criteria, Gherkin, and contracts.
Process:
Output: GitHub issue with Gherkin, data contracts, journey reference, and contract YAML files.
When: After implementation, before closing tickets.
Process:
Key rule: Issues with UI but no journey contract are PARTIAL at best, never PASS.
When: After implementation, before closing tickets or creating PRs.
Process:
Mandatory reporting: WHERE tests ran, WHICH tests, HOW MANY passed/failed, SKIPPED with reasons.
When: Contract tests fail. Invoked by orchestrator, never by users directly.
Scope: Only contract violations with enough YAML context to generate a fix. Never journey tests, build errors, or forbidden patterns without auto_fix hints.
Process:
Fix strategies: add_import, remove_pattern, wrap_with, replace_with
Route tasks to the optimal model tier for cost efficiency (~40-60% savings).
| Tier | Task Types |
|---|---|
| Haiku | Compliance audits, pattern matching validation, test execution and parsing, coverage checks, issue closing |
| Sonnet | Spec generation, contract YAML creation, test code generation, dependency mapping, component building, orchestration |
| Opus | Deep fix reasoning (heal-loop), complex architectural analysis |
Override in .specflow/config.json:
{
"model_routing": {
"default": "sonnet",
"overrides": {
"heal-loop": "opus",
"test-runner": "haiku"
}
}
}
All four gates must pass before work is considered complete.
npm test -- contracts
Pattern scans source code for forbidden/required patterns. Violations block the build.
npx playwright test
E2E tests verify user flows work end-to-end. Critical journeys must pass before release.
SEC-001 through SEC-005 scan for OWASP Top 10 patterns. Non-negotiable.
A11Y-001 through A11Y-004 scan for WCAG AA violations. Non-negotiable.
| Level | Meaning | Release Impact |
|---|---|---|
critical | Core user flow | Blocks release if failing |
important | Key feature | Should fix before release |
future | Planned feature | Can release without |
Never report "ready for release" if any critical journey is failing or not_tested.
Fix patterns are stored in .specflow/fix-patterns.json and scored by historical success rate.
| Tier | Confidence | Behavior |
|---|---|---|
| Platinum | >= 0.95 | Auto-apply immediately |
| Gold | >= 0.85 | Auto-apply, flag in commit message for review |
| Silver | >= 0.75 | Suggest only, do not auto-apply |
| Bronze | < 0.70 | Learning only, track for analysis |
Score rules: New patterns start at 0.50 (Silver). +0.05 per success, -0.10 per failure. Decay -0.01/week after 90 days unused. Below 0.30: archived.
Pattern entry format:
{
"id": "fix-sec-001-hardcoded-secret",
"contract_rule": "SEC-001",
"violation_signature": "Hardcoded secret detected",
"fix_strategy": "replace_with",
"fix_template": {
"find": "const KEY = \"sk_live_...\"",
"replace_pattern": "const KEY = process.env.STRIPE_SECRET_KEY"
},
"confidence": 0.50,
"tier": "silver"
}
/specflow Full autonomous loop: spec, contract, test, implement, verify
/specflow verify Contract validation only against existing contracts
/specflow spec Generate spec with REQ IDs for current issue or feature
/specflow heal Run fix loop on failing contract tests
/specflow status Render full execution dashboard (all 5 visualizations)
/specflow compile Compile CSV journeys to YAML contracts + Playwright stubs
docs/contracts/ exists. If not, create it and install default templates.docs/contracts/*.yml*.csv with journey headers)node scripts/specflow-compile.cjs <csv-file>Render the full execution dashboard with all 5 mandatory visualizations:
This command works at any point during wave execution. See agents/waves-controller.md for full visualization templates.
Core Loop: Spec --> [Pre-Flight] --> Contract --> Test --> Code --> Verify
REQ ID Format: AUTH-001 (MUST), AUTH-010 (SHOULD), J-AUTH-LOGIN
Contract Files: docs/contracts/feature_*.yml, journey_*.yml
Test Files: src/__tests__/contracts/*.test.ts, tests/e2e/*.spec.ts
Commands: npm test -- contracts, npx playwright test
Override: override_contract: <contract_id>
Pre-Flight: simulation_status: passed | passed_with_warnings | blocked | stale | override:[reason]
PF Override: override_preflight: <ticket-id> reason: <reason text>
When setting up Specflow in a new project, create this structure:
docs/
contracts/
feature_architecture.yml # ARCH rules
feature_*.yml # Feature rules
journey_*.yml # User flow DOD
security_defaults.yml # SEC-001..005
accessibility_defaults.yml # A11Y-001..004
CONTRACT_INDEX.yml # Central registry
src/
__tests__/
contracts/
*.test.ts # Contract pattern tests
tests/
e2e/
journey_*.spec.ts # Playwright journey tests
.specflow/
config.json # Model routing, overrides
fix-patterns.json # Fix pattern store
Inspired by the single-file skill packaging of forge by Ikenna N. Okpala.