/dev-practices:tddfrom dev-practices
Guides Test-Driven Development with red-green-refactor cycle. Activates only when explicitly asked for TDD. Covers interface design, tracer bullet tests, and incremental refactoring.
Ships in dev-practices. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
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.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub spences10/claude-code-toolkit --plugin dev-practicesOther plugins' skills for the same job