Test driven

From OutlineDriven/odin-codex-plugin · View interactive version

Test driven is an AI agent skill from the GitHub repository OutlineDriven/odin-codex-plugin. Test-Driven Development (TDD) across any supported language. Use when implementing features or fixes with TDD methodology, writing tests before code, or following XP-style development.

How to use this skill

Skill file

Test-driven development (XP-style)

Tests define the specification. Design them from requirements before any implementation. The RED-GREEN-REFACTOR cycle is the heartbeat: write a failing test, make it pass with minimal code, then clean up while green.

Modern insight (2025): TDD + property-based testing pairing is the standard -- example tests prevent regressions, property tests discover edge cases. TDD also serves AI-assisted development: structural integrity keeps code understandable for both human and AI collaborators (Kent Beck, "Augmented Coding"). Mutation testing validates test quality beyond coverage metrics (TDD+Mutation: 63.3% vs TDD-alone: 39.4% mutation coverage).

See frameworks for language-specific test runners, property testing, coverage, and mutation tools.

See examples for brief TDD cycle patterns per language.


When to Apply

When NOT to Apply


Anti-patterns


Two Schools (decision guidance, not prescription)

Test Doubles Hierarchy


Workflow (language-neutral)

  1. CREATE -- Write failing tests: error cases -> edge cases -> happy paths -> property tests
  2. RED -- Run tests, verify all fail. If any pass, the test is wrong or behavior already exists.
  3. GREEN -- Minimal code to pass. No extras, no optimization, no cleanup.
  4. REFACTOR -- Clean up while green. Separate structural changes from behavioral (compress first, then extend). Re-run tests after every change.

Constitutional Rules (Non-Negotiable)

  1. Design Tests First: Plan all test cases from requirements before implementation; write each test iteratively in the RED-GREEN-REFACTOR loop
  2. RED Before GREEN: Each new test MUST fail before you write implementation for it
  3. Error Cases First: Implement error handling before success paths
  4. One Test at a Time: Write one failing test, make it pass, refactor, then add the next test
  5. Refactor Only on GREEN: Never refactor with failing tests

Validation Gates

| Gate | Pass Criteria | Blocking |

|------|---------------|----------|

| Tests Created | Test files exist for target module | Yes |

| RED State | All new tests fail before implementation | Yes |

| GREEN State | All tests pass after implementation | Yes |

| Coverage | >= 80% line coverage | No |

| Mutation | Mutation score reviewed (no threshold enforced) | No |

Exit Codes

| Code | Meaning |

|------|---------|

| 0 | TDD cycle complete, all tests pass |

| 11 | No test framework detected |

| 12 | Test compilation failed |

| 13 | Tests not failing (RED state invalid) |

| 14 | Tests fail after implementation (GREEN not achieved) |

| 15 | Tests fail after refactor (regression) |


Reference materials (mattpocock/skills tdd fold-in)

These reference docs are MIT-licensed (see /home/alpha/.claude/claude/skills/LICENSES.md for full attribution).

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.