test-driven-development
Skill9 starsChanged 3 months agoMITView on GitHub
Use when implementing any feature or bugfix, before writing implementation code
192 other projects use a version of this, 115 of them edited.
Adopted by
Most recently taken up by
- NousResearch/hermes-agentedited, 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-skillsedited, 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 10 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
MorningStar0709Skillworkflow-runner
Run an agency-orchestrator style YAML workflow inside the current Trae conversation by simulating or coordinating multiple roles. Use when the user provides a `.yaml` or `.yml` workflow, asks for multi-role collaboration, says things like “用多个角色一起评审这个 PRD”“多角色协作”“先生成工作流再执行”“让产品经理、架构师、QA 一起看一下”, or wants roles such as product manager, architect, reviewer, or QA to work together. Supports layered execution, role prompting, variable interpolation, document-backed inputs, and parallel steps only when the current environment has a clear subagent mapping. Do not use for ordinary implementation plans, simple code changes, or tasks already covered by `writing-plans`, `executing-plans`, `subagent-driven-development`, or single-purpose review/debug skills.
Also in 5 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
MorningStar0709Skillchinese-git-workflow
Configure Git for domestic platforms and manage branching strategies suitable for Chinese teams. Use when the user asks to configure remotes, set up SSH, or manage Git workflows for Gitee, Coding, Jihu GitLab, or CNB, including requests like "配置国内 Git", "设置 Gitee 远程仓库", "推荐适合小团队的 Git 流程".
Also in 4 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
- +5 more from LLl0k0laD
Other versions192 projects use a version of this.
Word for word · 0
None found.
Edited · 115
- obra/superpowers★ 314k42% same
- NousResearch/hermes-agent★ 267k36% same
- openai/plugins★ 7.3k46% same
- microsoft/FluidFramework★ 4.9k16% same
- NeoLabHQ/context-engineering-kit★ 1.7k27% same
- GanyuanRan/Aegis★ 1.3k10% same
- coco-research/coco★ 43750% same
- Ibrahim-3d/orchestrator-supaconductor★ 38047% same
- aivrar/portable-hermes-agent★ 23236% same
- graniet/kheish★ 22137% same
105 more not listed
Wrote their own version · 77
- addyosmani/agent-skills★ 101ksame name
- cloudflare/computer★ 9.5ksame name
- jnMetaCode/superpowers-zh★ 8.3ksame name
- mikeyobrien/ralph-orchestrator★ 3.2ksame name
- crbnos/carbon★ 2.7ksame name
- taracodlabs/aiden★ 846same name
- taichuy/1flowbase★ 267same name
- KbWen/agentic-os★ 206same name
- shashankswe2020-ux/whoop-mcp★ 165same name
- ravila4/claude-adhd-skills★ 155same name
67 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 repository13 other files it gives its agents.
- toolconfigs/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- toolconfigs/CLAUDE.mdCLAUDE.md
- toolconfigs/copilot-instructions.mdCopilot instructions
- parallel-sessionsSkill
- code-refactoringSkill
- receiving-code-reviewSkill
- visual-smokeSkill
- code-refactoringSkill
- dev-harness-for-ui-iterationSkill
- receiving-code-reviewSkill
- test-driven-developmentSkill
- visual-smokeSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
16 rules. 3 are common, 12 are distinctive, and 1 is very specific to this project.
3
Common
Most of the 178 edited versions we read keep these.
12
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Common: line 12
Write the test first. Watch it fail.
- Common: line 14
Core principle: If you didn't watch the test fail, you don't know if it tests the right thing.
- Distinctive: line 39
Write code before the test?
- Distinctive: line 42
Don't keep it as "reference"
- Distinctive: line 43
Don't "adapt" it while writing tests
- Distinctive: line 44
Don't look at it
- Distinctive: line 53
Write one minimal test showing what should happen.
- Distinctive: line 97
Test fails (not errors)
- Distinctive: line 107
Write simplest code to pass the test.
- Distinctive: line 140
Don't add features, refactor other code, or "improve" beyond the test.
- Distinctive: line 166
Keep tests green. Don't add behavior.
- Very specific: line 211
Use freezegun / time-machine.
- Common: line 298
Before marking work complete:
- Distinctive: line 325
Never fix bugs without a test.
- Distinctive: line 329
When adding mocks or test utilities, read testing-anti-patterns.md to avoid common pitfalls:
- Distinctive: line 341
No exceptions without the project owner's explicit approval.
“Common” is measured: kept by at least 6 in 10 of the 178 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)
Overview
Write the test first. Watch it fail. Write minimal code to pass.
Core principle: If you didn't watch the test fail, you don't know if it tests the right thing.
Violating the letter of the rules is violating the spirit of the rules.
When to Use
Always:
- New features
- Bug fixes
- Refactoring
- Behavior changes
Exceptions (ask the project owner):
- Throwaway prototypes
- Generated code
- Configuration files
Thinking "skip TDD just this once"? Stop. That's rationalization.
The Iron Law
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRSTWrite code before the test? Delete it. Start over.
No exceptions:
- Don't keep it as "reference"
- Don't "adapt" it while writing tests
- Don't look at it
- Delete means delete
Implement fresh from tests. Period.
Red-Green-Refactor
RED - Write Failing Test
Write one minimal test showing what should happen.
Good:
def test_retries_failed_operations_three_times() -> None:
attempts = 0
def operation() -> str:
nonlocal attempts
attempts += 1
if attempts < 3:
raise RuntimeError('fail')
return 'success'
result = retry_operation(operation)
assert result == 'success'
assert attempts == 3Clear name, tests real behavior, one thing.
Bad:
def test_retry_works() -> None:
mock_op = MagicMock(side_effect=[RuntimeError(), RuntimeError(), 'success'])
retry_operation(mock_op)
assert mock_op.call_count == 3Vague name, tests mock not code.
Requirements:
- One behavior
- Clear name (
test_<behavior>, nottest_<function>) - Real code (no mocks unless unavoidable)
Verify RED - Watch It Fail
MANDATORY. Never skip.
pytest tests/test_module.py::test_retries_failed_operations_three_times -vConfirm:
- Test fails (not errors)
- Failure message is expected
- Fails because feature missing (not import errors or typos)
Test passes? You're testing existing behavior. Fix test.
Test errors? Fix error, re-run until it fails correctly.
GREEN - Minimal Code
Write simplest code to pass the test.
Good:
from typing import Callable, TypeVar
T = TypeVar('T')
def retry_operation(fn: Callable[[], T], max_attempts: int = 3) -> T:
for attempt in range(max_attempts):
try:
return fn()
except Exception:
if attempt == max_attempts - 1:
raise
raise RuntimeError('unreachable')Just enough to pass.
Bad:
def retry_operation(
fn: Callable[[], T],
max_attempts: int = 3,
backoff: Literal['linear', 'exponential'] = 'linear',
on_retry: Callable[[int], None] | None = None,
exceptions: tuple[type[Exception], ...] = (Exception,),
) -> T:
# YAGNI
...Over-engineered.
Don't add features, refactor other code, or "improve" beyond the test.
Verify GREEN - Watch It Pass
MANDATORY.
pytest tests/test_module.py -vConfirm:
- Test passes
- Other tests still pass
- Output clean (no warnings, no deprecation notices)
Test fails? Fix code, not test.
Other tests fail? Fix now.
REFACTOR - Clean Up
After green only:
- Remove duplication
- Improve names
- Extract helpers
Keep tests green. Don't add behavior.
Repeat
Next failing test for next feature.
Good Tests
| Quality | Good | Bad |
| Minimal | One thing. "and" in name? Split it. | test_validates_email_and_domain_and_whitespace |
| Clear | Name describes behavior | test1, test_foo |
| Shows intent | Demonstrates desired API | Obscures what code should do |
pytest Specifics
Fixtures over setup/teardown:
# GOOD
@pytest.fixture
def user_repo(tmp_path: Path) -> UserRepository:
return UserRepository(db_path=tmp_path / 'test.db')
def test_saves_user(user_repo: UserRepository) -> None:
user = User(name='Alice', email='alice@example.com')
user_repo.save(user)
assert user_repo.find_by_email('alice@example.com') == userParametrize for multiple cases:
@pytest.mark.parametrize('email', ['', 'notanemail', '@nodomain'])
def test_rejects_invalid_email(email: str) -> None:
result = validate_email(email)
assert result.is_err()Fake time, don't sleep:
def test_expires_after_ttl(freezer: FrozenDateTimeFactory) -> None:
cache = Cache(ttl_seconds=60)
cache.set('key', 'value')
freezer.tick(61)
assert cache.get('key') is NoneUse freezegun / time-machine; never time.sleep() in tests.
Why Order Matters
"I'll write tests after to verify it works"
Tests written after code pass immediately. Passing immediately proves nothing.
"I already manually tested all the edge cases"
Manual testing is ad-hoc. No record, can't re-run, easy to forget under pressure.
"Deleting X hours of work is wasteful"
Sunk cost fallacy. Keeping code you can't trust is the real waste.
"Tests after achieve the same goals"
Tests-after answer "What does this do?" Tests-first answer "What should this do?" Tests-after are biased by your implementation.
Common Rationalizations
| Excuse | Reality |
| "Too simple to test" | Simple code breaks. Test takes 30 seconds. |
| "I'll test after" | Tests passing immediately prove nothing. |
| "Tests after achieve same goals" | Tests-after = "what does this do?" Tests-first = "what should this do?" |
| "Already manually tested" | Ad-hoc is not systematic. No record, can't re-run. |
| "Deleting X hours is wasteful" | Sunk cost fallacy. Keeping unverified code is technical debt. |
| "Keep as reference, write tests first" | You'll adapt it. That's testing after. Delete means delete. |
| "Need to explore first" | Fine. Throw away exploration, start with TDD. |
| "Test hard = design unclear" | Listen to test. Hard to test = hard to use. |
| "TDD will slow me down" | TDD faster than debugging. Pragmatic = test-first. |
Red Flags - STOP and Start Over
- Code before test
- Test after implementation
- Test passes immediately
- Can't explain why test failed
- Tests added "later"
- Rationalizing "just this once"
- "I already manually tested it"
- "Tests after achieve the same purpose"
- "Keep as reference" or "adapt existing code"
- "Already spent X hours, deleting is wasteful"
- "TDD is dogmatic, I'm being pragmatic"
- "This is different because..."
All of these mean: Delete code. Start over with TDD.
Example: Bug Fix
Bug: Empty email accepted
RED
def test_rejects_empty_email() -> None:
result = submit_form({'email': ''})
assert result['error'] == 'Email required'Verify RED
$ pytest tests/test_form.py::test_rejects_empty_email -v
FAILED: AssertionError: assert None == 'Email required'GREEN
def submit_form(data: dict[str, str]) -> dict[str, str | None]:
if not data.get('email', '').strip():
return {'error': 'Email required'}
...Verify GREEN
$ pytest tests/test_form.py -v
PASSEDREFACTOR Extract validation for multiple fields if needed.
Verification Checklist
Before marking work complete:
- Every new function/method has a test
- Watched each test fail before implementing
- Each test failed for expected reason (feature missing, not typo or import error)
- Wrote minimal code to pass each test
- All tests pass (
pytest) - Type checker passes (
mypy/pyright) - Output pristine (no warnings)
- Tests use real code (mocks only if unavoidable)
- Edge cases and errors covered
Can't check all boxes? You skipped TDD. Start over.
When Stuck
| Problem | Solution |
| Don't know how to test | Write wished-for API. Write assertion first. Ask the project owner. |
| Test too complicated | Design too complicated. Simplify interface. |
| Must mock everything | Code too coupled. Use dependency injection or pass a Protocol. |
| Test setup huge | Extract fixtures. Still complex? Simplify design. |
Debugging Integration
Bug found? Write failing test reproducing it. Follow TDD cycle. Test proves fix and prevents regression.
Never fix bugs without a test.
Testing Anti-Patterns
When adding mocks or test utilities, read testing-anti-patterns.md to avoid common pitfalls:
- Testing mock behavior instead of real behavior
- Adding test-only methods to production classes
- Mocking without understanding dependencies
Final Rule
Production code -> test exists and failed first
Otherwise -> not TDDNo exceptions without the project owner's explicit approval.
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.

