KS
Killer-Skills

tdd-workflow — what is tdd-workflow what is tdd-workflow, how to use tdd-workflow with claude, tdd-workflow vs other testing skills, tdd-workflow alternative, tdd-workflow install guide, tdd-workflow setup for MCP, tdd-workflow coverage requirements, enforce TDD with AI agent

Verified
v1.0.0
GitHub

About this Skill

Ideal for Code Optimization Agents requiring rigorous test-driven development with unit, integration, and E2E testing. tdd-workflow is an AI Agent Skill designed for Claude that enforces a strict Test-Driven Development methodology. It mandates writing tests before implementing code and ensures a minimum of 80% test coverage across unit, integration, and end-to-end (E2E) test types.

Features

Enforces writing tests BEFORE code implementation as a core TDD principle
Mandates a minimum of 80% test coverage for all code changes
Generates and manages unit, integration, and end-to-end (E2E) tests
Activates during new feature development, bug fixing, and code refactoring workflows
Provides structured workflow for adding new API endpoints and components

# Core Topics

affaan-m affaan-m
[62.0k]
[7678]
Updated: 3/6/2026

Quality Score

Top 5%
89
Excellent
Based on code quality & docs
Installation
SYS Universal Install (Auto-Detect)
Cursor IDE Windsurf IDE VS Code IDE
> npx killer-skills add affaan-m/everything-claude-code/tdd-workflow

Agent Capability Analysis

The tdd-workflow MCP Server by affaan-m is an open-source Categories.official integration for Claude and other AI agents, enabling seamless task automation and capability expansion. Optimized for what is tdd-workflow, how to use tdd-workflow with claude, tdd-workflow vs other testing skills.

Ideal Agent Persona

Ideal for Code Optimization Agents requiring rigorous test-driven development with unit, integration, and E2E testing.

Core Value

Empowers agents to enforce comprehensive test coverage of 80% or higher, ensuring code reliability and stability through test-driven development principles, including unit, integration, and end-to-end tests.

Capabilities Granted for tdd-workflow MCP Server

Implementing test-driven development for new feature development
Ensuring bug fixes with comprehensive test coverage
Refactoring existing code with confidence through thorough testing

! Prerequisites & Limits

  • Requires adherence to test-driven development principles
  • Minimum 80% test coverage required
  • Applies to code development, bug fixing, and refactoring scenarios
Project
SKILL.md
9.3 KB
.cursorrules
1.2 KB
package.json
240 B
Ready
UTF-8
SKILL.md
Readonly

Test-Driven Development Workflow

This skill ensures all code development follows TDD principles with comprehensive test coverage.

When to Activate

  • Writing new features or functionality
  • Fixing bugs or issues
  • Refactoring existing code
  • Adding API endpoints
  • Creating new components

Core Principles

1. Tests BEFORE Code

ALWAYS write tests first, then implement code to make tests pass.

2. Coverage Requirements

  • Minimum 80% coverage (unit + integration + E2E)
  • All edge cases covered
  • Error scenarios tested
  • Boundary conditions verified

3. Test Types

Unit Tests

  • Individual functions and utilities
  • Component logic
  • Pure functions
  • Helpers and utilities

Integration Tests

  • API endpoints
  • Database operations
  • Service interactions
  • External API calls

E2E Tests (Playwright)

  • Critical user flows
  • Complete workflows
  • Browser automation
  • UI interactions

TDD Workflow Steps

Step 1: Write User Journeys

As a [role], I want to [action], so that [benefit]

Example:
As a user, I want to search for markets semantically,
so that I can find relevant markets even without exact keywords.

Step 2: Generate Test Cases

For each user journey, create comprehensive test cases:

