skills/benny9193/tdd/SKILL.md
Test-Driven Development workflow - write tests first, then implementation
npx skillsauth add aiskillstore/marketplace tddInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Follow the Red-Green-Refactor cycle strictly. Never write production code without a failing test first.
┌─────────────────────────────────────────┐
│ │
│ ┌───────┐ │
│ │ RED │ Write a failing test │
│ └───┬───┘ │
│ │ │
│ ▼ │
│ ┌───────┐ │
│ │ GREEN │ Write minimal code to pass│
│ └───┬───┘ │
│ │ │
│ ▼ │
│ ┌──────────┐ │
│ │ REFACTOR │ Improve without │
│ └────┬─────┘ breaking tests │
│ │ │
│ └──────────────────────────────┘
No production code without a failing test
Write the minimum test to fail
Write the minimum code to pass
Refactor only when green
// Start with what you want the API to look like
describe('Calculator', () => {
it('should add two numbers', () => {
const calc = new Calculator();
expect(calc.add(2, 3)).toBe(5);
});
});
Run test → Watch it fail → Confirm it fails for the RIGHT reason
// Write the SIMPLEST code that passes
class Calculator {
add(a: number, b: number): number {
return 5; // Yes, hardcoding is fine here!
}
}
Run test → Watch it pass → Celebrate (briefly)
it('should add different numbers', () => {
const calc = new Calculator();
expect(calc.add(1, 1)).toBe(2); // Forces real implementation
});
class Calculator {
add(a: number, b: number): number {
return a + b; // Now we generalize
}
}
With green tests, improve the code:
Use this pattern: should [expected behavior] when [condition]
it('should return empty array when input is null')
it('should throw ValidationError when email is invalid')
it('should retry 3 times when connection fails')
Before writing ANY code, verify:
Before marking GREEN:
Before REFACTORING:
This is not TDD. Tests written after tend to test implementation, not behavior.
Write ONE test, make it pass, then write the next. Stay in the cycle.
If your implementation is more than a few lines, you skipped steps. Add intermediate tests.
// BAD - tests implementation
expect(user._hashedPassword).toMatch(/^[a-f0-9]{64}$/);
// GOOD - tests behavior
expect(user.verifyPassword('correct')).toBe(true);
Never refactor with failing tests. Get green first.
Goal: Implement a slugify function
// Test 1: Simplest case
it('should lowercase the input', () => {
expect(slugify('Hello')).toBe('hello');
});
// Implementation: return input.toLowerCase();
// Test 2: Handle spaces
it('should replace spaces with hyphens', () => {
expect(slugify('Hello World')).toBe('hello-world');
});
// Implementation: return input.toLowerCase().replace(/ /g, '-');
// Test 3: Handle special characters
it('should remove special characters', () => {
expect(slugify('Hello, World!')).toBe('hello-world');
});
// Implementation: add .replace(/[^a-z0-9-]/g, '');
// Test 4: Edge case
it('should handle empty string', () => {
expect(slugify('')).toBe('');
});
// Already passes! No change needed.
"TDD is not about testing. It's about design."
The tests drive you toward better, more modular code. Trust the process.
development
Apple Human Interface Guidelines for content display components. Use this skill when the user asks about charts component, collection view, image view, web view, color well, image well, activity view, lockup, data visualization, content display, displaying images, rendering web content, color pickers, or presenting collections of items in Apple apps. Also use when the user says how should I display charts, what's the best way to show images, should I use a web view, how do I build a grid of items, what component shows media, or how do I present a share sheet. Cross-references: hig-foundations for color/typography/accessibility, hig-patterns for data visualization patterns, hig-components-layout for structural containers, hig-platforms for platform-specific component behavior.
tools
Automate HelpDesk tasks via Rube MCP (Composio): list tickets, manage views, use canned responses, and configure custom fields. Always search tools first for current schemas.
testing
Expert Haskell engineer specializing in advanced type systems, pure functional design, and high-reliability software. Use PROACTIVELY for type-level programming, concurrency, and architecture guidance.
tools
GraphQL gives clients exactly the data they need - no more, no less. One endpoint, typed schema, introspection. But the flexibility that makes it powerful also makes it dangerous. Without proper controls, clients can craft queries that bring down your server. This skill covers schema design, resolvers, DataLoader for N+1 prevention, federation for microservices, and client integration with Apollo/urql. Key insight: GraphQL is a contract. The schema is the API documentation. Design it carefully.