Skip to content
Back to skills

Tdd

ASecurity

Test-driven development with the red-green-refactor loop. Use when building a feature or fixing a bug test-first, when the user mentions "red-green-refactor" or "test first", or when a bug fix needs a reproducing test before the fix.

  • 3 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 19, 2026
ai-agentsgoexpresstesting

Security analysis

A100/100

Scanned November 9, 2026

npx -y skills add konstantinos-malavazos/claude-code-playbook --skill tdd --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Tdd?

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

Security grade badge for Tdd
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/konstantinos-malavazos-tdd/badge)](https://www.skillsdirectory.com/skills/konstantinos-malavazos-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: tdd
description: >-
  Test-driven development with the red-green-refactor loop. Use when building a feature
  or fixing a bug test-first, when the user mentions "red-green-refactor" or "test
  first", or when a bug fix needs a reproducing test before the fix.
---

# TDD — red / green / refactor

> Prior art: mattpocock/skills@49dd158 `tdd` (MIT) — the two anti-patterns below.

## The loop
1. **Red** — write a test that expresses the desired behaviour and **fails** for the
   right reason. Run it. Confirm it fails.
2. **Green** — write the **minimum** code to make it pass. No more.
3. **Refactor** — clean up with the test as a safety net. Re-run. Stay green.

## For bug fixes specifically
- First write a test that **reproduces the bug** (fails on current code). This proves you
  understand the bug and prevents regression.
- Then make it pass with the smallest change.
- "Fix the bug" → "write a failing test that reproduces it, then make it pass."

## Rules
- **Test at the seam the plan names.** Where `planner.md` has a `## Testing seams` section,
  test only at those seams. Where the plan names one test instead — a fix plan's "the test
  that catches THIS bug" — that is the seam. Where nothing names one, test at the public
  boundary the change crosses and name it in your handoff, so review can judge it. Run
  standalone, agree the seams with the user before the first test.
- Test **behaviour through public interfaces**, not private internals. Tests shouldn't
  break when you refactor without changing behaviour.
- One behaviour per test; a clear name that states the expectation.
- Don't test the framework, generated code, or impossible states.
- Keep the arrange/act/assert structure obvious.
- Find the public interface with `find_symbol` before you write the test against it, and run
  `get_diagnostics_for_file` on the test file before you run it: a test that does not compile
  is not a failing test.

## Anti-patterns
- **Tautological** — the assertion computes the expected value the way the code does, so the
  test passes by construction and can never disagree with the code. Take expected values from
  an independent source: a known-good literal, a worked example, the spec.
- **Horizontal slicing** — all the tests first, then all the code. The tests pin an imagined
  shape before you understand the implementation. Instead: one test, then the code that
  passes it, then the next test.

## When NOT to force it
Exploratory spikes and throwaway prototypes don't need TDD, but the moment code is
meant to survive, back it with tests.

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.