Enforces strict RED-GREEN-REFACTOR test-driven development — one failing test at a time, minimal code to pass, then refactor against an inline quality checklist and a test-provenance check (`provenance` runs it alone). Triggers on "tdd", "write tests", "test driven", "red green refactor", "/tdd".
82%
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
Enforce strict RED-GREEN-REFACTOR discipline. One test at a time. Tests describe WHAT the system does, never HOW.
Lens-eligible for the pr-reviewer agent: lens.md auto-loads when a diff changes tests.
Check $ARGUMENTS for the feature or behavior description.
$ARGUMENTS contains a feature description, use it directly.$ARGUMENTS starts with provenance, run only the provenance check on the named or changed test files. See rules/test-provenance.md.$ARGUMENTS contains "after" (e.g., /tdd after), run in Test-After Mode — write tests for existing code. See rules/test-after.md.$ARGUMENTS is empty, ask the user what behavior they want to implement or test.Before writing any tests:
**/*.test.*, **/*.spec.*, **/*_test.*, **/test_*.*, **/tests/** to identify the test framework, naming conventions, and directory structure.package.json scripts, Makefile, pyproject.toml, Cargo.toml, go.mod, or similar for the test command.TEST_CMD for use throughout the cycle. If you can run a single test file or test case, prefer that over the full suite.If no tests exist yet, ask the user which framework to use before proceeding.
Before diving into implementation, identify what matters most:
Present the test list to the user for confirmation before starting the cycle.
For each item in the test list, execute one full cycle. Follow the rules strictly:
See rules/red.md
Write exactly ONE failing test. Run it. Confirm it fails with the expected error. Do NOT write implementation code.
See rules/green.md
Write the MINIMUM code to make the failing test pass. No more. Run the test. Confirm it passes. Run the full relevant test suite to check for regressions.
Even in this phase, apply the basic readability primitives while you write: meaningful names, guard clauses for the cases the test forces, no nesting beyond 2 levels. These cost almost nothing during authoring but are expensive to bolt on later. Don't optimize, abstract, or add unrequested features — REFACTOR will handle deeper improvements.
See rules/refactor.md
Evaluate whether refactoring is needed. If yes, refactor while keeping all tests green. If no, move to the next cycle.
Judge the GREEN output against the quality checklist in rules/refactor.md — readability, nesting, naming, duplication and reuse, and neighbour-pattern match — and apply one named move at a time (e.g., "Extract Guarded Function", "Consolidate Parallel Maps"). Name each move in commit messages so reviews are reproducible.
After each RED-GREEN-REFACTOR cycle:
After all items in the test list are complete:
setTimeout works, that React renders, or that Go's http.ListenAndServe starts. Test YOUR code.buildUser(overrides?) patterns instead of inline object literals scattered across tests.Follow the project's existing convention. If none exists, use:
should [expected behavior] when [condition]describe('createOrder') → it('should reject order when inventory is zero')Apply these primitives inline during GREEN; walk the full checklist in rules/refactor.md during REFACTOR.
GREEN-phase primitives (apply inline while writing the minimal implementation):
ifs — flat code is easier to read and easier to test.pendingOrders beats arr2.For REFACTOR, address each checklist finding as a separate refactoring move (one change at a time per the "Procedure" below), and name the move in the commit message.
| Anti-Pattern | Why It's Bad | What to Do Instead |
|---|---|---|
| Writing tests in bulk | Tests imagined behavior, not observed | One test per cycle |
| Testing and implementing together | Unconsciously designs tests around implementation | Strict phase separation |
| "Make sure tests pass" prompt | Encourages implementation-first thinking | "Write a FAILING test" |
| Changing test expectations to pass | Masks real bugs | Fix the source code |
| Testing private methods | Couples tests to implementation | Test through public API |
| Copy-pasting mock setup | Brittle, hard to maintain | Extract shared fixtures |
mthines/agent-skills
0ec47ca
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.