tdd-bdd-harness
A self-enforcing TDD + BDD discipline that Claude Code can install into any repo — and that CI refuses to let drift.
Ships as a Claude Code plugin and as a plain skill you can drop into any project. Same content, two install paths — pick whichever fits (both are covered below).
Battle-tested on a production FastAPI + React app: 529 scenarios / 0 gaps, pytest + Vitest, survived two adversarial audits.
The core idea
Every observable behaviour is written as a Gherkin scenario bound to a real test by a machine-verified citation — a promise ledger CI won't let rot:
# Backed by: tests/test_pricing.py::test_discount_never_exceeds_cap
Scenario: A stacked coupon can never push a line item below zero
Given a cart line at 10.00 with a 120% coupon
When the total is computed
Then the line item is floored at 0.00
A CI meta-guard parses the catalogue on every push and fails the build if a scenario cites a test that doesn't exist, a scenario has no proof, a @gap is left bare, or the coverage matrix is stale. Green tests can lie; this makes the lies visible.
What you get
- An executable scenario catalogue —
features/*.feature, one file per domain, indexed by a generated Scenarios.md and docs/scenarios/coverage-matrix.md.
- Machine-verified citations — every scenario names the test that proves it. Three ref forms are resolved automatically: unit/regression (
tests/x.py::test_fn), JS file-title (web/src/x.test.ts > does the thing), and live-only loop checks (scripts/quality/checks.py::check_fn).
- The ratchet — an unproven scenario must be tagged
@gap @wip. A bare @gap fails CI. Once gaps hit zero, they stay zero.
- A self-tested meta-guard — a test file that fails CI on unparseable Gherkin, unbacked scenarios, ghost/renamed citations, or stale matrix totals. Its own checkers have red-path proofs.
- A gap-grinding workflow — parallel-safe, one agent per domain with exclusive namespaces; mappings are applied as data, never hand-edited concurrently.
- An adversarial audit playbook — the field-tested catalogue of ways a green test lies (self-referential pins, seam-short pins, source-text pins, spec overstatement, vacuous fixtures) and how to kill each one.
- A quality-loop layer — for behaviours only a live system can prove (real process boot, real files, real HTTP headers, real paid API calls). First-class scenarios tagged
@loop, executed on a cron/nightly cadence, still citation-checked every CI run.
- An optional reviewer gate for model-pairing setups — e.g. Sonnet 5 writing + Opus 5 advising. Five placed gates (not one per scenario), a Phase 4 handoff contract so the reviewer's test spec survives transcription intact, and a mandatory mutation red-proof — the actual mechanism for a split workflow to match or beat a solo strong model. Degrades cleanly to solo or to a refute-by-default subagent when no reviewer tool exists.
- Automatic enforcement, not just documentation — three hooks (plugin install only, see below) fire without Claude needing to remember. A
SessionStart hook states the same-commit rule with the repo's live scenario/@gap counts before the first edit — the only point where it can still change what gets written. A PostToolUse hook reminds on the first test/.feature edit each session. A post-git commit hook flags both drift directions: a new test with no citing scenario, and source shipped with no test and no .feature at all. All three are silent no-ops outside a repo that has the harness, and none ever blocks — they nudge, because a diff scan can't tell a behaviour change from a rename.
- An opt-in formal layer (TLA+ and Lean 4) — for the few promises example tests rarely reach (an order of steps, a state machine, a bounded counter, a rule for any size), a
@formal scenario also cites a TLA+ model (# Model-checked by:) or a Lean proof (# Proved by:), always beside a real-code property test. A stamp tool runs the model's mutations (each must fail on the rule) and the model (it must pass), then fingerprints the model and the exact functions and constants it covers; the meta-guard fails on every test run when any of them changed since. See Formal layer.
- An adoption gate for repos that don't have it yet — in a repo with no harness, the
SessionStart hook checks whether one would land on something real (a test runner: pytest.ini, vitest.config.*, a package.json test script, … — or a codebase of 10+ tracked source files) and, if so, tells Claude to offer adoption once, through the skill's Gate. Installation is never automatic: the answer is recorded in .tdd-bdd-harness/state.local.json, and a declined project is never asked again.
Install
Option A — as a Claude Code plugin (recommended)