Tdd
Build a known behaviour or fix a reproducible bug test-first, red-green-refactor. Use when the expected behaviour is already clear enough to write down as a test.From its SKILL.md
npx -y skills add mthanhlm/compound --skill tddAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
3.0 KB, as published. Nobody here has run it
Red, green, refactor — one vertical slice at a time. A slice is thin end to end: one behaviour, proven by one failing test, made to pass by the smallest change that could work.
Reach for this when the behaviour is already known. When nobody has said what "done"
looks like yet, verify-first establishes that first, then hands over here.
The loop
Red
Write one test for one behaviour. Run it. Watch it fail, and read the failure — it must fail because the behaviour is missing, not because the test is broken.
A test that has never been seen failing is not evidence of anything. This is the step that gets skipped, and skipping it is how suites full of tests that assert nothing get built.
Completion criterion: the test ran, failed, and the message names the missing behaviour.
Green
Write the smallest change that makes it pass. Not the general solution — the specific one. Generality earned across three slices is better designed than generality guessed at during the first.
Run the whole suite, not just the new test. A green new test beside a red old one is a regression, not progress.
Completion criterion: the full suite passes.
Refactor
Now that the tests hold the behaviour still, improve the shape — naming, duplication, the seam the code sits behind. Run the suite after each change.
Refactor only what this slice touched. Improving code the slice never went near is scope creep with a respectable name.
Completion criterion: the suite still passes, and the diff is confined to this slice's surface.
Then take the next slice.
What makes a good test here
- Test behaviour through the interface, not internals. A test that reaches past the interface pins the implementation in place and has to be rewritten every time the implementation improves.
- One reason to fail per test. When it goes red, the name should tell you what broke.
- Real inputs over mocks. Mock what is slow, non-deterministic, or outside the process — a clock, a network call, a payment provider. Mocking the thing under test proves only that the mock works.
- Name it after the behaviour:
rejects an expired refresh token, nottest auth 3.
Bugs
A bug fix is the same loop with the red step handed to you:
- Reproduce it, and turn the reproduction into a failing test. If it cannot be
reproduced, or you cannot yet say why it breaks, that is the actual task — run
diagnosingfirst and come back with a mechanism. - Make it pass with the smallest change.
- Keep the test. It is now a regression test, and it is the part of the fix that outlives the fix.
Once the root cause is understood, it is worth filing — the capture skill puts it in
the wiki so the next person meets the explanation instead of the bug.