Build a change test-first in small red, green, refactor steps. Use when implementing a feature, a bug fix or a refactor whose behavior a code test can pin down.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Test Driven Development?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/prasadm1022-test-driven-development)
---
name: test-driven-development
description: Build a change test-first in small red, green, refactor steps. Use when implementing a feature, a bug fix or a refactor whose behavior a code test can pin down.
license: MIT
version: 0.1.0
requires:
tools: [fs.read, fs.list, fs.search, fs.write, fs.edit, exec.run, git]
hosts: []
classes: [read, write-local]
task-types:
- software-development.feature
- software-development.bug-fix
- software-development.tests
- software-development.refactor
---
# Test-driven development
Write the test that fails for the right reason before the code that makes it pass.
## The loop
1. Pick one behavior from the plan, the smallest step toward done.
2. Red. Write a test for it and run only that test. Read the failure: it must fail because the behavior is missing, not because of a typo or a bad import. A test that passes at once checks nothing new, so fix the test.
3. Green. Write the least code that passes. Returning a constant is fine when the next test will force the general version.
4. Run the whole test file, then the whole suite. Everything that passed before must still pass.
5. Refactor while the suite is green: remove duplication, improve names, one small move at a time, running the suite after each.
6. Commit on the work branch with a message that says which behavior now holds.
7. Repeat until every acceptance criterion has a passing test.
## Bug fixes
Reproduce first: write a test that fails on the bug exactly as reported. Fix the cause, not the symptom. Keep that test as the regression test.
## Rules
- Tests are deterministic: no network, no real clock, no sleeping, no state shared between tests. Use fakes and fixed clocks.
- Test behavior through the public surface. Do not assert on details a refactor would change.
- Never weaken, disable or delete an existing test to get a pass. If a test is wrong, say why in the report and fix it in its own commit.
- Say a test passed only if you ran it and read the result. Give the command and the counts as evidence.
- Work on the ticket's branch. Never commit to the default branch.