Test-driven development with red-green-refactor loop. Use when user wants to build features or fix bugs using TDD, mentions "red-green-refactor", wants integration tests, or asks for test-first development.
67
84%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Core principle: tests verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't.
See tests.md for examples and mocking.md for mocking rules.
Do not write all tests first, then all implementation. Bulk-written tests verify imagined behavior — they test the shape of things (signatures, data) rather than user-facing behavior, and become insensitive to real changes.
Correct: vertical slices. One test → one implementation → repeat. Each test responds to what you learned from the previous cycle.
WRONG (horizontal): RED: t1,t2,t3,t4,t5 → GREEN: i1,i2,i3,i4,i5
RIGHT (vertical): RED→GREEN: t1→i1, t2→i2, t3→i3, ...Before writing code:
Ask: "What should the public interface look like? Which behaviors matter most?"
Write ONE test for ONE behavior. RED → minimal code → GREEN. Proves the path works end-to-end.
For each remaining behavior: RED (next test fails) → GREEN (minimal code passes).
Rules: one test at a time; only enough code to pass it; no anticipating future tests; tests stay on observable behavior.
After GREEN, look for refactor candidates:
Never refactor while RED. Get to GREEN first.
[ ] Test describes behavior, not implementation
[ ] Test uses public interface only
[ ] Test would survive an internal refactor
[ ] Code is minimal for this test
[ ] No speculative features addedIf your function assembles a prompt that gets shipped to an LLM (or stored in a cache key), add one regression test that pins the exact byte sequence for a representative input. Prompt-cache hit rates depend on byte-equal prefixes; a refactor that re-orders fields, swaps a sort -u for awk '!seen[$0]++', or relies on find's readdir order can silently change the bytes without changing the test's observable behavior — and shred the cache. Test seen in practice: extracting a helper changed find issues -name '*.md' order from one machine to another; behavior tests stayed green; prompt cache lost ~40% of its hit rate for a day.
belchman/claude-skills
77a9e6b
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.