mcpField
T
test-driven-development

test-driven-development

github.com/oakossTesting & quality2092 installsUpdated 11w ago
Repository

About test-driven-development

test-driven-development is a skill for developers that structures code changes around a failing test, minimal implementation, and refactoring. It emphasizes tests of observable behavior and proving the need before changing production code.

Key features

  1. 01Red-green-refactor cycle
  2. 02Complete one test at a time
  3. 03Test behavior rather than implementation
  4. 04Mock only at I/O boundaries
  5. 05Refactor after tests pass
  6. 06Reproduce bugs with failing tests

Use cases

  1. 01Write tests for a feature in vertical slices
  2. 02Reproduce a bug before fixing it
  3. 03Design interfaces through tests
  4. 04Refactor while keeping tests green

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/oakoss/agent-skills --skill test-driven-development

After installing, type/test-driven-developmentin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
design-for-testability.md
mocking-boundaries.md
test-quality.md

Details

From the project README

Test-Driven Development

Write one failing test that describes the next behavior, write the minimal code to pass it, then refactor while green. Every production change starts with a test that proves the need exists. This is the discipline within each vertical slice — not framework syntax, but when and why to write tests.

Skip for exploratory prototyping, config-only changes (environment variables, feature flags), visual/CSS-only tweaks, and one-off scripts that won't be maintained.

Quick Reference — TDD Cycle

PhaseActionRule
REDWrite one test that fails for the right reasonNo production code without a failing test
GREENWrite the simplest code that makes the test passResist the urge to generalize prematurely
REFACTORImprove structure while all tests stay greenNever change behavior and structure at once

Quick Reference — Principles

PrinciplePractice
One test at a timeComplete the full red-green-refactor cycle before writing the next test
Behavior over implementationTest what code does, not how it does it; assert outputs and side effects
Vertical slicesTDD one end-to-end behavior at a time, not one layer at a time
Mock at boundariesMock I/O, network, filesystem, clock. Never mock internal collaborators
Deep modulesDesign small interfaces with rich internals; fewer tests cover more behavior
Refactor only when greenAll tests pass before touching structure; refactoring under red hides new bugs
Design through testsThe first test IS the API design decision; awkward tests signal awkward interfaces
Failing test for every bugReproduce the bug as a failing test before writing the fix

Planning Before Coding

StepActionOutput
1Identify behaviorsList of observable behaviors the feature must exhibit
2Order by dependencySequence where each test builds on prior passing tests
3Design the interfaceFunction signatures, parameter types, return types
4Identify mock boundariesExternal dependencies that need test doubles

Common Mistakes

MistakeCorrect Pattern
Writing all tests firstOne test at a time. Complete the cycle before starting the next
Testing private methodsTest through the public interface; private methods are implementation detail
Mocking internal collaboratorsOnly mock at I/O boundaries; trust your own code
Writing code before a failing testRED first. The failing test proves the behavior is missing
Refactoring while tests are redGet to GREEN first, then refactor with confidence
Tests coupled to call sequencesAssert on outputs and state, not on which internal methods were called
Skipping the refactor phaseGREEN is not done. Clean up duplication and naming before moving on
Hardcoding expected valuesUse triangulation: add a second test case to force the general solution
One giant test per featureOne test per behavior — small, focused, independently meaningful

Delegation

  • Slice decomposition: If the tracer-bullets skill is available, use it to decompose features into vertical slices before applying TDD within each slice
  • Test framework syntax: Delegate framework-specific patterns to vitest-testing, e2e-testing, or api-testing skills
  • Feature planning: If the plan-first-development skill is available, use it for upfront planning before entering the TDD cycle
  • Individual TDD cycles: Delegate each red-green-refactor cycle to a Task subagent to keep context focused

References

  • Test Quality — good vs bad tests, what to test, naming, triangulation, refactoring signals
  • Mocking Boundaries — boundary rule, test doubles, dependency injection, anti-patterns
  • Design for Testability — deep modules, interface-first design, pure functions, computation vs I/O

Comments

Markdown supported