test-driven-development
Skill17 starsChanged 7 months agoMITView on GitHub
Use when implementing behavior with tests first, including new features, bug fixes, behavior changes, and regression protection, and including Chinese requests such as “先写测试”“补回归”“按 TDD 修复”. Do not use for pure copy edits, generated outputs with little test value, or tasks where the user explicitly wants to skip testing and accepts the risk.
191 other projects use a version of this.
Adopted by
Most recently taken up by
- Blandskron/agents-first-repo-docstheir own version, first seen Nov 29, 2026
- ctaxnagomi/agent-kd-skilltheir own version, first seen Nov 29, 2026
- aakash1552005/universal-agent-skillstheir own version, first seen Nov 29, 2026
- karanmrn/karanagentskillstheir own version, first seen Nov 29, 2026
- karanmrn/kstacktheir own version, first seen Nov 29, 2026
- Dannykkh/skill-olympustheir own version, first seen Nov 29, 2026
Used with
Projects with it also use chinese-code-review, chinese-commit-conventions and 8 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
steven123397Skillaccessibility-engineering
Audits existing interfaces for WCAG 2.2 AA conformance and remediates the violations found. Use when auditing a page or component for accessibility, running axe-core or pa11y, triaging a11y violations, or checking screen reader and contrast issues before shipping.
Also in 4 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 46 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 21 projects that use this
LLl0k0laDSkillgit-workflow-and-versioning
Use when making any code change. Use when committing, branching, resolving conflicts, or when you need to organize work across multiple parallel streams.
Also in 54 projects that use this
- +1 more from Leodorareluctant259
- +2 more from LLl0k0laD
Other versions191 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 191
- obra/superpowers★ 314ksame name
- NousResearch/hermes-agent★ 267ksame name
- addyosmani/agent-skills★ 121ksame name
- cloudflare/computer★ 10ksame name
- mdiri-ai/SoduWork★ 9.1ksame name
- jnMetaCode/superpowers-zh★ 8.6ksame name
- openai/plugins★ 8.4ksame name
- farm-fe/farm★ 5.6ksame name
- microsoft/FluidFramework★ 5ksame name
- mikeyobrien/ralph-orchestrator★ 3.2ksame name
181 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 repository37 other files it gives its agents.
- a11y-debuggingSkill
- agent-blueprint-architectSkill
- brainstormingSkill
- chart-visualizationSkill
- chinese-copywritingSkill
- chinese-git-workflowSkill
- chrome-devtoolsSkill
- creating-trae-rulesSkill
- debug-optimize-lcpSkill
- discovering-subagent-capabilitiesSkill
- dispatching-parallel-agentsSkill
- everything-searchSkill
- executing-plansSkill
- find-docsSkill
- finishing-a-development-branchSkill
- frontend-designSkill
- gh-cliSkill
- git-commitSkill
- image-manipulation-python-magickSkill
- memory-kernelSkill
- memory-leak-debuggingSkill
- mineru-to-mdSkill
- model-config-lookupSkill
- receiving-code-reviewSkill
- requesting-code-reviewSkill
- self-improvementSkill
- skill-creatorSkill
- skill-language-policySkill
- skill-stability-reviewSkill
- subagent-driven-developmentSkill
- systematic-debuggingSkill
- troubleshootingSkill
- using-git-worktreesSkill
- verification-before-completionSkill
- visual-brainstormingSkill
- workflow-runnerSkill
- writing-plansSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
26 rules. 0 are common, 23 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 182 edited versions we read keep these.
23
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 10
Core Principle: If you don't see the test fail first, you don't know if it's actually protecting the correct behavior.
- Distinctive: line 21
Only modifying copy, comments, or static configs without behavioral changes.
- Distinctive: line 37
Behavioral target unclear: Do not start the TDD loop.
- Distinctive: line 38
Context Payload available: Read it during Phase 0 before writing the failing test.
- Very specific: line 45
If the current task was handed off from an upstream skill (e.g., systematic-debugging), check the conversation for a [Context Payload] …
- Distinctive: line 52
If a Context Payload is present, incorporate its content into the failing test design and implementation scope.
- Distinctive: line 59
Test only one behavior at a time.
- Distinctive: line 83
Use PowerShell-compatible commands on a Windows host, for example:
- Distinctive: line 97
If the test passes immediately upon writing, it means it is not protecting the actual new behavior.
- Distinctive: line 101
Write only the minimum code required to make the current failing test pass.
- Distinctive: line 120
Run the exact same test command again and confirm:
- Distinctive: line 130
Only alter implementation code, not test code.
- Distinctive: line 132
Do not break code unrelated to what the test is verifying.
- Distinctive: line 136
If the test does not fail under mutation, the test is not protective — it is a false-green test.
- Distinctive: line 139
If you cannot make the test fail under mutation, escalate: this likely means the code cannot fail from the outside, which is a design issue.
- Distinctive: line 172
After refactoring, you must run the tests again to ensure behavior remains unchanged.
- Distinctive: line 176
When fixing a bug, write the bug as a failing test first, instead of fixing the implementation directly.
- Distinctive: line 185
Run it to get a red light, then fix:
- Distinctive: line 200
When running validations, use the project's native test commands and maintain PowerShell compatibility on the Windows host.
- Distinctive: line 201
Do only one thing per cycle: write failing test, run it, write minimal implementation, run it again, perform mutation test, restore, then …
- Very specific: line 202
After the fix is complete, if preparing to declare success, continue using verification-before-completion.
- Distinctive: line 206
Write code first, add tests at the end.
- Distinctive: line 219
Existing code lacks tests: Start from the behavior being modified.
- Distinctive: line 223
When completing a TDD cycle, you must at least state:
- Distinctive: line 230
If there is no evidence of a red light, do not claim you did TDD.
- Very specific: line 232
Next Step: After the TDD cycle is complete, must invoke verification-before-completion to independently verify the fix before declaring …
“Common” is measured: kept by at least 6 in 10 of the 182 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
Overview
Core Principle: If you don't see the test fail first, you don't know if it's actually protecting the correct behavior.
Use This Skill
- Developing new features.
- Fixing bugs and adding regression protection.
- Changing existing behavior.
- Adding safety nets to legacy code lacking tests.
Do Not Use
- Only modifying copy, comments, or static configs without behavioral changes.
- Generating files or third-party artifacts with very low testing value.
- The user explicitly asks to skip testing and accepts the corresponding risk.
- The current task is just discussing solutions; use
brainstormingorwriting-plansfirst.
Input Contract
Required Inputs:
- A clear behavioral target: what behavior needs to be implemented, fixed, or changed.
Optional but highly recommended inputs:
- Existing project testing patterns and framework configuration.
- Related test files or code paths.
- Context Payload from upstream skill (e.g.,
systematic-debugging,writing-plans): When handed off from an upstream skill, check the conversation for a[Context Payload]block. It preserves the confirmed root cause, ruled-out paths, residual risks, and fix guidance that should inform the failing test design.
Missing input handling:
- Behavioral target unclear: Do not start the TDD loop; clarify first.
- Context Payload available: Read it during Phase 0 before writing the failing test.
- Context Payload absent: Proceed without it.
Execution Protocol
Phase 0: Read Upstream Context (if handed off from upstream skill)
If the current task was handed off from an upstream skill (e.g., systematic-debugging), check the conversation for a [Context Payload] block before starting the TDD loop. Pay special attention to these fields:
- Root Cause (from
systematic-debugging): Confirmed root cause that the fix must address. - Ruled Out (from
systematic-debugging): What was already investigated — avoid repeating dead ends. - Residual Risk (from
systematic-debugging): Edge cases or uncertainties that the TDD regression test should cover. - Fix Guidance (from
systematic-debugging): One-sentence summary of what needs to change.
If a Context Payload is present, incorporate its content into the failing test design and implementation scope. If absent, proceed without it.
1. Red Light: Write Failing Test First
The test must first express the expected behavior, then expose the current gap.
A good failing test should:
- Test only one behavior at a time.
- Have a clear name.
- Prioritize testing real behavior, not the mock itself.
- Be minimally reproducible.
Example:
test('retries failed operations 3 times', async () => {
let attempts = 0;
const operation = async () => {
attempts += 1;
if (attempts < 3) throw new Error('fail');
return 'success';
};
const result = await retryOperation(operation);
expect(result).toBe('success');
expect(attempts).toBe(3);
});2. Verify Red Light: Must See It Fail
Use PowerShell-compatible commands on a Windows host, for example:
npm test -- path\to\retry.test.tsOr:
pytest tests/test_retry.py -k retries_failed_operationsConfirm three things:
- The test fails, not the test file itself throwing a syntax/load error.
- The failure reason matches expectations.
- The failure comes from missing behavior, not typos or environment errors.
If the test passes immediately upon writing, it means it is not protecting the actual new behavior.
3. Green Light: Write Minimal Implementation
Write only the minimum code required to make the current failing test pass. Do not opportunistically expand interfaces or optimize unrelated logic.
Example:
async function retryOperation<T>(fn: () => Promise<T>): Promise<T> {
for (let i = 0; i < 3; i += 1) {
try {
return await fn();
} catch (error) {
if (i === 2) throw error;
}
}
throw new Error('unreachable');
}4. Verify Green Light: Re-run Tests
Run the exact same test command again and confirm:
- The target test passes.
- Related tests do not regress.
- The output has no new errors or obvious warnings.
5. Mutation Test: Break Then Verify (Anti-False-Green)
Deliberately alter one line of the implementation code you just wrote to prove the test can catch the defect.
Rules:
- Only alter implementation code, not test code.
- Make a targeted, minimal break (e.g., flip a boolean, remove a guard clause, return a wrong value, comment out a key line).
- Do not break code unrelated to what the test is verifying.
- Re-run the exact same test and confirm it fails with a meaningful error.
- Restore the broken code immediately after verification.
If the test does not fail under mutation, the test is not protective — it is a false-green test. In that case:
- Fix the test to actually assert meaningful behavior.
- Repeat the mutation test until the test fails when the implementation is broken.
- If you cannot make the test fail under mutation, escalate: this likely means the code cannot fail from the outside, which is a design issue.
- Log via
self-improvement: Record the false-green pattern as an anti-pattern experience so future agents can recognize and avoid similar testing mistakes.
Example mutation sequence for a validation function:
// Original implementation:
function submitForm(data: FormData) {
if (!data.email?.trim()) {
return { error: 'Email required' };
}
return { ok: true };
}
// Mutation: comment out the guard
function submitForm(data: FormData) {
// if (!data.email?.trim()) {
// return { error: 'Email required' };
// }
return { ok: true };
}
// Run test → expect FAIL with meaningful error
// Then restore immediately6. Refactor: Only After Mutation Passes
You are only allowed to do these when the tests are green:
- Deduplicate code.
- Rename variables/functions.
- Extract helper functions.
- Simplify structures.
After refactoring, you must run the tests again to ensure behavior remains unchanged.
Bug Fix Pattern
When fixing a bug, write the bug as a failing test first, instead of fixing the implementation directly.
test('rejects empty email', async () => {
const result = await submitForm({ email: '' });
expect(result.error).toBe('Email required');
});Run it to get a red light, then fix:
function submitForm(data: FormData) {
if (!data.email?.trim()) {
return { error: 'Email required' };
}
return { ok: true };
}Trae / Windows Conventions
- In Trae, use
Read,Grep,GetDiagnosticsto understand existing testing patterns before writing new tests. - When running validations, use the project's native test commands and maintain PowerShell compatibility on the Windows host.
- Do only one thing per cycle: write failing test, run it, write minimal implementation, run it again, perform mutation test, restore, then refactor.
- After the fix is complete, if preparing to declare success, continue using
verification-before-completion.
Common Anti-Patterns
- Write code first, add tests at the end.
- The test passes as soon as it is written.
- Testing the number of mock calls instead of behavioral results.
- Modifying production code to be harder to understand just to make it easier to test.
- Writing a lot of implementation at once, then going back to add a bunch of tests.
See more anti-patterns in: testing-anti-patterns.md
Failure Handling
- Test won't stably fail: Fix the test environment or minimal reproduction first; do not enter implementation.
- Test is too hard to write: Usually indicates the interface design is too heavy or tightly coupled; simplify the design first.
- Requires massive mocking to test: Prioritize checking dependency injection, boundary splitting, and responsibility separation.
- Existing code lacks tests: Start from the behavior being modified; add minimal regression tests first.
Output Contract
When completing a TDD cycle, you must at least state:
- Which test was added or modified.
- What failure was seen during the red light phase.
- What minimal implementation was used to make it green.
- What validations were run at the end.
- What mutation test was performed to verify test protection.
If there is no evidence of a red light, do not claim you did TDD.
Next Step: After the TDD cycle is complete, must invoke verification-before-completion to independently verify the fix before declaring "fixed" or entering the commit process.
Checklist
- Wrote a failing test first.
- Saw the test fail for the expected reason with my own eyes.
- Wrote only the minimal implementation to pass the test.
- Re-ran the test and confirmed it passed.
- Related tests did not regress.
- Performed mutation test: broke implementation and confirmed test failure.
- Restored implementation after mutation verification.
- If refactored, verified again after refactoring.
Integration
systematic-debugging: Locate the root cause first, then return to TDD to fix.verification-before-completion: Re-verify conclusions before claiming "fixed".
Does 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.

