AIhero

    tdd: Red, Green, Refactor for Agentic Coding

    Matt Pocock
    Matt Pocock

    Install this skill:

    npx skills add mattpocock/skills skill=tdd -y -g

    Source: mattpocock/skills/tdd

    What it does

    tdd guides an agent through test-driven development with a red, green, refactor loop.

    The central rule is that tests should verify behavior through public interfaces, not implementation details.

    Good tests

    Good tests read like specifications. They describe what the system does from the outside.

    They survive refactors because they do not care about private functions, internal collaborators, or the exact shape of implementation code.

    Bad tests

    Bad tests couple themselves to implementation details. They mock internals, test private methods, or fail when code is refactored even though behavior did not change.

    The skill pushes the agent away from those tests.

    One behavior at a time

    tdd rejects horizontal TDD:

    WRONG:
    RED: test1, test2, test3, test4
    GREEN: impl1, impl2, impl3, impl4

    Instead, it works vertically:

    RIGHT:
    RED → GREEN: test1 → impl1
    RED → GREEN: test2 → impl2
    RED → GREEN: test3 → impl3
    REFACTOR: clean up after green

    This keeps the agent from writing tests for imagined behavior before it understands the implementation.

    How it fits the workflow

    grill-me → domain-model → to-prd → to-issues → tdd

    Use tdd after to-issues has produced a vertical slice. Then implement one behavior at a time through public interfaces.

    Pairs well with

    Join over 54,000 Developers Becoming AI Heroes

    Engineering fundamentals are your biggest advantage. Learn how to leverage them and leave the vibe coders behind.

    I respect your privacy. Unsubscribe at any time.

    Share