Skip to content
Skills Library
Programming · Testing

test-driven-development

/test-driven-development

Use when implementing a feature or fixing a bug test-first: write a failing test, make it pass with the minimum code, then refactor. Covers the red-green-refactor loop, what is worth testing, and the common pitfalls that make TDD backfire.

Repository
md-files ↗
Licence
MIT
Last repository change
03.10.2026

Assessment and security

90/ 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.
Content25 / 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
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 03.10.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 a feature or fixing a bug test-first: write a failing test, make it pass with the minimum code, then refactor. Covers the red-green-refactor loop, what is worth testing, and the common pitfalls that make TDD backfire.

Original author description

Use when implementing a feature or fixing a bug test-first: write a failing test, make it pass with the minimum code, then refactor. Covers the red-green-refactor loop, what is worth testing, and the common pitfalls that make TDD backfire.

How it works

  1. The loop: Red → Green → Refactor
  2. Bug fixing with TDD
  3. What to test
  4. Pitfalls
  5. When strict TDD doesn't fit
Original SKILL.md headings · 49 lines, 346 words
SKILL.md preview
---
name: test-driven-development
description: >-
  Use when implementing a feature or fixing a bug test-first: write a failing test,
  make it pass with the minimum code, then refactor. Covers the red-green-refactor
  loop, what is worth testing, and the common pitfalls that make TDD backfire.
---

# Test-Driven Development

Write the test before the code. The test specifies the behavior; the code satisfies
it. This keeps the design testable, catches regressions immediately, and produces a
suite that documents intent.

## The loop: Red → Green → Refactor

1. **Red.** Write one small test for the next increment of behavior. Run it. It must
   fail — and fail for the *right reason* (the behavior is missing, not a typo). A test
   that passes before you write the code tests nothing.
2. **Green.** Write the minimum code to make it pass. Resist building beyond the test.
   Ugly-but-correct is fine here.
3. **Refactor.** With the test green as a safety net, clean up — names, duplication,
   structure. Re-run; stay green. Refactor the test too if it got messy.

Keep the steps small. A cycle should be minutes, not an afternoon. Commit at green.

## Bug fixing with TDD

Reproduce the bug as a failing test *first*. It pins the defect, proves the fix works,
and prevents regression. If you can't write a test that fails on the current code, you
don't yet understand the bug — go investigate before fixing.

## What to test

- The contract: inputs → outputs and side effects, not internal mechanics.
- Boundaries: 0, 1, n, max, empty, null, overflow.
- Failure paths: invalid input, downstream errors, partial failure.
- The specific behavior this change introduces.

## Pitfalls

- **Testing implementation, not behavior** → tests break on every refactor and stop
  catching real bugs. Assert observable results.
- **Tests that can't fail** → no negative-control; verify the test fails before you make
  it pass.
- **Over-mocking** → a test of mocks proving mocks were called. Mock only at real
  boundaries (network, clock, filesystem).
- **Skipping refactor** → green-and-move-on accrues mess. The third step isn't optional.
- **Giant tests** → many reasons to fail. One behavior per test.

## When strict TDD doesn't fit

Exploratory spikes, throwaway prototypes, and hard-to-test legacy edges may warrant
test-after or characterization tests instead. Be deliberate about the exception rather
than abandoning the discipline by default.

Versions

RepositoryScoreLicence
This page · alisinadevelo/md-files90MIT
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 f3741acb847b (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
    Test-driven development. Use when building a feature or fixing a bug test-first, when the user asks for red-green-refactor, or when a change needs its tests written before its implementation.
  • 100red-green-refactor
    Guides the red-green-refactor TDD workflow: write a failing test first, implement the minimum code to make it pass, then refactor while keeping tests green. Use when a user asks to practice TDD, write tests first, follow red-green-refactor, do test-driven development, write…
  • 100tdd
    Test-Driven Development facilitation using the red-green-refactor cycle. Guides users through writing tests first, implementing minimal code to pass, and refactoring for quality. Use when users want to practice TDD, need help writing tests before code, are developing new…
  • 90tdd-red-green-refactor
    Drive a change with test-driven development in short red-green-refactor cycles, with Claude as a disciplined pair: write one failing test, the minimum code to pass, refactor with tests green, repeat; keeps a visible test list. Use when implementing new logic, fixing a bug the…
  • 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.