tdd-guardian

TDD Guardian for Claude Code — enforces strict test-driven development discipline with automated quality gates across unit, integration, e2e, and contract test lanes.
What it does
- Test lanes — each test tier gets its own command, trigger, and coverage participation. A 90-second browser suite gates
git push; it does not run after every task.
- Verified setup —
/tdd-guardian:init reads your CI config first, then dry-run probes every proposed command before writing it. A lane that discovers zero tests is reported, not configured.
- Coverage gates — 9 report formats parsed and merged, with an exact per-line union when the formats allow it and an explicitly-flagged approximation when they do not.
- Mutation testing — optional, per-trigger.
- Behavior-driven test quality — rejects wiring-only tests that assert mock calls without verifying observable behavior.
- Specification strength — a third axis beyond assertion level and lane: how much of the input space a test actually claims, S1 (one example) through S6 (metamorphic relation). A unit with a conservation law or a round-trip needs a property, not more examples.
- Adversarial specification review —
tdd-spec-adversary attacks the test matrix before any implementation exists, hunting for the simplest wrong implementation that would pass every case.
- Red receipts — records that your tests failed for a real reason before the code existed, then checks that no assertion moved on the way to green. Opt-in evidence; its absence reports as unverified, never as a violation.
- Critical paths — per-glob coverage thresholds and specification requirements, because one repo-wide number treats the payment core and the logging helper alike.
- Commit and push gating — hooks check that every lane bound to the action has a fresh pass.
- Greenfield-aware — a lane that has never had a test is in bootstrap: reported loudly on every run, but not blocking. The strict "zero tests is a failure" rule switches on permanently the moment that lane runs its first test.
Part of the xiaolai plugin marketplace.
Installation
Add the marketplace (once):
/plugin marketplace add xiaolai/claude-plugin-marketplace
Then install:
/plugin install tdd-guardian@xiaolai
Install fails with "Plugin not found in marketplace 'xiaolai'"? Your local marketplace clone is stale. Run claude plugin marketplace update xiaolai and retry — plugin install does not auto-refresh.
| Scope | Command | Effect |
|---|
| User (default) | /plugin install tdd-guardian@xiaolai | Available in all your projects |
| Project | /plugin install tdd-guardian@xiaolai --scope project | Shared with team via .claude/settings.json |
| Local | /plugin install tdd-guardian@xiaolai --scope local | Only you, only this repo |
Initialize for your project
Run /tdd-guardian:init inside your project. It detects your lanes, probes each one, and writes .claude/tdd-guardian/config.json.
Codex CLI
The same repository ships a Codex layout (.codex-plugin/ and codex/):
codex plugin marketplace add xiaolai/claude-plugin-marketplace
codex plugin add tdd-guardian@xiaolai
In a Codex session, start with $tdd-guardian-init, then $tdd-guardian-workflow (or the
individual $tdd-guardian-plan, -design-tests, -implement, -gate, … skills). Both tools
run the same scripts and share .claude/tdd-guardian/. Codex has no TaskCompleted event, so
only the commit/push guard runs as a hook (after you trust it in Codex); the taskCompleted
lanes run when $tdd-guardian-implement or $tdd-guardian-gate runs them. See
codex/AGENTS.md for the full list of differences.
Commands