Catalog
mattpocock/tdd

Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.

NewUpdated Oct 8, 2026

Test-Driven Development

TDD is the red → green 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 for examples and mocking.md for mocking guidelines.

Seams: where tests go

A seam is the public boundary you test at: the interface 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. 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), call the Skill tool with "codebase-design" for the vocabulary. 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, then only enough code to pass it. Don't anticipate future tests or add speculative features.
  • One slice at a time. One seam, one test, one minimal implementation per cycle.
  • Refactoring is not part of the loop. It belongs to the review stage (see the code-review skill), not the red → green implementation cycle.
Files4
4 files · 4.7 KB

Select a file to preview

Overall Score

87/100

Grade

A

Excellent

Grades are signals, not a certification. Always review a skill yourself before use.

Safety

92

Quality

88

Clarity

89

Completeness

82

Summary

This skill teaches test-driven development (TDD) through the red-green-refactor cycle. It covers what makes a good test, where to place tests (seams), common anti-patterns (implementation coupling, tautological tests, horizontal slicing), and the core rules of TDD. The skill includes supporting documentation on mocking strategies and practical examples of good vs. bad tests, with emphasis on testing behavior through public interfaces rather than implementation details.

Static Analysis Findings

1 finding

Patterns detected by deterministic static analysis before AI scoring. Hover over any finding code for detailed information and remediation guidance.

Credential Exposure
SEC-020Direct .env File Access

Direct .env file access

mocking.md.env

Detected Capabilities

read documentationcode analysistest design guidancedocumentation reference

Trigger Keywords

Phrases that agents use to match this skill to user intent.

test-driven developmentred-green-refactorwrite tests firsttest seamsmock external dependenciesintegration testing

Risk Signals

INFO

SEC-020: Direct .env file access reference

mocking.md, line 17

Use Cases

  • Write tests before implementation using red-green-refactor
  • Design test seams at system boundaries before coding
  • Identify and avoid implementation-coupled test anti-patterns
  • Mock external dependencies (APIs, databases) without over-mocking internal code
  • Review and improve existing test suites for behavior-driven correctness
  • Establish shared testing vocabulary and patterns across a codebase

Quality Notes

  • Strong emphasis on testing behavior vs. implementation details—anti-patterns section is particularly clear and actionable
  • Examples are concrete and practical, with side-by-side good/bad comparisons that illustrate the point
  • Clear workflow: agree on seams first, then write one test-implementation cycle at a time
  • Explicitly references related skills (code-review, codebase-design) with appropriate disambiguation
  • Supporting files (tests.md, mocking.md) are well-integrated and directly reinforce core concepts
  • The .env reference in mocking.md is a design guideline example (showing what NOT to do), not an instruction to access .env files
  • Limitations are clearly stated: can't test everything, so seams must be prioritized
  • Could benefit from more edge case examples (empty carts, network failures, timeout handling)
Model: claude-haiku-4-5-20251001Analyzed: Oct 8, 2026

Reviews

Add this skill to your library to leave a review.

No reviews yet

Be the first to share your experience.

Version History

  1. v2.3

    Content updated

    ✦ AIAdds requirement to annotate proposed seams with one-line notes on coverage.

    2026-10-08

    LATEST
  2. v2.2

    Content updated

    ✦ AIReferences GLOSSARY.md instead of CONTEXT.md for codebase exploration vocabulary.

    2026-09-30

    View This Version
  3. v2.1

    Content updated

    ✦ AIRestructures philosophy and workflow; replaces horizontal-slicing anti-pattern with emphasis on seams and tracer bullets. Adds agents/openai.yaml.

    2026-09-09

    View This Version
  4. v2.0

    Contract changed: description

    ✦ AIActivation description narrowed (removes codebase-glossary mention); planning workflow shifted to CONTEXT.md lookup and delegates design review to /codebase-design skill.

    triggering2026-06-28

    View This Version
  5. v1.0

    2026-05-02

    View This VersionInitial version

Use mattpocock/tdd in your dev environment

Command Palette

Search for a command to run...