aiprompter.site
Software

TDD skill: a failing test before working code

Try Matt Pocock's TDD approach on a shipping-fee function, with three executed red/green cycles, original code and checked output.

Source and original example ↗ · MIT · Matt Pocock · AIPrompter adaptation

Published on AIPrompter: 2026-11-09 · GitHub: 318424 repository stars; not verified installs · Checked: 2026-11-09

Engagement source ↗ · Execution record and code ↗

WORKED EXAMPLE

Sample output

Sample input

Interface: shipping_fee(total).
99.99 → 4.99
100 → 0
-1 → ValueError
Python; no network, API key or package installation.

Sample output

1. 99.99 case: RED → GREEN.
2. 100 boundary: RED → GREEN.
3. Negative total: RED → GREEN.
Total: 3 behavioral tests passed.

Final code:
def shipping_fee(total):
    if total < 0:
        raise ValueError('negative total')
    return 0 if total >= 100 else 4.99

November 9, 2026: the AI editor wrote original example code and actually executed six Python runs. The Matt Pocock plugin was not installed; this is a local application of its method. The 318,424 stars belong to the whole mattpocock/skills repository, not the TDD file. Upstream license: MIT. Your AI tool may have separate costs.

Raw prompt

Develop a shipping-fee function in small test cycles. State the public interface first: shipping_fee(total). Rules: orders of 100 or more ship free; smaller orders cost 4.99; negative totals are invalid. For each behavior, run a failing test first, write only enough code to pass it, then rerun existing tests. Test the function's observable result rather than its internals. Record every red and green result.

How to use this prompt

1. Pick one small behavior and expected result. 2. Agree on its interface. 3. Observe a failing test before claiming the fix works. 4. Rerun previous tests after every fix. Use the official repository if you choose to install the skill; this page does not install a plugin.