.fyi
SkillsMCPPluginsSubagents

Browse by category

DevOps & CI/CD SkillsProductivity & Workflow SkillsOther SkillsProduct & Project Management SkillsDocumentation & Knowledge SkillsCode Review & Refactor SkillsBackend & APIs SkillsAgent Meta & Communication SkillsResearch SkillsSecurity SkillsUX UI & Design SkillsTesting & QA SkillsSee all →

Every Claude Code skill, MCP server, plugin and subagent in one directory. Searchable, comparable, and one command from installed. Live stats from GitHub, npm and PyPI.

We're on Product HuntYour agent's app storeCheck it out →
Agent SkillsMCP ServersPluginsSubagentsCoding Agents
CollectionsOfficial publishersGlossaryFAQBlogSearchSavedFeedback
PrivacyTermsllms.txtSitemap

made with ♥ · © 2026 aaaa.fyi

Independent project · real data from public registries

…/superpowers/test-driven-development
home/skills/obra/superpowers/test-driven-development
obra avatar

test-driven-development

byobra· 95 skills

Installs

181k

Stars

261k

Forks

23k

Category

Testing & QA

View on GitHub

TL;DR

Use when implementing any feature or bugfix, before writing implementation code

How to install test-driven-development?

obra/superpowers/test-driven-development
$npx -y skills add obra/superpowers --skill test-driven-development

Installs into the current project.

›Prefer a prompt? Paste this to your agent

Use this skill

Run `npx skills use "https://github.com/obra/superpowers" --skill "obra/superpowers/test-driven-development"` and follow the generated skill instructions now. Read its complete output, redirecting it to a temporary file first if necessary. Resolve relative paths from the supporting-files directory it provides.

Use the whole pack

Use the skills in "https://github.com/obra/superpowers" that are relevant to the current task. Run `npx skills add "https://github.com/obra/superpowers"` and select the relevant skills, then follow their instructions.

Files · 1

