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 Sep 9, 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 CONTEXT.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?"

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

88/100

Grade

A

Excellent

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

Safety

92

Quality

87

Clarity

89

Completeness

82

Summary

A reference skill for test-driven development (TDD) that teaches the red-green-refactor loop, what makes a good test, where tests belong (seams), common anti-patterns, and the rules of the TDD cycle. The skill guides agents to write tests against public interfaces, avoid implementation coupling, and work in vertical slices rather than horizontal layers. It includes supporting documentation on mocking guidelines and good vs. bad test examples.

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

File reading (CONTEXT.md, supporting docs)Code analysis (identifying seams, interfaces, anti-patterns)Reference documentation consultation

Trigger Keywords

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

red green refactortest firstwrite failing testintegration testmock external apistest seamstdd cycle

Risk Signals

INFO

SEC-020: Reference to .env file in mocking.md documentation (dependency injection example showing process.env.STRIPE_KEY)

mocking.md | Hard to mock section

Use Cases

  • Write new features test-first using red-green-refactor
  • Fix bugs by writing failing tests before implementation
  • Design and agree on seams before writing tests
  • Identify and refactor implementation-coupled tests
  • Learn when and how to mock at system boundaries
  • Avoid tautological or horizontally-sliced test patterns

Quality Notes

  • Skill clearly defines TDD principles with practical, executable rules (red before green, one slice at a time)
  • Excellent anti-pattern coverage—implementation coupling, tautological tests, horizontal slicing—with concrete TypeScript examples
  • Good pedagogical structure: defines terms (seams), shows negative examples, provides independent verification for expected values
  • Supporting files (mocking.md, tests.md) are well-organized with side-by-side good/bad comparisons for learning
  • Seam agreement step is well-documented: requires user confirmation before testing, which prevents scope creep
  • Clear reference to other skills (codebase-design) helps users know when to pivot to design work
  • Rules section is prescriptive and actionable—agents can follow them step-by-step
Model: claude-haiku-4-5-20251001Analyzed: Sep 9, 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.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

    LATEST
  2. 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
  3. v1.0

    2026-05-02

    View This VersionInitial version

Use mattpocock/tdd in your dev environment

Command Palette

Search for a command to run...