Skip to content
Back to skills

Applying Tdd

ASecurity

Use when writing code test-first or coaching the red-green-refactor cycle. Triggers on TDD, red-green-refactor, test-first, 'write the test first', a failing test before the code, triangulation, fake it till you make it, a test list, classical vs mockist TDD, or Detroit vs London school, even when the user doesn't say 'TDD'.

  • 6 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added November 30, 2026
ai-agentsgoapi

Works with

  • api

Security analysis

A100/100

Pro scans all 8 files and shows the line behind each finding

Scanned November 30, 2026

npx -y skills add xonovex/platform --skill applying-tdd --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Applying Tdd?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Applying Tdd
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/xonovex-applying-tdd/badge)](https://www.skillsdirectory.com/skills/xonovex-applying-tdd)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: applying-tdd
description: "Use when writing code test-first or coaching the red-green-refactor cycle. Triggers on TDD, red-green-refactor, test-first, 'write the test first', a failing test before the code, triangulation, fake it till you make it, a test list, classical vs mockist TDD, or Detroit vs London school, even when the user doesn't say 'TDD'."
---

# Test-Driven Development

Drive production code from a failing test, one small step at a time: red (write a test that fails), green (make it pass by any means), refactor (remove the duplication you just created). The goal is clean code that works, and the design emerges from the tests rather than being drawn up front.

## Essentials

- **Run the loop red -> green -> refactor** - never skip refactor; green-without-refactor is not TDD, see [references/red-green-refactor.md](references/red-green-refactor.md)
- **Write the failing test before the code** - production code exists only to make a red test pass, see [references/red-green-refactor.md](references/red-green-refactor.md)
- **Pick a green-bar strategy per step** - obvious implementation, fake it, or triangulate, see [references/green-bar-strategies.md](references/green-bar-strategies.md)
- **Keep a test list, work one item at a time** - list test ideas, never batch-write them, see [references/test-list-and-design.md](references/test-list-and-design.md)
- **Let the tests grow the design** - the emerging API is an output; judge the refactor against **applying-oop** and **analyzing-connascence**, see [references/test-list-and-design.md](references/test-list-and-design.md)

## Gotchas

- Skipping refactor leaves the duplication you committed to go green (including a constant duplicated between test and code): removing it is exactly what the third step is for.
- "Refactor" means change structure without changing behaviour while the test stays green; it is not "rewrite", "optimize", or "add the next feature".
- The test list is a list of test IDEAS, not a batch of tests written up front: write them one at a time to preserve the cycle.
- Test-first is the rhythm; classical vs mockist is an orthogonal design choice. You can do classical TDD test-first, so don't conflate the two.
- Neither classical nor mockist is "more modern": mockist trades integration coverage and tighter implementation-coupling for faster, smaller fixtures.
- A single good test's anatomy (AAA, FIRST, naming, the test-double taxonomy) belongs to **authoring-tests**. This skill owns only the rhythm in which you write it.

## Example

```text
Test list (shopping-cart total):
[ ] empty cart totals 0
[ ] one line item totals its price
[ ] two items sum
[ ] a percentage discount applies

RED      test: total([]) === 0                       -> fails (no function)
GREEN    return 0                                    -> obvious implementation
RED      test: total([{price: 500}]) === 500         -> fails
GREEN    return items[0].price                       -> fake it (duplicated constant)
RED      test: total([a, b]) === a.price + b.price    -> fails, forces generalize
GREEN    items.reduce((s, i) => s + i.price, 0)       -> sum; constant duplication gone
REFACTOR name the fold, extract lineTotal()           -> structure only, test stays green
```

## Progressive Disclosure

- Read [references/red-green-refactor.md](references/red-green-refactor.md) - Load when running or coaching the cycle: the two rules, what each of red/green/refactor allows, small steps, and why refactor is non-optional.
- Read [references/green-bar-strategies.md](references/green-bar-strategies.md) - Load when deciding how to make a red test pass: obvious implementation vs fake it vs triangulation and how to choose.
- Read [references/test-list-and-design.md](references/test-list-and-design.md) - Load when planning what to test next or letting tests shape the API: the test list, one-at-a-time discipline, classical vs mockist as a design choice.

Files in this skill

  • SKILL.md3.9 KB
  • eval-output.json3.3 KB
  • eval-trigger.json5.3 KB
  • moon.yml86 B
  • references/green-bar-strategies.md1.5 KB
  • references/red-green-refactor.md2.2 KB
  • references/test-list-and-design.md2.7 KB
  • sources.json4.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.