dotfiles/agents/skills/tdd/SKILL.md
Test-driven bug fixing and feature development. Use when fixing bugs or building features — works with test suites or ad-hoc repro scripts. Enforces red-green-refactor vertical slices.
npx skillsauth add szymonkaliski/home-configuration 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.
First, determine which mode fits the project:
./tmp/repro/. This directory is gitignored scratch space — create it if it doesn't exist.Both modes follow the same red-green discipline. The only difference is where the "test" lives.
This is the primary workflow. Do NOT attempt a fix before you have a failing repro.
Test suite mode: Write a failing test case in the project's test framework that captures the broken behavior. Run the suite — confirm it fails for the right reason.
Ad-hoc mode: Write a self-contained repro script in ./tmp/repro/:
./tmp/repro/
├── repro.sh # or repro.js, repro.py, etc.
├── input.txt # test fixtures if needed
└── expected-output # what correct behavior looks like
The repro script should:
bash ./tmp/repro/repro.sh)Run it. Confirm it fails (exit 1). This is your proof the bug exists.
Before writing any code:
You can't test everything. Focus on critical paths and complex logic, not every possible edge case.
One test → one implementation → repeat.
WRONG (horizontal):
RED: test1, test2, test3, test4, test5
GREEN: impl1, impl2, impl3, impl4, impl5
RIGHT (vertical):
RED→GREEN: test1→impl1
RED→GREEN: test2→impl2
RED→GREEN: test3→impl3
...
DO NOT write all tests first. Tests written in bulk test imagined behavior, not actual behavior. Each test should respond to what you learned from the previous cycle.
Rules:
After all tests pass, look for refactor candidates. Never refactor while RED. Get to GREEN first.
See tests.md for examples and mocking.md for mocking guidelines.
Good tests verify behavior through public interfaces. They describe what the system does, survive internal refactors, and read like specifications.
Bad tests are coupled to implementation: mocking internal collaborators, testing private methods, asserting on call counts. Warning sign: test breaks when you refactor but behavior hasn't changed.
Mock only at system boundaries (external APIs, databases, time/randomness). Don't mock your own code.
[ ] Test/repro describes behavior, not implementation
[ ] Test/repro uses public interface only
[ ] Test/repro would survive internal refactor
[ ] Code is minimal for this test
[ ] No speculative features added
tools
Open the current plan file in nvim for user review
testing
Review uncommitted changes for issues, missed items, and improvements. Use when reviewing before commit or when user asks to check their work.
tools
Format, lint, test, and commit changes. Detects repo tooling automatically.
tools
Understand current work context from recent changes. Use at session start or when resuming work.