Skip to content
Skills Library
Programming · Building & coding

test-driven-development

/test-driven-development

Use when implementing new features or logic that requires tests — before writing implementation code. Covers Red-Green-Refactor cycle, stack-specific test patterns, test naming conventions, and mocking. Triggers: "write tests first", "TDD", "test-driven", "failing test", "red-green-refactor", "how do I test X".

Licence
MIT
Last repository change
30.06.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
5
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 30.06.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Use when implementing new features or logic that requires tests — before writing implementation code. Covers Red-Green-Refactor cycle, stack-specific test patterns, test naming conventions, and mocking. Triggers: "write tests first", "TDD", "test-driven", "failing test", "red-green-refactor", "how do I test X".

Triggers from the description

write tests firstTDDtest-drivenfailing testred-green-refactorhow do I test X
Original author description

Use when implementing new features or logic that requires tests — before writing implementation code. Covers Red-Green-Refactor cycle, stack-specific test patterns, test naming conventions, and mocking. Triggers: "write tests first", "TDD", "test-driven", "failing test", "red-green-refactor", "how do I test X".

How it works

  1. Iron Law
  2. When TDD Applies
  3. Red-Green-Refactor Cycle
  4. Test Naming Convention
  5. Stack Dispatch
  6. Quick Checklist
Original SKILL.md headings · 73 lines, 368 words
SKILL.md preview
---
name: test-driven-development
description: Use when implementing new features or logic that requires tests — before writing implementation code. Covers Red-Green-Refactor cycle, stack-specific test patterns, test naming conventions, and mocking. Triggers: "write tests first", "TDD", "test-driven", "failing test", "red-green-refactor", "how do I test X".
allowed-tools: Read, Write, Edit, Glob, Grep, Bash
metadata:
  triggers: TDD, test-driven, write tests first, failing test, red-green-refactor, test first, unit test, TDD cycle
  related-skills: systematic-debugging, verification-before-completion, code-reviewer
  domain: quality
  role: specialist
  scope: testing
  output-format: code
last-reviewed: "2026-03-14"
---

# Test-Driven Development

## Iron Law

**NO IMPLEMENTATION WITHOUT A FAILING TEST FIRST**

Write the test. Run it. See it fail (RED). Then implement until it passes (GREEN). Then refactor.

## When TDD Applies

**DO use TDD for:**
- New features and new logic
- Bug fixes (write a test that reproduces the bug first)
- Any code path that has business logic

**DO NOT use TDD for:**
- Config changes, renames, formatting
- Trivial one-line fixes with no logic
- See `leverage-patterns.md` Test-First section for the full rule

## Red-Green-Refactor Cycle

```
RED   -> Write a test that FAILS for the right reason
         Run it. Confirm it fails. If it passes without code -> test is wrong.

GREEN -> Write the MINIMUM code to make the test pass
         No extras. No "while I'm here" additions.

REFACTOR -> Clean up code without changing behavior
            Run tests again. Must still pass.
```

> For verifying regression tests are genuine (not vacuous): see `verification-before-completion` Red-Green protocol.
> For TDD during bug investigation: see `systematic-debugging` Phase 4 — Create Failing Test Case.

## Test Naming Convention

Pattern: `test_<what>_<when>_<expected>` (or `should_<expected>_when_<condition>`)

```
# Java
@Test void createUser_withDuplicateEmail_throwsConflictException()

# NestJS/Jest
it('should throw ConflictException when email already exists', ...)

# Python/pytest
def test_create_user_with_duplicate_email_raises_conflict():

# Flutter
test('createUser throws ConflictException when email is duplicate', ...)
```

## Stack Dispatch

| Stack | Reference File | Load When |
|-------|---------------|-----------|
| Java 21 / Spring Boot WebFlux | `references/tdd-patterns-java.md` | Writing tests for Spring Boot, WebFlux, reactive Java |
| NestJS 11 / TypeScript | `references/tdd-patterns-nestjs.md` | Writing tests for NestJS, TypeScript, Fastify |
| Python 3.14 / FastAPI | `references/tdd-patterns-python.md` | Writing tests for FastAPI, Pydantic, async Python |
| Flutter / Dart | `references/tdd-patterns-flutter.md` | Writing tests for Flutter widgets, Riverpod providers, Dart |

## Quick Checklist

Before claiming a test is real:
- [ ] Test FAILED before implementation (you saw the red output)
- [ ] Test PASSES after implementation (you saw the green output)
- [ ] Test name describes behavior, not implementation
- [ ] One assertion per logical outcome (not 10 assertions in one test)
- [ ] Mocks are used for external dependencies only (not to avoid writing logic)
Files in this package (5)
  • SKILL.md 3 KB
  • references/tdd-patterns-flutter.md 4 KB
  • references/tdd-patterns-java.md 3 KB
  • references/tdd-patterns-nestjs.md 3 KB
  • references/tdd-patterns-python.md 3 KB

Versions

RepositoryScoreLicence
This page · kumaran-is/claude-code-onboarding100MIT
GanyuanRan/Aegis100MIT
lucasouzadev/agent-kit-skill100MIT
zeative/satgas100AGPL-3.0
nikospavlopoulos/devops-mutant-powers100MIT
JohnStrunk/CommonCast100LGPL
Sanit-mann/The-Insectoids100MIT
mastro993/fstack100MIT
jelvodev/yaap100MIT

Database snapshot: 13.11.2026 · package version 510199f86cf7 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100tdd
    Enforces strict RED-GREEN-REFACTOR test-driven development — one failing test at a time, minimal code to pass, then refactor against an inline quality checklist and a test-provenance check (`provenance` runs it alone). Triggers on "tdd", "write tests", "test driven", "red green refactor", "/tdd".
  • 100tdd
    Enforce strict Test-Driven Development (TDD) using the red-green-refactor cycle. Use when writing unit tests, practicing test-first development, applying TDD discipline, or implementing features via red-green-refactor workflows.
  • 100tdd
    Test-driven development with red-green-refactor loop. Use when user wants to build features or fix bugs using TDD, mentions "red-green-refactor", wants integration tests, or asks for test-first development.
  • 100tdd
    Test-driven development with red-green-refactor loop. Use when user wants to build features or fix bugs using TDD, mentions "red-green-refactor", wants integration tests, or asks for test-first development.
  • 100tdd
    Test-driven development with red-green-refactor loop. Use when user wants to build features or fix bugs using TDD, mentions "red-green-refactor", wants integration tests, or asks for test-first development.
  • 100tdd
    Test-driven development with red-green-refactor loop. Use when user wants to build features or fix bugs using TDD, mentions "red-green-refactor", wants integration tests, or asks for test-first development.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.