plugins/dev-practices/skills/tdd/SKILL.md
Test-Driven Development workflow with red-green-refactor cycle. Use only when explicitly asked for TDD, not for general test writing.
npx skillsauth add spences10/claude-code-toolkit tddInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Drive implementation through tests using the red-green-refactor cycle.
Adapted from Matt Pocock's TDD skill
Do not activate for general "write tests for X" or "add test coverage" requests. This skill is specifically for the TDD workflow where tests lead implementation.
Test behavior, not implementation. Every test should verify what the code does from the outside, not how it works inside. See deep-modules.md for the reasoning behind this.
Good tests act as a contract: they define what the module promises to its callers. If you can swap the internals completely and your tests still pass, they're testing the right thing.
Before writing any code, decide the public surface area:
Design for the caller, not the implementation. See interface-design.md.
Start with one test that exercises the simplest meaningful path through the feature. This test should:
RED: test exists, code does not
Run the test. Confirm it fails for the right reason (missing function, wrong return value — not a syntax error).
Write the minimum code to pass that one test. Do not write more than what the test demands. Hardcode return values if that's all it takes. The goal is a green test suite, not elegant code.
GREEN: test passes with minimal implementation
With the test passing, clean up. Remove duplication, improve names, extract helpers — but only while tests stay green. See refactoring.md.
REFACTOR: improve code quality, tests still pass
Add the next test. Pick the next simplest behavior that isn't covered. Follow the same cycle:
Build up complexity incrementally. Each cycle should take minutes, not hours.
After the core behavior works, add tests for:
Once all behavior is covered, do a final pass:
Use real dependencies when practical. Mock only at system boundaries — network calls, databases, file systems, clocks. See mocking.md for detailed guidance.
Write tests that are readable, independent, and fast. See tests.md for patterns on naming, structure, and assertion style.
development
Design and create Claude Skills using progressive disclosure principles. Use when building new skills, planning skill architecture, or writing skill content.
testing
Verify sources before presenting findings. Use when asked to research links or documentation.
data-ai
Analyze session history for learnings and persist to skills. Solves "memory zero" - correct once, never again.
tools
Validate, test, and distribute Claude Code plugins and marketplaces. Use when developing plugins, debugging validation errors, or preparing for distribution.