distributions/codex/skills/tdd-workflow/SKILL.md
Test-driven development workflow with comprehensive coverage requirements including unit, integration, and E2E tests
npx skillsauth add a-organvm/a-i--skills tdd-workflowInstall 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.
Enforces test-driven development principles with comprehensive test coverage across all layers.
Always write tests first, then implement code to make tests pass. No exceptions.
┌────────┐
│ E2E │ (10-20%)
├────────┤
│ INTEG │ (20-30%)
├────────┤
│ UNIT │ (50-70%)
└────────┘
Start with the user story:
As a [role], I want to [action], so that [benefit]
Example:
As a user, I want to search for products by category,
so that I can find relevant items quickly.
Write the test:
describe('ProductSearch', () => {
it('returns products filtered by category', async () => {
const products = await searchProducts({ category: 'electronics' });
expect(products).toHaveLength(5);
expect(products.every(p => p.category === 'electronics')).toBe(true);
});
});
npm test
# ✗ ProductSearch > returns products filtered by category
# TypeError: searchProducts is not a function
This is good! Red phase confirms test is working.
Write just enough code to pass:
export async function searchProducts(filters: SearchFilters) {
const { category } = filters;
return db.products.findMany({
where: { category }
});
}
npm test
# ✓ ProductSearch > returns products filtered by category (42ms)
Now refactor while keeping tests green:
export async function searchProducts(filters: SearchFilters) {
const query = buildSearchQuery(filters);
const results = await executeSearch(query);
return transformResults(results);
}
Run tests again to ensure they still pass.
Purpose: Test individual functions in isolation
describe('calculateDiscount', () => {
it('applies 10% discount for basic tier', () => {
const price = calculateDiscount(100, 'basic');
expect(price).toBe(90);
});
it('applies 20% discount for premium tier', () => {
const price = calculateDiscount(100, 'premium');
expect(price).toBe(80);
});
it('throws error for invalid tier', () => {
expect(() => calculateDiscount(100, 'invalid')).toThrow();
});
});
Purpose: Test multiple components working together
describe('User Registration API', () => {
it('creates user and sends welcome email', async () => {
const response = await request(app)
.post('/api/register')
.send({ email: '[email protected]', password: 'secret' }); // allow-secret
expect(response.status).toBe(201);
expect(response.body.user.email).toBe('[email protected]');
// Verify email was sent
const sentEmails = await testEmailService.getSentEmails();
expect(sentEmails).toHaveLength(1);
expect(sentEmails[0].to).toBe('[email protected]');
});
});
Purpose: Test complete user flows through the UI
test('user can complete checkout process', async ({ page }) => {
await page.goto('/products');
await page.click('[data-testid="add-to-cart"]');
await page.click('[data-testid="cart"]');
await page.click('[data-testid="checkout"]');
await page.fill('[name="cardNumber"]', '4242424242424242');
await page.click('[data-testid="complete-order"]');
await expect(page.locator('.success-message')).toBeVisible();
await expect(page).toHaveURL(/\/order-confirmation/);
});
After implementation, check coverage:
npm test -- --coverage
# Output:
# File | % Stmts | % Branch | % Funcs | % Lines
# --------------|---------|----------|---------|--------
# All files | 84.2 | 78.5 | 91.3 | 85.1
Requirements:
Always test:
// Mock external service
vi.mock('./emailService', () => ({
sendEmail: vi.fn().mockResolvedValue({ success: true })
}));
// Mock database
vi.mock('./db', () => ({
users: {
findUnique: vi.fn().mockResolvedValue({ id: 1, name: 'Test' })
}
}));
// Mock Date.now()
vi.spyOn(Date, 'now').mockReturnValue(1234567890000);
src/
features/
products/
product.service.ts
product.service.test.ts # Unit tests
product.integration.test.ts # Integration tests
product.e2e.test.ts # E2E tests
# Run single test file
npm test -- product.service.test.ts
# Run single test
npm test -- -t "calculates discount correctly"
# Run in watch mode
npm test -- --watch
# Run with coverage
npm test -- --coverage --no-cache
Complements:
Never skip steps. Never commit untested code.
testing
Designs systems for encoding, scoring, and generating choreographic movement using Laban notation, computational geometry, and procedural animation principles.
tools
Manage monorepos and multi-package repositories with workspace tools, dependency management, selective builds, and change detection. Covers npm/pnpm workspaces, Turborepo, and Python monorepo patterns. Triggers on monorepo setup, workspace management, or multi-package repository requests.
development
Curated bundle for managing monorepos with containerized deployment pipelines. Includes monorepo management, Docker containerization, CI/CD deployment, and coding standards. Use when setting up or improving multi-package repository infrastructure.
development
Apply modular synthesis principles to system design, workflow architecture, and conceptual frameworks. Use when designing modular systems, creating architecture diagrams using synthesis metaphors, applying signal flow thinking to data pipelines, or translating between audio engineering and software concepts. Triggers on modular architecture design, signal flow diagrams, synthesis-inspired system thinking, or "oscillator/patch" metaphors.