fail-first: Force Real TDD on Your AI Coding Agent
An open agent skill that makes the model write a failing test, verify the failure reason, then ship the smallest green fix — real TDD instead of tests written after the fact.
Agents love to write the implementation first, then add tests that pass on the first run. Those tests prove almost nothing: they describe what was built, not what should have been built, and many would still pass if the code were wrong.
fail-first is an open agent skill that forces real test-driven development. The agent must write one test, watch it fail for the expected reason, then write the smallest code that makes it pass.
Repo: github.com/RK905/fail-first
The loop
feature / bug / refactor
│
▼
1. Red ──────────── one test, one behavior
2. Verify red ───── fails (not errors) for the right reason
3. Green ────────── simplest code that passes
4. Verify green ─── full suite clean
5. Refactor ─────── only while green
Before “done,” the skill requires a mutation check and a short completion checklist. If production code already exists without a failing test, the skill deletes that code and starts from the test.
Test-quality rules it enforces
| Trap | What fail-first does |
|---|---|
| Expected value computed by the code under test | Uses literals or hand-checked fixtures |
| Test only checks that a mock was called | Asserts real behavior, or unmocks |
| Test pins a constant or exact copy | Tests the behavior that depends on it |
| Mock setup bigger than the test | Switches to an integration test |
Install
git clone https://github.com/RK905/fail-first /tmp/ff
cp -r /tmp/ff/skills/fail-first ~/.claude/skills/
Or copy skills/fail-first into <project>/.claude/skills/. Point Cursor, Codex, or Gemini CLI at SKILL.md if you do not use Claude Code.
Usage
/fail-first add retry with 3 attempts to fetchInvoice()
It triggers on its own when you ask for a feature, bugfix, or behavior change. Pair it with root-cause-first when the bug’s cause is still unclear, and with proof-before-done so “green” always includes a fresh suite run.
Credits and license
Derived from test-driven-development in obra/superpowers by Jesse Vincent. MIT licensed. See the fail-first repository for NOTICE and install details.
More in the set: five agent skills overview.
