Skip to content
Skills Library
Programming · Testing

tdd

/tdd

Build one feature or fix one bug test-first in the red → green → refactor loop, with tests at agreed seams. Use when the user asks for TDD or test-first work on a single feature or bug fix, mentions "red-green-refactor", wants integration tests, or when implement reaches its build step. To take a whole slice, ticket or spec from its acceptance criteria to a reviewed commit, use implement instead.

Repository
skills ↗
Licence
MIT
Last repository change
12.11.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
3
Scripts
0
HTML comments
0
URLs in SKILL.md
1
Deprecation

No signals detected. Repository changed on 12.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Build one feature or fix one bug test-first in the red → green → refactor loop, with tests at agreed seams. Use when the user asks for TDD or test-first work on a single feature or bug fix, mentions "red-green-refactor", wants integration tests, or when implement reaches its build step. To take a whole slice, ticket or spec from its acceptance criteria to a reviewed commit, use implement instead.

Triggers from the description

red-green-refactor
Original author description

Build one feature or fix one bug test-first in the red → green → refactor loop, with tests at agreed seams. Use when the user asks for TDD or test-first work on a single feature or bug fix, mentions "red-green-refactor", wants integration tests, or when implement reaches its build step. To take a whole slice, ticket or spec from its acceptance criteria to a reviewed commit, use implement instead.

How it works

  1. What a good test is
  2. Seams: where tests go
  3. Anti-patterns
  4. Rules of the loop
Original SKILL.md headings · 41 lines, 778 words
SKILL.md preview
---
name: tdd
description: Build one feature or fix one bug test-first in the red → green → refactor loop, with tests at agreed seams. Use when the user asks for TDD or test-first work on a single feature or bug fix, mentions "red-green-refactor", wants integration tests, or when implement reaches its build step. To take a whole slice, ticket or spec from its acceptance criteria to a reviewed commit, use implement instead.
---

# Test-Driven Development

TDD is the red → green → refactor loop. This skill is the reference that makes that loop produce tests worth keeping: what a good test is, where tests go, the anti-patterns, and the rules of the loop. Every section applies on every cycle: consult them before and during the loop, not after.

When exploring the codebase, read `GLOSSARY.md` (if it exists) so test names and interface vocabulary match the project's domain language, and respect ADRs in the area you're touching.

## What a good test is

Tests verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't. A good test reads like a specification: "user can checkout with valid cart" tells you exactly what capability exists, and it survives refactors because it doesn't care about internal structure.

See [tests.md](tests.md) for examples and [mocking.md](mocking.md) for mocking guidelines.

## Seams: where tests go

A **seam** is the public interface you test at (an HTTP endpoint, a command, a module's exported function, a component's rendered output): where you observe behavior without reaching inside. Tests live at seams, never against internals.

**Test only at pre-agreed seams.** Before writing any test, write down the seams under test and confirm them with the user. No test is written at an unconfirmed seam. Seams already agreed (listed in the slice or ticket, or agreed by the skill that called this one) are confirmed: don't ask again. You can't test everything, so agreeing the seams up front is how testing effort lands on the critical paths and complex logic instead of every edge case.

Ask: "What's the public interface, and which seams should we test?" Give each proposed seam a one-line note on what it catches and what it misses.

When the shape of that interface is itself in question (how deep the module is, where the seam belongs, what the interface should expose), read `${CLAUDE_SKILL_DIR}/../codebase-design/SKILL.md` for the vocabulary (if that file isn't there, go on without it). It is the shared source of the module, interface, depth, seam, adapter, leverage and locality terms, and it is a reference to consult, not a session to run.

## Anti-patterns

- **Implementation-coupled**: mocks internal collaborators, tests private methods, or verifies through a side channel (querying the database instead of using the interface). The tell: the test breaks when you refactor but behavior hasn't changed.
- **Tautological**: the assertion recomputes the expected value the way the code does (`expect(add(a, b)).toBe(a + b)`, a snapshot derived by hand the same way, a constant asserted equal to itself), so it passes by construction and can never disagree with the code. Expected values must come from an independent source of truth: a known-good literal, a worked example, the spec.
- **Horizontal slicing**: writing all tests first, then all implementation. Bulk tests verify _imagined_ behavior: you test the _shape_ of things rather than user-facing behavior, the tests go insensitive to real changes, and you commit to test structure before understanding the implementation. Work in **vertical slices** instead: one test → one implementation → repeat, each test a **tracer bullet** that responds to what the last cycle taught you.

## Rules of the loop

- **Red before green.** Write the failing test first and run it: it must fail, and for the reason the behavior under test describes. If it passes, or fails for an unrelated reason, fix the test before touching production code. Then write only enough code to pass it. Don't anticipate future tests or add speculative features.
- **One cycle at a time.** One seam, one test, one minimal implementation per cycle.
- **Prepare on green.** Before writing the next failing test, if the code it will change is hard to change, refactor it first (preparatory refactor, in the Refactoring section of `${CLAUDE_SKILL_DIR}/../codebase-design/SKILL.md`).
- **Refactor on green, never on red.** Once the test passes, refactor the code this cycle touched, and its test, as the Refactoring section and the clean code rules in `${CLAUDE_SKILL_DIR}/../codebase-design/SKILL.md` say.
- **One folder per slice.** Where the code is organized by feature (vertical slice architecture), everything a use case needs lives in one folder named after it in business terms (e.g. `Features/Orders/PlaceOrder/`): entry point, request/response, handler, validation, data access, and its tests next to them or in the mirrored test folder the project uses. Slices don't call each other's handlers. When this slice duplicates logic another slice already has, stop and follow the Duplication rule in `${CLAUDE_SKILL_DIR}/../codebase-design/SKILL.md`. In a repo organized by technical layer, follow the existing structure.

---

Adapted from the `tdd` skill in [mattpocock/skills](https://github.com/mattpocock/skills) (MIT License, Copyright (c) 2026 Matt Pocock), with the refactor step and the folder rule added. `tests.md` and `mocking.md` are copied unchanged.
Files in this package (3)
  • SKILL.md 5 KB
  • mocking.md 1 KB
  • tests.md 2 KB

Versions

RepositoryScoreLicence
This page · mikeleg/skills100MIT
kdlbs/kandev100AGPL-3.0
sentimony/skills100MIT
sentimony/skills100MIT
TerminalSkills/skills100Apache-2.0
duronext/jig100MIT
xoai/sage100MIT
rolemodel/skills100MIT
matteocodogno/wellforge100MIT

Database snapshot: 13.11.2026 · package version d406fabbabc2 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 1 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100tdd-workflow
    TDD red-green-refactor workflow. Use when implementing a feature or bug fix test-first.
  • 100rc-tdd
    Test-driven development — red then green, one vertical slice, at agreed seams. Use to build or fix test-first. Not for picking a framework.
  • 100code-tdd
    Build a change test-first when the change is already clear. Agree the test entry points, then work in vertical slices of red, green and refactor through the public interface, and end with prove-tests. Use when the user asks for TDD, test-first work or red-green-refactor, or when…
  • 90tdd-workflow
    Standardized Test-Driven Development (TDD) cycle (RED-GREEN-REFACTOR-VERIFY). Use when user asks to write tests, do TDD, implement test-first, or ensure code quality with high test coverage and regression prevention.
  • 95test-driven-development
    Implement a feature or bug fix test-first through small red-green-cleanup cycles when the user explicitly requests TDD or red-green-refactor evidence.
  • 90tdd-cycle
    Red-Green-Refactor TDD loop with mandatory false-positive check. Use when: test, TDD, red-green, failing test, write test first, test-driven.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.