test-driven-development
Skill18 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, 1 of them edited.
Adopted by
Most recently taken up by
- NousResearch/hermes-agenttheir own version, first seen Nov 13, 2026
- andreymudri/fleetmatestheir own version, first seen Oct 5, 2026
- Jacobinwwey/notemdprotheir own version, first seen Oct 5, 2026
- crbnos/carbontheir own version, first seen Oct 4, 2026
- L-X-T/ng-agentic-skillstheir own version, first seen Oct 4, 2026
- GuillemRoca/agent-skills-androidtheir own version, first seen Oct 3, 2026
Used with
Projects with it also use diagnosing-superpowers, api-and-interface-design 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.
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 6 projects that use this
LLl0k0laDSkillapi-and-interface-design
Use when designing APIs, module boundaries, or any public interface. Use when creating REST or GraphQL endpoints, defining type contracts between modules, or establishing boundaries between frontend and backend.
Also in 32 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 25 projects that use this
vinvcnSkillconstraint-driven-development
把一个项目的质量线确立为书面契约,并阻止 agent 悄悄降低它。通过访谈确定用户在意哪些维度,当用户心里没有数字时提供合理的默认阈值,把一切记录进 CONSTRAINTS.md,并盯住 diff 中质量线被削弱的迹象——新增的 @ts-ignore 或 eslint-disable 抑制注释、被跳过或删除的测试、被剥掉的断言、未实现的 stub、被调低的阈值。当没有任何质量线被写下来时使用;当用户说 "set up constraints" 或 "define our standards" 时;当用户希望把他们在意的维度——无障碍性、Web 性能、覆盖率——设置成被强制执行的约束时;当 agent 为了变绿不断静默检查或跳过测试时;当你需要一个覆盖率或性能阈值却不知道该选什么数字时;或者当 agent 写下的代码超出任何人会读的体量时。
Also in 4 projects that use this
az9713Skilldeprecation-and-migration
Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when deciding whether to maintain or sunset existing code.
Also in 22 projects that use this
- +5 more from LLl0k0laD
Other versions191 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- rzx007/Vykor★ 210% same
Wrote their own version · 190
- obra/superpowers★ 314ksame name
- NousResearch/hermes-agent★ 267ksame name
- addyosmani/agent-skills★ 101ksame name
- cloudflare/computer★ 9.5ksame name
- jnMetaCode/superpowers-zh★ 8.3ksame name
- openai/plugins★ 7.3ksame name
- microsoft/FluidFramework★ 4.9ksame name
- mikeyobrien/ralph-orchestrator★ 3.2ksame name
- crbnos/carbon★ 2.7ksame name
- NeoLabHQ/context-engineering-kit★ 1.7ksame 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 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 177 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 177 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.