typescript
1describe('Semantic Search', () => { 2 it('returns relevant markets for query', async () => { 3 // Test implementation 4 }) 5 6 it('handles empty query gracefully', async () => { 7 // Test edge case 8 }) 9 10 it('falls back to substring search when Redis unavailable', async () => { 11 // Test fallback behavior 12 }) 13 14 it('sorts results by similarity score', async () => { 15 // Test sorting logic 16 }) 17})

Step 3: Run Tests (They Should Fail)

bash
1npm test 2# Tests should fail - we haven't implemented yet

Step 4: Implement Code

Write minimal code to make tests pass:

typescript
1// Implementation guided by tests 2export async function searchMarkets(query: string) { 3 // Implementation here 4}

Step 5: Run Tests Again

bash
1npm test 2# Tests should now pass

Step 6: Refactor

Improve code quality while keeping tests green:

  • Remove duplication
  • Improve naming
  • Optimize performance
  • Enhance readability

Step 7: Verify Coverage

bash
1npm run test:coverage 2# Verify 80%+ coverage achieved

Testing Patterns

Unit Test Pattern (Jest/Vitest)

typescript
1import { render, screen, fireEvent } from '@testing-library/react' 2import { Button } from './Button' 3 4describe('Button Component', () => { 5 it('renders with correct text', () => { 6 render(<Button>Click me</Button>) 7 expect(screen.getByText('Click me')).toBeInTheDocument() 8 }) 9 10 it('calls onClick when clicked', () => { 11 const handleClick = jest.fn() 12 render(<Button onClick={handleClick}>Click</Button>) 13 14 fireEvent.click(screen.getByRole('button')) 15 16 expect(handleClick).toHaveBeenCalledTimes(1) 17 }) 18 19 it('is disabled when disabled prop is true', () => { 20 render(<Button disabled>Click</Button>) 21 expect(screen.getByRole('button')).toBeDisabled() 22 }) 23})

API Integration Test Pattern

typescript
1import { NextRequest } from 'next/server' 2import { GET } from './route' 3 4describe('GET /api/markets', () => { 5 it('returns markets successfully', async () => { 6 const request = new NextRequest('http://localhost/api/markets') 7 const response = await GET(request) 8 const data = await response.json() 9 10 expect(response.status).toBe(200) 11 expect(data.success).toBe(true) 12 expect(Array.isArray(data.data)).toBe(true) 13 }) 14 15 it('validates query parameters', async () => { 16 const request = new NextRequest('http://localhost/api/markets?limit=invalid') 17 const response = await GET(request) 18 19 expect(response.status).toBe(400) 20 }) 21 22 it('handles database errors gracefully', async () => { 23 // Mock database failure 24 const request = new NextRequest('http://localhost/api/markets') 25 // Test error handling 26 }) 27})

E2E Test Pattern (Playwright)

typescript
1import { test, expect } from '@playwright/test' 2 3test('user can search and filter markets', async ({ page }) => { 4 // Navigate to markets page 5 await page.goto('/') 6 await page.click('a[href="/markets"]') 7 8 // Verify page loaded 9 await expect(page.locator('h1')).toContainText('Markets') 10 11 // Search for markets 12 await page.fill('input[placeholder="Search markets"]', 'election') 13 14 // Wait for debounce and results 15 await page.waitForTimeout(600) 16 17 // Verify search results displayed 18 const results = page.locator('[data-testid="market-card"]') 19 await expect(results).toHaveCount(5, { timeout: 5000 }) 20 21 // Verify results contain search term 22 const firstResult = results.first() 23 await expect(firstResult).toContainText('election', { ignoreCase: true }) 24 25 // Filter by status 26 await page.click('button:has-text("Active")') 27 28 // Verify filtered results 29 await expect(results).toHaveCount(3) 30}) 31 32test('user can create a new market', async ({ page }) => { 33 // Login first 34 await page.goto('/creator-dashboard') 35 36 // Fill market creation form 37 await page.fill('input[name="name"]', 'Test Market') 38 await page.fill('textarea[name="description"]', 'Test description') 39 await page.fill('input[name="endDate"]', '2025-12-31') 40 41 // Submit form 42 await page.click('button[type="submit"]') 43 44 // Verify success message 45 await expect(page.locator('text=Market created successfully')).toBeVisible() 46 47 // Verify redirect to market page 48 await expect(page).toHaveURL(/\/markets\/test-market/) 49})

Test File Organization

src/
├── components/
│   ├── Button/
│   │   ├── Button.tsx
│   │   ├── Button.test.tsx          # Unit tests
│   │   └── Button.stories.tsx       # Storybook
│   └── MarketCard/
│       ├── MarketCard.tsx
│       └── MarketCard.test.tsx
├── app/
│   └── api/
│       └── markets/
│           ├── route.ts
│           └── route.test.ts         # Integration tests
└── e2e/
    ├── markets.spec.ts               # E2E tests
    ├── trading.spec.ts
    └── auth.spec.ts

Mocking External Services

Supabase Mock

typescript
1jest.mock('@/lib/supabase', () => ({ 2 supabase: { 3 from: jest.fn(() => ({ 4 select: jest.fn(() => ({ 5 eq: jest.fn(() => Promise.resolve({ 6 data: [{ id: 1, name: 'Test Market' }], 7 error: null 8 })) 9 })) 10 })) 11 } 12}))

Redis Mock

typescript
1jest.mock('@/lib/redis', () => ({ 2 searchMarketsByVector: jest.fn(() => Promise.resolve([ 3 { slug: 'test-market', similarity_score: 0.95 } 4 ])), 5 checkRedisHealth: jest.fn(() => Promise.resolve({ connected: true })) 6}))

OpenAI Mock

typescript
1jest.mock('@/lib/openai', () => ({ 2 generateEmbedding: jest.fn(() => Promise.resolve( 3 new Array(1536).fill(0.1) // Mock 1536-dim embedding 4 )) 5}))

Test Coverage Verification

Run Coverage Report

bash
1npm run test:coverage

Coverage Thresholds

json
1{ 2 "jest": { 3 "coverageThresholds": { 4 "global": { 5 "branches": 80, 6 "functions": 80, 7 "lines": 80, 8 "statements": 80 9 } 10 } 11 } 12}

Common Testing Mistakes to Avoid

❌ WRONG: Testing Implementation Details

typescript
1// Don't test internal state 2expect(component.state.count).toBe(5)

✅ CORRECT: Test User-Visible Behavior

typescript
1// Test what users see 2expect(screen.getByText('Count: 5')).toBeInTheDocument()

❌ WRONG: Brittle Selectors

typescript
1// Breaks easily 2await page.click('.css-class-xyz')

✅ CORRECT: Semantic Selectors

typescript
1// Resilient to changes 2await page.click('button:has-text("Submit")') 3await page.click('[data-testid="submit-button"]')

❌ WRONG: No Test Isolation

typescript
1// Tests depend on each other 2test('creates user', () => { /* ... */ }) 3test('updates same user', () => { /* depends on previous test */ })

✅ CORRECT: Independent Tests

typescript
1// Each test sets up its own data 2test('creates user', () => { 3 const user = createTestUser() 4 // Test logic 5}) 6 7test('updates user', () => { 8 const user = createTestUser() 9 // Update logic 10})

Continuous Testing

Watch Mode During Development

bash
1npm test -- --watch 2# Tests run automatically on file changes

Pre-Commit Hook

bash
1# Runs before every commit 2npm test && npm run lint

CI/CD Integration

yaml
1# GitHub Actions 2- name: Run Tests 3 run: npm test -- --coverage 4- name: Upload Coverage 5 uses: codecov/codecov-action@v3

Best Practices

  1. Write Tests First - Always TDD
  2. One Assert Per Test - Focus on single behavior
  3. Descriptive Test Names - Explain what's tested
  4. Arrange-Act-Assert - Clear test structure
  5. Mock External Dependencies - Isolate unit tests
  6. Test Edge Cases - Null, undefined, empty, large
  7. Test Error Paths - Not just happy paths
  8. Keep Tests Fast - Unit tests < 50ms each
  9. Clean Up After Tests - No side effects
  10. Review Coverage Reports - Identify gaps

Success Metrics

  • 80%+ code coverage achieved
  • All tests passing (green)
  • No skipped or disabled tests
  • Fast test execution (< 30s for unit tests)
  • E2E tests cover critical user flows
  • Tests catch bugs before production

Remember: Tests are not optional. They are the safety net that enables confident refactoring, rapid development, and production reliability.

Related Skills

Looking for an alternative to tdd-workflow or building a Categories.official AI Agent? Explore these related open-source MCP Servers.

View All

flags

Logo of facebook
facebook

flags is a feature flag management system that enables developers to check flag states, compare channels, and debug feature behavior differences across release channels.

243.6k
0
Design

extract-errors

Logo of facebook
facebook

extract-errors is a skill that assists in extracting and managing error codes in React applications using yarn extract-errors command.

243.6k
0
Design

fix

Logo of facebook
facebook

fix is a technical skill that resolves lint errors, formatting issues, and ensures code quality in declarative, frontend, and UI projects

243.6k
0
Design

flow

Logo of facebook
facebook

Flow is a type checking system for JavaScript, used to validate React code and ensure consistency across applications

243.6k
0
Design