Skip to content
Back to skills

Test Driven Development

ASecurity

Enforce Red-Green-Refactor TDD cycle. Use when implementing any new class or method — write the failing test first, then make it pass. Never write production code before a failing test exists.

  • 8 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 20, 2026
testingaws

Security analysis

A100/100

Scanned September 20, 2026

npx -y skills add tstapler/dotfiles --skill test-driven-development --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Test Driven Development?

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

Security grade badge for Test Driven Development
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tstapler-test-driven-development/badge)](https://www.skillsdirectory.com/skills/tstapler-test-driven-development)

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: test-driven-development
description: Enforce Red-Green-Refactor TDD cycle. Use when implementing any new class or method — write the failing test first, then make it pass. Never write production code before a failing test exists.
---

# Test-Driven Development

## Iron Law

**No production code without a failing test first.**

If you have written production code before a failing test:
1. Delete the production code
2. Write the failing test
3. Make it pass with minimal code
4. Then refactor

There are no exceptions. "This is too simple to need a test first" is rationalisation.

## Red-Green-Refactor Cycle

### RED — Write the failing test

1. Write the test for the behaviour you want
2. **Verify the test fails** before writing any production code.
   If you didn't watch it fail, you don't know if it tests the right thing.

### GREEN — Write minimal production code

Write the smallest amount of production code that makes the test pass.
Do not add logic that isn't required by a failing test.

### REFACTOR — Clean up

Clean the code while keeping tests green:
- Extract methods, rename for clarity, remove duplication
- Tests must still pass after every refactor step

## Required Test Cases Per Method

For each public method, write at minimum:
- Happy path (normal success)
- Error path (dependency throws or returns empty/null)
- Edge case (null, empty collection, boundary value)

## Anti-Patterns to Refuse

| Thought | Reality |
|---------|---------|
| "This is too simple to need a test" | Simple code breaks too. Write the test. |
| "I'll write tests after to save time" | You won't. The test discovers design flaws. |
| "The test would just mirror the implementation" | Then the implementation is too tightly coupled. |
| "Integration tests cover this" | Unit tests run in milliseconds. Write both. |

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.

Comments

Loading comments…