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.
77%
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
Fix and improve this skill with Tessl
tessl review fix ./.agents/skills/tdd/SKILL.mdProject context — read these first, they are the parts this file cannot know:
- Test runner, tiers, and conventions:
constitution/local-engineering.md. It names the command that runs the suite, the file-naming convention the runner actually collects, and which tier a given behavior belongs in. A test written to a convention your runner does not collect silently never runs — that is the single most expensive mistake available here, so check before you write the first file.- What counts as source, and what counts as its paired test:
scripts/guards.config.sh. Those two regexes are the machine-readable version of "this change needed a test", and everything below is the procedure that keeps you on the right side of them. Keep them in step with your runner's include globs: a tree the runner covers but the config doesn't is silently un-guarded.- Code craft:
constitution/shared-code-craft.md. The portable rules the GREEN and refactor steps are held to. The review's standards axis reads with that file open; write with it open too.- Domain language:
docs/domain-glossary.md. Assertions and test names use those names. Do not invent local aliases inside test files — a second name for one concept is a distinction waiting to be invented.- Decision records:
docs/adr/. Respect the ones covering the area you're touching; a test that contradicts a binding decision is a finding, not a green.- The enforcement layer:
.githooks/pre-pushrunsscripts/tdd-pairing-guard.sh, which blocks a push whose source changes carry no test changes;scripts/tdd-pairing-guard-ci.shruns the same rule over the pull request, so a local bypass only defers the failure. This skill provides the procedure; the hook and the workflow provide the enforcement. They are not a substitute for each other: the guard checks that a test file moved, never that the test is any good.Shared invariant §3 is the reason all of this exists: the test suite is the signal an agent optimizes for, so it is the specification, not an afterthought — and the testing infrastructure is the ceiling on how correct any agent's output can be.
The rest of this file is universal advice, adapted from the upstream skill named at the bottom.
Core principle: Tests should verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't.
Good tests are integration-style: they exercise real code paths through public APIs. They describe what the system does, not how it does it. A good test reads like a specification - "user can checkout with valid cart" tells you exactly what capability exists. These tests survive refactors because they don't care about internal structure.
Bad tests are coupled to implementation. They mock internal collaborators, test private methods, or verify through external means (like querying a database directly instead of using the interface). The warning sign: your test breaks when you refactor, but behavior hasn't changed. If you rename an internal function and tests fail, those tests were testing implementation, not behavior.
A test that cannot fail is worse than no test: it converts an unknown into a false "verified" (shared invariant §3).
See tests.md for examples and mocking.md for mocking guidelines.
DO NOT write all tests first, then all implementation. This is "horizontal slicing" - treating RED as "write all tests" and GREEN as "write all code."
This produces crap tests:
Correct approach: Vertical slices via tracer bullets. One test → one implementation → repeat. Each test responds to what you learned from the previous cycle. Because you just wrote the code, you know exactly what behavior matters and how to verify it.
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
...When exploring the codebase, use docs/domain-glossary.md so that test names and interface vocabulary match the project's language, and respect the decision records in docs/adr/ covering the area you're touching.
Before writing any code:
Ask: "What should the public interface look like? Which behaviors are most important to test?"
You can't test everything. Confirm with the user exactly which behaviors matter most. Focus testing effort on critical paths and complex logic, not every possible edge case.
Write ONE test that confirms ONE thing about the system:
RED: Write test for first behavior → test fails
GREEN: Write minimal code to pass → test passesThis is your tracer bullet - proves the path works end-to-end.
For each remaining behavior:
RED: Write next test → fails
GREEN: Minimal code to pass → passesRules:
After all tests pass, look for refactor candidates:
Never refactor while RED. Get to GREEN first.
And keep the refactor out of the behavior commit (shared invariant §10) — a refactor-only pass is its own commit, with the suite green before and after.
[ ] Test describes behavior, not implementation
[ ] Test uses public interface only
[ ] Test would survive internal refactor
[ ] Code is minimal for this test
[ ] No speculative features addedAdapted from engineering/tdd in mattpocock/skills — MIT, see .agents/skills/LICENSE-mattpocock-skills.md. The project-context prelude above is this kit's; the five sidecars (tests.md, mocking.md, deep-modules.md, interface-design.md, refactoring.md) are upstream verbatim. Their examples are written in one language; the principles are not.
agranado2k/tic-tac-toe-haskell
7554191
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.