View on GitHub
SKILL.md
1# Test-Driven Development (TDD)
2 
3## Overview
4 
5Write the test first. Watch it fail. Write minimal code to pass.
6 
7**Core principle:** If you didn't watch the test fail, you don't know if it tests the right thing.
8 
9**Violating the letter of the rules is violating the spirit of the rules.**
10 
11## When to Use
12 
13**Always:**
14- New features
15- Bug fixes
16- Refactoring
17- Behavior changes
18 
19**Exceptions (ask your human partner):**
20- Throwaway prototypes
21- Generated code
22- Configuration files
23 
24Thinking "skip TDD just this once"? Stop. That's rationalization.
25 
26## The Iron Law
27 
28```
29NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
30```
31 
32Write code before the test? Delete it. Start over.
33 
34**No exceptions:**
35- Don't keep it as "reference"
36- Don't "adapt" it while writing tests
37- Don't look at it
38- Delete means delete
39 
40Implement fresh from tests. Period.
41 
42## Red-Green-Refactor
43 
44```dot
45digraph tdd_cycle {
46 rankdir=LR;
47 red [label="RED\nWrite failing test", shape=box, style=filled, fillcolor="#ffcccc"];
48 verify_red [label="Verify fails\ncorrectly", shape=diamond];
49 green [label="GREEN\nMinimal code", shape=box, style=filled, fillcolor="#ccffcc"];
50 verify_green [label="Verify passes\nAll green", shape=diamond];
51 refactor [label="REFACTOR\nClean up", shape=box, style=filled, fillcolor="#ccccff"];
52 next [label="Next", shape=ellipse];
53 
54 red -> verify_red;
55 verify_red -> green [label="yes"];
56 verify_red -> red [label="wrong\nfailure"];
57 green -> verify_green;
58 verify_green -> refactor [label="yes"];
59 verify_green -> green [label="no"];
60 refactor -> verify_green [label="stay\ngreen"];
61 verify_green -> next;
62 next -> red;
63}
64```
65 
66### RED - Write Failing Test
67 
68Write one minimal test showing what should happen.
69 
70<Good>
71```typescript
72test('retries failed operations 3 times', async () => {
73 let attempts = 0;
74 const operation = () => {
75 attempts++;
76 if (attempts < 3) throw new Error('fail');
77 return 'success';
78 };
79 
80 const result = await retryOperation(operation);
81 
82 expect(result).toBe('success');
83 expect(attempts).toBe(3);
84});
85```
86Clear name, tests real behavior, one thing
87</Good>
88 
89<Bad>
90```typescript
91test('retry works', async () => {
92 const mock = jest.fn()
93 .mockRejectedValueOnce(new Error())
94 .mockRejectedValueOnce(new Error())
95 .mockResolvedValueOnce('success');
96 await retryOperation(mock);
97 expect(mock).toHaveBeenCalledTimes(3);
98});
99```
100Vague name, tests mock not code
101</Bad>
102 
103**Requirements:**
104- One behavior
105- Clear name
106- Real code (no mocks unless unavoidable)
107 
108### Verify RED - Watch It Fail
109 
110**MANDATORY. Never skip.**
111 
112```bash
113npm test path/to/test.test.ts
114```
115 
116Confirm:
117- Test fails (not errors)
118- Failure message is expected
119- Fails because feature missing (not typos)
120 
121**Test passes?** You're testing existing behavior. Fix test.
122 
123**Test errors?** Fix error, re-run until it fails correctly.
124 
125### GREEN - Minimal Code
126 
127Write simplest code to pass the test.
128 
129<Good>
130```typescript
131async function retryOperation<T>(fn: () => Promise<T>): Promise<T> {
132 for (let i = 0; i < 3; i++) {
133 try {
134 return await fn();
135 } catch (e) {
136 if (i === 2) throw e;
137 }
138 }
139 throw new Error('unreachable');
140}
141```
142Just enough to pass
143</Good>
144 
145<Bad>
146```typescript
147async function retryOperation<T>(
148 fn: () => Promise<T>,
149 options?: {
150 maxRetries?: number;
151 backoff?: 'linear' | 'exponential';
152 onRetry?: (attempt: number) => void;
153 }
154): Promise<T> {
155 // YAGNI
156}
157```
158Over-engineered
159</Bad>
160 
161Don't add features, refactor other code, or "improve" beyond the test.
162 
163### Verify GREEN - Watch It Pass
164 
165**MANDATORY.**
166 
167```bash
168npm test path/to/test.test.ts
169```
170 
171Confirm:
172- Test passes
173- Other tests still pass
174- Output pristine (no errors, warnings)
175 
176**Test fails?** Fix code, not test.
177 
178**Other tests fail?** Fix now.
179 
180### REFACTOR - Clean Up
181 
182After green only:
183- Remove duplication
184- Improve names
185- Extract helpers
186 
187Keep tests green. Don't add behavior.
188 
189### Repeat
190 
191Next failing test for next feature.
192 
193## Good Tests
194 
195| Quality | Good | Bad |
196|---------|------|-----|
197| **Minimal** | One thing. "and" in name? Split it. | `test('validates email and domain and whitespace')` |
198| **Clear** | Name describes behavior | `test('test1')` |
199| **Shows intent** | Demonstrates desired API | Obscures what code should do |
200 
201When writing or changing any test, read [writing-good-tests.md](writing-good-tests.md) for the rules that keep tests honest:
202- Name the production change that would make the test fail — before writing it
203- Assert on real behavior, never on mock behavior
204- Keep test-only code in test utilities, out of production classes
205- Understand a dependency's side effects before mocking it
206 
207## Common Rationalizations
208 
209| Excuse | Reality |
210|--------|---------|
211| "Too simple to test" | Simple code breaks. Test takes 30 seconds. |
212| "I'll test after" | Tests written after pass immediately — which proves nothing. They may test the wrong thing, test the implementation instead of the behavior, or miss the edge case you forgot. You never watched it fail, so you never proved it can catch the bug. Test-first forces that failure. |
213| "Tests after achieve same goals (spirit not ritual)" | Tests-after answer "what does this do?"; tests-first answer "what should this do?" Tests written after are biased by the code you already wrote — you verify the cases you remembered, not the ones you'd have discovered. Coverage without proof the tests work. |
214| "Already manually tested" | Manual testing is ad-hoc: no record of what you covered, no way to re-run it when the code changes, easy to forget cases under pressure. "Worked when I tried it" ≠ comprehensive. Automated tests run the same way every time. |
215| "Deleting X hours is wasteful" | Sunk cost fallacy — that time is already spent either way. The real choice: rewrite with TDD (high confidence) vs. keep it and bolt tests on after (low confidence, likely bugs). Keeping code you can't trust is the waste. |
216| "Keep as reference, write tests first" | You'll adapt it. That's testing after. Delete means delete. |
217| "Need to explore first" | Fine. Throw away exploration, start with TDD. |
218| "Test hard = design unclear" | Listen to test. Hard to test = hard to use. |
219| "TDD will slow me down" | TDD IS the pragmatic path: catches bugs before commit, prevents regressions, lets you refactor without fear. "Pragmatic" shortcuts mean debugging in production — slower, not faster. |
220| "Manual test faster" | Manual doesn't prove edge cases. You'll re-test every change. |
221| "Existing code has no tests" | You're improving it. Add tests for existing code. |
222 
223## Red Flags - STOP and Start Over
224 
225- Code before test
226- Test after implementation
227- Test passes immediately
228- Can't explain why test failed
229- Tests added "later"
230- Rationalizing "just this once"
231- "I already manually tested it"
232- "Tests after achieve the same purpose"
233- "It's about spirit not ritual"
234- "Keep as reference" or "adapt existing code"
235- "Already spent X hours, deleting is wasteful"
236- "TDD is dogmatic, I'm being pragmatic"
237- "This is different because..."
238 
239**All of these mean: Delete code. Start over with TDD.**
240 
241## Example: Bug Fix
242 
243**Bug:** Empty email accepted
244 
245**RED**
246```typescript
247test('rejects empty email', async () => {
248 const result = await submitForm({ email: '' });
249 expect(result.error).toBe('Email required');
250});
251```
252 
253**Verify RED**
254```bash
255$ npm test
256FAIL: expected 'Email required', got undefined
257```
258 
259**GREEN**
260```typescript
261function submitForm(data: FormData) {
262 if (!data.email?.trim()) {
263 return { error: 'Email required' };
264 }
265 // ...
266}
267```
268 
269**Verify GREEN**
270```bash
271$ npm test
272PASS
273```
274 
275**REFACTOR**
276Extract validation for multiple fields if needed.
277 
278## Verification Checklist
279 
280Before marking work complete:
281 
282- [ ] Every new function/method has a test
283- [ ] Watched each test fail before implementing
284- [ ] Each test failed for expected reason (feature missing, not typo)
285- [ ] Wrote minimal code to pass each test
286- [ ] All tests pass
287- [ ] Output pristine (no errors, warnings)
288- [ ] Tests use real code (mocks only if unavoidable)
289- [ ] Edge cases and errors covered
290 
291Can't check all boxes? You skipped TDD. Start over.
292 
293## When Stuck
294 
295| Problem | Solution |
296|---------|----------|
297| Don't know how to test | Write wished-for API. Write assertion first. Ask your human partner. |
298| Test too complicated | Design too complicated. Simplify interface. |
299| Must mock everything | Code too coupled. Use dependency injection. |
300| Test setup huge | Extract helpers. Still complex? Simplify design. |
301 
302## Debugging Integration
303 
304Bug found? Write failing test reproducing it. Follow TDD cycle. Test proves fix and prevents regression.
305 
306Never fix bugs without a test.
307 
308## Final Rule
309 
310```
311Production code → test exists and failed first
312Otherwise → not TDD
313```
314 
315No exceptions without your human partner's permission.

