A strict TDD enforcement tool that guides development through the Red-Green-Refactor cycle.
Install
mkdir -p .claude/skills/tdd-zereight && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/18717" && unzip -o skill.zip -d .claude/skills/tdd-zereight && rm skill.zipInstalls to .claude/skills/tdd-zereight
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Test-Driven Development enforcement skill. Activates full TDD mode. Activate when: TDD, test-driven, test first, red-green-refactor, write tests first.Key capabilities
- →Write a failing test for new behavior
- →Write minimum code to make a test pass
- →Name tests as specifications
- →Identify and fix common TDD pitfalls
How it works
The skill guides through the Red-Green-Refactor cycle, starting with writing a failing test, then implementing minimal code to pass it, and finally refactoring.
Inputs & outputs
When to use tdd
- →Implement features test-first
- →Enforce TDD discipline
- →Ensure reliable refactoring
- →Validate code behavior
About this skill
TDD — Test-Driven Development
THE IRON LAW: Write the failing test FIRST. Always.
The Red-Green-Refactor Cycle
RED → Write a failing test for the NEXT behavior
GREEN → Write ONLY enough code to make it pass (no extras)
REFACTOR → Clean up code quality (tests must stay green after every change)
REPEAT
Step-by-Step Protocol
1. RED Phase
- Identify the smallest next behavior to implement
- Write a test that describes that behavior as a named
it()/test()/def test_ - Run the test — it MUST FAIL. If it passes, the test is wrong.
- Confirm the failure message is the RIGHT failure (not a syntax error)
// Example: RED — test fails because function doesn't exist yet
it('returns an empty array for an empty input', () => {
const result = parseItems([]);
expect(result).toEqual([]); // FAILS: parseItems is not defined
});
2. GREEN Phase
- Write the MINIMUM code to make the test pass
- Do not add extra logic, default parameters, or "nice-to-haves"
- Run ALL tests — the new test must pass; existing tests must not break
// Example: GREEN — just enough to pass
function parseItems(input: string[]): string[] {
return []; // only enough for the current test
}
3. REFACTOR Phase
- Look at the code — can it be cleaner without changing behavior?
- Apply simplification patterns (see
/ai-slop-cleanerand/coding-standards) - Run tests after EVERY change. If tests break, undo immediately.
TDD Gate — When to Stop
| Situation | Action |
|---|---|
| Code written before test | STOP. Delete production code. Write test first. |
| Test passes on first run (no prior code) | The test is wrong — fix it to fail first. |
| Multiple behaviors in one test | STOP. One test, one behavior. |
| Skipping refactor to go faster | Go back. Clean up before next feature. |
Naming Tests as Specifications
Tests are executable documentation. Name them as complete sentences:
// BAD
it('test1', ...)
it('works with empty', ...)
// GOOD
it('returns empty array when input is empty', ...)
it('throws ValidationError when email is missing @', ...)
it('sends exactly one email when user registers', ...)
Framework Quick Reference
| Framework | Failing assertion | Run single test |
|---|---|---|
| Vitest | expect(x).toBe(y) | npx vitest run -t "test name" |
| Jest | expect(x).toBe(y) | npx jest -t "test name" |
| pytest | assert x == y | pytest -k "test_name" |
| cargo test | assert_eq!(x, y) | cargo test test_name |
| go test | t.Errorf(...) | go test -run TestName |
Common TDD Pitfalls
| Pitfall | Fix |
|---|---|
| Testing implementation details | Test behavior (outputs), not internals (private methods) |
| One test for 10 behaviors | Split into atomic test cases |
| Mock everything (over-mocking) | Mock at system boundaries only (DB, HTTP, filesystem) |
| No triangulation | Write 2-3 tests that force the correct implementation to emerge |
| Untriangulated constants | return 42 passes one test — add a second test to force real logic |
See Also
@test-engineer— test strategy, framework detection, coverage gap analysis/ultraqa— QA cycling: test, verify, fix, repeat/verify— evidence-based completion verification
When not to use it
- →When code has already been written before a test
- →When a test passes on its first run without prior code
- →When multiple behaviors are tested in one test
Limitations
- →Requires tests to be written first
- →Requires one test per behavior
- →Requires refactoring after each green phase
How it compares
This skill enforces a strict TDD cycle, ensuring tests are written before implementation and code is refactored continuously, unlike a traditional code-first approach.
Compared to similar skills
tdd side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| tdd (this skill) | 0 | 3mo | No flags | Beginner |
| python-testing-patterns | 77 | 2mo | Review | Intermediate |
| dependency-upgrade | 26 | 4mo | Review | Intermediate |
| test-cases | 57 | 6mo | No flags | Beginner |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by zereight
View all by zereight →You might also like
python-testing-patterns
wshobson
Implement comprehensive testing strategies with pytest, fixtures, mocking, and test-driven development. Use when writing Python tests, setting up test suites, or implementing testing best practices.
dependency-upgrade
wshobson
Manage major dependency version upgrades with compatibility analysis, staged rollout, and comprehensive testing. Use when upgrading framework versions, updating major dependencies, or managing breaking changes in libraries.
test-cases
cexll
This skill should be used when generating comprehensive test cases from PRD documents or user requirements. Triggers when users request test case generation, QA planning, test scenario creation, or need structured test documentation. Produces detailed test cases covering functional, edge case, error handling, and state transition scenarios.
reviewing-code
CaptainCrouton89
Systematically evaluate code changes for security, correctness, performance, and spec alignment. Use when reviewing PRs, assessing code quality, or verifying implementation against requirements.
wcag-audit-patterns
wshobson
Conduct WCAG 2.2 accessibility audits with automated testing, manual verification, and remediation guidance. Use when auditing websites for accessibility, fixing WCAG violations, or implementing accessible design patterns.
code-coverage-with-gcov
gadievron
Add gcov code coverage instrumentation to C/C++ projects