Tdd

From FradSer/dotclaude · View interactive version

Tdd is an AI agent skill from the GitHub repository FradSer/dotclaude. BDD-driven test implementation: red-green loop mechanics, seams, mocking, and test quality under BDD Automation. Use when the user wants to write or improve tests during BDD implementation, needs guidance on test structure, or asks about test seams, mocking, or anti-patterns.

How to use this skill

Skill file

BDD-Driven TDD (Automation)

BDD cycles through three phases: Discovery (conversations → examples), Formulation (Gherkin scenarios), Automation (red-green-refactor, driven by BDD). This skill is the BDD-driven Automation reference — the how of test implementation, once /mattpocock:bdd has defined the what.

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.

When invoked during /mattpocock:implement or /mattpocock:bdd, use this skill as the test-writing authority. The /mattpocock:bdd skill governs the scenario design and Iron Law; this skill governs the test code quality under BDD discipline.

CRITICAL: BDD scenarios come first

If you reached this skill directly (not via /mattpocock:bdd or /mattpocock:implement), stop and ask the user: "Have you defined the Gherkin scenarios for this behavior yet?"

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 "mattpocock: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

Rules of the loop

CRITICAL: BDD-Driven — not standalone TDD

This skill is the Automation phase of the BDD lifecycle. It always runs under /mattpocock:bdd or /mattpocock:implement as BDD-driven TDD. If invoked directly, see the CRITICAL check at the top of this file — confirm scenarios exist before writing test code.

  1. Discovery (what behavior matters) — owned by /mattpocock:bdd via Gherkin scenarios
  2. Formulation (scenario as specification) — owned by /mattpocock:bdd via .feature files
  3. Automation (this skill) — the red-green loop that makes the scenario pass

When to invoke

Invoke this skill explicitly when:

When invoked directly, first check if Gherkin scenarios exist (see the CRITICAL check at the top). If not, redirect to /mattpocock:bdd before proceeding with Automation.

The /mattpocock:bdd and /mattpocock:implement skills load this automatically during the Automation phase — you do not need to invoke it separately in those flows.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.