Test-Driven Development
Skill3 starsChanged 6 months agoMITView on GitHub
Write tests before code using RED-GREEN-REFACTOR cycle
1 other project uses a version of this.
Adopted by
Most recently taken up by
- fdhhhdjd/Class-AI-Agentword for word, first seen Oct 8, 2026
Other versions1 project uses a version of this.
Word for word · 1
- fdhhhdjd/Class-AI-Agent★ 266100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
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.
- AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- code-reviewSkill
- nestjs-backendSkill
- nodejs-backendSkill
- react-frontendSkill
- react-native-mobileSkill
- tddSkill
- Code Review & QualitySkill
- Data Transformation & AnalysisSkill
- deploySkill
- Incremental ImplementationSkill
- security-reviewSkill
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 6 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
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 16
When asked to write tests
- Distinctive: line 17
Before any implementation work
- Distinctive: line 25
Write a test that describes expected behavior.
- Very specific: line 36
Run: npm test → Should FAIL
- Distinctive: line 40
Write minimal code to pass the test.
- Very specific: line 49
Run: npm test → Should PASS
- Very specific: line 65
Run: npm test → Should still PASS
- Distinctive: line 83
Run test → Confirms bug exists
- Distinctive: line 96
Run test → Confirms fix works
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Test-Driven Development Skill
Overview
TDD transforms testing from an afterthought into the foundation of development. Tests are proof that code works correctly.
When to Invoke
- Writing new features
- Fixing bugs (Prove-It pattern)
- When asked to write tests
- Before any implementation work
Core Cycle: RED-GREEN-REFACTOR
RED Phase
Write a test that describes expected behavior. It must fail.
describe('calculateDiscount', () => {
it('should apply 10% discount for orders over $100', () => {
const result = calculateDiscount(150);
expect(result).toBe(15);
});
});Run: npm test → Should FAIL
GREEN Phase
Write minimal code to pass the test. No extras.
function calculateDiscount(amount) {
if (amount > 100) return amount * 0.1;
return 0;
}Run: npm test → Should PASS
REFACTOR Phase
Improve code while keeping tests green.
const DISCOUNT_THRESHOLD = 100;
const DISCOUNT_RATE = 0.1;
function calculateDiscount(amount) {
if (amount <= DISCOUNT_THRESHOLD) return 0;
return amount * DISCOUNT_RATE;
}Run: npm test → Should still PASS
Prove-It Pattern (Bug Fixes)
Step 1: Write Failing Test
it('should handle empty cart without error (bug #456)', () => {
const cart = new Cart([]);
expect(() => cart.getTotal()).not.toThrow();
expect(cart.getTotal()).toBe(0);
});Step 2: Verify Failure
Run test → Confirms bug exists
Step 3: Fix Bug
getTotal() {
if (this.items.length === 0) return 0; // Fix
return this.items.reduce((sum, item) => sum + item.price, 0);
}Step 4: Verify Pass
Run test → Confirms fix works
Step 5: Run Full Suite
npm test # No regressionsTest Pyramid
┌─────────┐
│ E2E │ 5% — Critical user flows
│ Tests │ Full system, minutes
├─────────┤
│ Integr. │ 15% — API + DB interactions
│ Tests │ Seconds
├─────────┤
│ Unit │ 80% — Pure logic
│ Tests │ Milliseconds
└─────────┘Test Structure: AAA Pattern
it('should calculate tax for California', () => {
// Arrange — Setup
const order = createOrder({ state: 'CA', subtotal: 100 });
// Act — Execute
const tax = calculateTax(order);
// Assert — Verify
expect(tax).toBe(7.25);
});DAMP > DRY in Tests
Tests should be Descriptive And Meaningful Phrases.
// ✅ DAMP — Self-contained and clear
it('should reject password without uppercase letter', () => {
const result = validatePassword('lowercase123!');
expect(result.valid).toBe(false);
expect(result.errors).toContain('Must contain uppercase letter');
});
// ❌ Too DRY — Requires reading shared context
it('should reject invalid password', () => {
expect(validate(INVALID_PASSWORD_NO_UPPER)).toBe(false);
});Test Doubles (Preference Order)
- Real implementations — Best, but may be slow
- Fakes — In-memory DB, simplified implementations
- Stubs — Return canned responses
- Mocks — Verify interactions (use sparingly)
// ✅ Prefer: Real or fake
const db = createTestDatabase();
const user = await userService.create(db, userData);
// ⚠️ Use sparingly: Mocks
const mockDb = { create: vi.fn().mockResolvedValue(user) };Naming Conventions
// Pattern: should [expected behavior] when [condition]
// ✅ Good
'should return empty array when no users exist'
'should throw ValidationError when email is invalid'
'should send welcome email after registration'
// ❌ Bad
'works correctly'
'test user creation'
'handles error'Anti-Patterns
| Pattern | Problem | Solution |
| Testing internals | Breaks on refactor | Test behavior, not implementation |
| Flaky tests | Erodes trust | Use deterministic data |
| Over-mocking | False confidence | Prefer real implementations |
| Snapshot abuse | Large diffs ignored | Use sparingly |
| Shared mutable state | Tests affect each other | Reset in beforeEach |
| Testing frameworks | Wasted effort | Only test your code |
Verification Checklist
- All new code has tests
- Bug fixes have reproduction tests
- Tests describe behavior (readable names)
- No skipped tests
- Coverage maintained/improved
- Full suite passes
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.