Security

Passed

  • Gen Agent Trust Hubpass
  • Socketpass
  • Snykpass
  • Runlayerpass
  • ZeroLeakspass

Preview

obra/superpowersobra/superpowers

$ npx -y skills add obra/superpowers --skill test-driven-development

▸ installing to .claude/skills…

✓ test-driven-development ready

Repoobra/superpowers
TypeSkills
CategoryTesting & QA
ForDeveloper
UpdatedJul 2026
License—
First seenJul 26, 2026

Tags

Skill

Related

6 picks
Type
  1. mattpocock avatartddTest-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.SkillsJul 2026544k189k
  2. mattpocock avatarqaInteractive QA session where user reports bugs or issues conversationally, and the agent files GitHub issues.SkillsJul 2026179k189k
  3. obra avatarverification-before-completionUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output…SkillsJul 2026160k261k
  4. anthropics avatarwebapp-testingToolkit for interacting with and testing local web applications using Playwright.SkillsJul 2026123k164k
  5. currents-dev avatarplaywright-best-practicesUse when writing Playwright tests, fixing flaky tests, debugging failures, implementing Page Object Model, configuring CI/CD, optimizing performance, mocking…SkillsJul 202666k340
  6. momentic-ai avatarmomentic-testCreate, run, and maintain Momentic E2E tests and modules, which are serialized to disk as *.test.yaml and *.module.yaml files.SkillsJul 202636k12