test-driven-development
Skill4 starsChanged 3 months agoMITView on GitHub
Apply the Red-Green-Refactor cycle to software development. Load when the user asks to write code using TDD, create unit tests, implement a feature with test coverage, refactor code, or ensure software quality through automated testing. Also triggers on "test-driven development", "write tests first", "TDD this feature", "Red-Green-Refactor", "ensure 100% test coverage", or any request to build software with a test-first approach. Supports unit, integration, and end-to-end testing strategies.
190 other projects use a version of this.
Adopted by
Most recently taken up by
- FimawLLC/fimaw-skillstheir own version, first seen Nov 15, 2026
- metaspartan/cybaratheir own version, first seen Nov 15, 2026
- mdiri-ai/SoduWorktheir own version, first seen Nov 15, 2026
- DemonDamon/AgenticXtheir own version, first seen Nov 9, 2026
- chrysogonus/power-agentstheir own version, first seen Nov 8, 2026
- ishandutta2007/Awesome-Agent-Skillstheir own version, first seen Nov 8, 2026
Used with
Projects with it also use chinese-code-review, chinese-commit-conventions and 7 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
Leodorareluctant259Skillchinese-code-review
中文代码审查规范——在保持专业严谨的同时,用符合国内团队文化的方式给出有效反馈
Also in 8 projects that use this
Leodorareluctant259Skillchinese-commit-conventions
中文 Git 提交规范 — 适配国内团队的 commit message 规范和 changelog 自动化
Also in 8 projects that use this
obraSkilldiagnosing-superpowers
Use when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.
Also in 19 projects that use this
LLl0k0laDSkillusing-agent-skills
Use when starting a session or when you need to discover which skill applies to the current task. This is the meta-skill that governs how all other skills are discovered and invoked.
Also in 39 projects that use this
MrCipherSmithSkillconstraint-driven-development
Use when a project needs a persistent, measurable quality bar — starting a project without documented standards, 'set up constraints', or when coverage/perf/a11y thresholds get re-debated per-PR. Produces CONSTRAINTS.md with enforceable numbers, ratchets, and a guard against silent weakening. NOT for throwaway prototypes or a one-off CI setup.
Also in 15 projects that use this
LLl0k0laDSkilldebugging-and-error-recovery
Use when tests fail, builds break, behavior doesn't match expectations, or you encounter any unexpected error. Use when you need a systematic approach to finding and fixing the root cause rather than guessing.
Also in 46 projects that use this
- +3 more from Leodorareluctant259
Other versions190 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 190
- obra/superpowers★ 314ksame name
- NousResearch/hermes-agent★ 262ksame name
- addyosmani/agent-skills★ 114ksame name
- cloudflare/computer★ 9.9ksame name
- jnMetaCode/superpowers-zh★ 8.4ksame name
- openai/plugins★ 7.8ksame name
- farm-fe/farm★ 5.6ksame name
- microsoft/FluidFramework★ 4.9ksame name
- mikeyobrien/ralph-orchestrator★ 3.2ksame name
- crbnos/carbon★ 2.8ksame name
180 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository125 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .cursor/rules/agent-loom-routing.mdcCursor rule
- .cursor/rules/agent-loom-skills-index.mdcCursor rule
- adversarial-hatSkill
- agent-builderSkill
- agent-launcherSkill
- agent-loom-syncSkill
- agent-observabilitySkill
- agent-run-retroSkill
- agent-system-architectureSkill
- api-and-interface-designSkill
- api-deprecation-and-migrationSkill
- apply-paper-to-projectSkill
- app-security-hardeningSkill
- architectural-decision-logSkill
- assumption-mappingSkill
- brainstormingSkill
- browser-testing-with-devtoolsSkill
- business-modelingSkill
- ci-cd-and-automationSkill
- codebase-understandingSkill
- code-review-crspSkill
- code-simplificationSkill
- compress-skillSkill
- context-engineeringSkill
- create-agent-promptSkill
- cross-link-skillsSkill
- customer-discoverySkill
- debug-and-fixSkill
- deep-thinkingSkill
- dependency-mappingSkill
- deploy-anywhereSkill
- deprecate-skillSkill
- design-directionSkill
- design-reviewSkill
- design-systemSkill
- dynamic-routingSkill
- eval-judgeSkill
- eval-outputSkill
- eval-pipelineSkill
- eval-rubric-designSkill
- experimentationSkill
- experiment-backlogSkill
- experiment-readoutSkill
- experiment-runbookSkill
- experiment-specSkill
- fault-localizeSkill
- feature-specSkill
- fermiSkill
- first-principlesSkill
- frontend-designSkill
- generate-changelogSkill
- git-workflow-and-versioningSkill
- gsap-animationSkill
- harness-engineeringSkill
- harness-evolutionSkill
- harness-generationSkill
- idea-evaluationSkill
- idea-generationSkill
- implementation-planSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
22 rules. 0 are common, 14 are distinctive, and 8 are very specific to this project.
0
Common
Most of the 179 edited versions we read keep these.
14
Distinctive
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 30
Never write production code without a failing test first (Red phase).
- Distinctive: line 31
Never write more code than necessary to pass the current failing test (Green phase).
- Distinctive: line 32
Never skip the Refactor phase — clean up code only when tests are passing.
- Distinctive: line 33
Never compromise on test clarity — tests are documentation.
- Very specific: line 41
Read the PRD (docs/prd/) or implementation plan (docs/plans/).
- Very specific: line 45
Write a test that describes the expected behavior.
- Very specific: line 46
Run the test and confirm it fails for the right reason (e.g., ReferenceError or AssertionError).
- Distinctive: line 47
Stop. Do not write any production code yet.
- Distinctive: line 50
Write just enough code to make the test pass.
- Distinctive: line 51
Don't worry about performance or elegance yet — focus on "Green." Run the test and confirm it passes.
- Distinctive: line 52
Run the test and confirm it passes.
- Distinctive: line 56
Run the tests again to ensure no regressions were introduced.
- Very specific: line 60
Ensure all tests in the suite pass.
- Very specific: line 62
When UI or browser E2E is in scope, pair with browser-testing-with-devtools after unit/integration tests pass.
- Distinctive: line 78
If a test requires >10 lines of setup, the code under test has too many dependencies.
- Very specific: line 79
Never assert against a mock's own behavior (it always "passes"), and never add test-only methods/hooks to production classes — see …
- Very specific: line 96
Run: NameError: name 'calculate_debt_interest' is not defined — correct failure.
- Distinctive: line 125
Run: ✓ Both tests pass.
- Distinctive: line 164
Test passes on first run (may not test what you think)
- Distinctive: line 166
Test names that don't describe behavior
- Very specific: line 177
Read references/examples.md for full worked examples.
- Distinctive: line 186
After completing, always report:
“Common” is measured: kept by at least 6 in 10 of the 179 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Test-Driven Development (TDD)
You are a Senior Software Engineer with a passion for quality. You follow the Red-Green-Refactor cycle strictly. You never write production code before a failing test exists, and you never refactor without a passing test suite.
Hard Rules
Never write production code without a failing test first (Red phase). Never write more code than necessary to pass the current failing test (Green phase). Never skip the Refactor phase — clean up code only when tests are passing. Never compromise on test clarity — tests are documentation. Code written before its test existed must be deleted, not retrofitted with a test after the fact — start over from Red.
Workflow
Step 1 — Define the Requirement
Read the PRD (docs/prd/) or implementation plan (docs/plans/).
Identify the smallest, testable unit of functionality.
Step 2 — Red Phase (Write a Failing Test)
Write a test that describes the expected behavior. For bug fixes, use the Prove-It Pattern — full protocol in references/tdd-patterns.md (repro → fix → regression guard).
Run the test and confirm it fails for the right reason (e.g., ReferenceError or AssertionError).
Stop. Do not write any production code yet.
Step 3 — Green Phase (Write Minimal Code)
Write just enough code to make the test pass. Don't worry about performance or elegance yet — focus on "Green." Run the test and confirm it passes.
Step 4 — Refactor Phase (Clean Up)
With the test passing, refactor the code for readability, performance, and structure. Run the tests again to ensure no regressions were introduced. Repeat Steps 2–4 for the next small unit of functionality.
Step 5 — Verify and Save
Ensure all tests in the suite pass.
Save the tests to tests/ and the code to src/ (or project equivalent).
When UI or browser E2E is in scope, pair with browser-testing-with-devtools after unit/integration tests pass.
Append to docs/skill-outputs/SKILL-OUTPUTS.md:
| YYYY-MM-DD HH:MM | test-driven-development | [test path] | TDD: <feature> |Tell the user:
"TDD cycle complete for
<feature>. Tests saved to[test path]. Logged indocs/skill-outputs/SKILL-OUTPUTS.md."
Gotchas
- Agents skip Red — they jump straight to writing code and tests together. Enforce the discipline: write the test FIRST, run it, see it FAIL, only then write code. The failure message confirms you are testing the right thing.
- "Test the framework" is the #1 agent mistake. Testing that
FastAPIreturns 200 for a valid route tests FastAPI, not your code. Test the business logic the route calls, not the HTTP plumbing. - Agents write one giant test per feature instead of many small tests. Each test should verify exactly one behavior. If a test name contains "and" ("test_login_and_redirect_and_set_cookie"), split it into three tests.
- If a test requires >10 lines of setup, the code under test has too many dependencies. This is TDD's most valuable signal — hard-to-test code needs architectural refactoring, not more mocking.
- Never assert against a mock's own behavior (it always "passes"), and never add test-only methods/hooks to production classes — see
references/tdd-patterns.mdAnti-patterns table.
Example
<examples>
<example>
<input>TDD a function that calculates the "interest rate" of a technical debt item based on its blast radius and frequency of encounters.</input>
<output>
**Target Feature:** `calculate_debt_interest(blast_radius: int, encounter_frequency: int) -> str`Red Phase — Test 1: Basic classification
def test_high_interest_when_high_blast_and_frequent():
assert calculate_debt_interest(blast_radius=8, encounter_frequency=5) == "high"Run: NameError: name 'calculate_debt_interest' is not defined — correct failure.
Green Phase — Minimal implementation
def calculate_debt_interest(blast_radius: int, encounter_frequency: int) -> str:
score = blast_radius * encounter_frequency
if score >= 20:
return "high"
return "low"Run: ✓ Test passes.
Red Phase — Test 2: Medium classification
def test_medium_interest_when_moderate_score():
assert calculate_debt_interest(blast_radius=3, encounter_frequency=3) == "medium"Run: AssertionError: 'low' != 'medium' — correct failure.
Green Phase — Add medium tier
def calculate_debt_interest(blast_radius: int, encounter_frequency: int) -> str:
score = blast_radius * encounter_frequency
if score >= 20:
return "high"
if score >= 8:
return "medium"
return "low"Run: ✓ Both tests pass.
Refactor Phase: Extracted threshold constants, added docstring. All tests still green.
TDD session complete: calculate_debt_interest
Tests written: 2 (+ 1 edge case for score=0)
Code coverage achieved: 100%
Refactorings performed: 1 (extract constants)
Status: Green (All tests passing)
Ready for: code review
</output>
</example>
</examples>
Output Format
TDD Session Report:
- Target Feature (What we are building).
- Test Case(s) (Description of the tests written).
- Pass/Fail Status (Final result of the suite).
- Refactorings Applied (What was cleaned up).
Common Rationalizations
| Excuse | Reality |
| "I'll write tests after it works" | Tests written after code test implementation, not behavior. |
| "Too simple to test" | Simple code grows; tests document expected behavior. |
| "I tested it manually" | Manual checks don't guard the next change. |
| "Let me run tests again to be sure" | Re-run only after code changes — identical re-runs add nothing. |
| "I already wrote this, I'll just add a test for it" | Delete it and rewrite from Red — a test written against existing code confirms the code, not the contract. |
Red Flags
- Production code with no corresponding test
- Test passes on first run (may not test what you think)
- Bug fix without a reproduction test
- Test names that don't describe behavior
Verification
- Every new behavior has a test; bug fixes include a failing-then-passing repro test
- Full suite passes:
[project test command] - Test names read as specifications
- No tests skipped or disabled to green the suite
Read references/examples.md for full worked examples.
Prune Log
Last pruned: 2026-07-09
- Added delete-not-retrofit enforcement + mock/test-only-method anti-pattern citation (agent-loom Phase 4, obra/superpowers)
Impact Report
After completing, always report:
TDD session complete: [feature name]
Tests written: [N]
Code coverage achieved: [N%]
Refactorings performed: [N]
Status: Green (All tests passing)
Ready for: code review / integrationDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

