Implement features and fixes by writing tests before production code.
Copy the install command and let the AI configure it · recommended for beginners
Please install the "test-driven-development" skill from askskill: 1. Download https://raw.githubusercontent.com/obra/superpowers/main/skills/test-driven-development/SKILL.md 2. Save it as ~/.claude/skills/test-driven-development/SKILL.md 3. Reload skills and tell me it's ready
Use test-driven development to build an API for fetching user profiles. First list the test cases, then write failing unit tests, and finally provide the minimal implementation code and refactoring suggestions. Use Node.js and Jest.
A test list and failing tests first, followed by minimal passing code and refactoring suggestions.
My date formatting function fails at timezone boundaries. Follow TDD: first write a test that reproduces the bug, then provide the fix, and explain why the fix makes the test pass.
A bug-reproducing test, targeted fix code, and a brief explanation of why the tests pass.
Implement the rule 'order discounts and member discounts apply together' using TDD. First break the business logic into multiple test scenarios, then write tests, implementation, and necessary refactoring step by step.
Layered test scenarios, stepwise implementation code, and a more maintainable refactored version.
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.
Always:
Exceptions (ask your human partner):
Thinking "skip TDD just this once"? Stop. That's rationalization.
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
Write code before the test? Delete it. Start over.
No exceptions:
Implement fresh from tests. Period.
digraph tdd_cycle {
rankdir=LR;
red [label="RED\nWrite failing test", shape=box, style=filled, fillcolor="#ffcccc"];
verify_red [label="Verify fails\ncorrectly", shape=diamond];
green [label="GREEN\nMinimal code", shape=box, style=filled, fillcolor="#ccffcc"];
verify_green [label="Verify passes\nAll green", shape=diamond];
refactor [label="REFACTOR\nClean up", shape=box, style=filled, fillcolor="#ccccff"];
next [label="Next", shape=ellipse];
red -> verify_red;
verify_red -> green [label="yes"];
verify_red -> red [label="wrong\nfailure"];
green -> verify_green;
verify_green -> refactor [label="yes"];
verify_green -> green [label="no"];
refactor -> verify_green [label="stay\ngreen"];
verify_green -> next;
next -> red;
}
Write one minimal test showing what should happen.
<Good> ```typescript test('retries failed operations 3 times', async () => { let attempts = 0; const operation = () => { attempts++; if (attempts < 3) throw new Error('fail'); return 'success'; };const result = await retryOperation(operation);
expect(result).toBe('success'); expect(attempts).toBe(3); });
Clear name, tests real behavior, one thing
</Good>
<Bad>
```typescript
test('retry works', async () => {
const mock = jest.fn()
.mockRejectedValueOnce(new Error())
.mockRejectedValueOnce(new Error())
.mockResolvedValueOnce('success');
await retryOperation(mock);
expect(mock).toHaveBeenCalledTimes(3);
});
Vague name, tests mock not code </Bad>
Requirements:
MANDATORY. Never skip.
npm test path/to/test.test.ts
Confirm:
Test passes? You're testing existing behavior. Fix test.
Test errors? Fix error, re-run until it fails correctly.
Write simplest code to pass the test.
<Good> ```typescript async function retryOperation<T>(fn: () => Promise<T>): Promise<T> { for (let i = 0; i < 3; i++) { try { return await fn(); } catch (e) { if (i === 2) throw e; } } throw new Error('unreachable'); } ``` Just enough to pass </Good> <Bad> ```typescript async function retryOperation<T>( fn: () => Promise<T>, options?: { maxRetries?: number; backoff?: 'linear' | 'exponential'; onRetry?: (attempt: number) => void; } ): Promise<T> { // YAGNI } ``` Over-engineered </Bad>Don't add features, refactor other code, or "improve" beyond the test.
MANDATORY.
npm test path/to/test.test.ts
Confirm:
Test fails? Fix code, not test.
Other tests fail? Fix now.
After green only:
Keep tests green. Don't add behavior.
Next failing test for next feature.
…
Turn requirements into a clear step-by-step execution plan before implementation.
Set conversation rules to discover and invoke skills before replying.
Systematically investigate bugs, test failures, and unexpected behavior before fixing.
Helps decide merge, PR, or cleanup steps after branch work is complete.
Execute implementation plans by splitting and advancing independent tasks in-session.
Clarify intent, requirements, and solution direction before any creative implementation work.
Write failing tests first to implement features and bug fixes reliably.
Use test-first development to improve code quality and maintainability.
Build features, fix bugs, and refactor code with test-driven development.
Create process documentation with test-driven validation before finalizing the draft.
Write behavior-focused, refactor-resistant tests that verify intent and regressions.
Practice test-driven development for Spring Boot features, fixes, and refactoring.