# TDD Workflow

Use this skill when writing new features, fixing bugs, or refactoring code.

- Repository: https://github.com/WorldFlowAI/everything-claude-code (5734 stars)
- Category: Testing
- License: see repository
- Last updated: 2026-01-23
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add WorldFlowAI/everything-claude-code --skill tdd-workflow -g -a claude-code -y`
Codex: `npx skills add WorldFlowAI/everything-claude-code --skill tdd-workflow -g -a codex -y`
Cursor: `npx skills add WorldFlowAI/everything-claude-code --skill tdd-workflow -g -a cursor -y`
Gemini CLI: `npx skills add WorldFlowAI/everything-claude-code --skill tdd-workflow -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add WorldFlowAI/everything-claude-code`

## Description

Use this skill when writing new features, fixing bugs, or refactoring code. Enforces test-driven development with 80%+ coverage including unit, integration, and E2E tests.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# 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
describe('Semantic Search', () => {
  it('returns relevant markets for query', async () => {
    // Test implementation
  })

  it('handles empty query gracefully', async () => {
    // Test edge case
  })

  it('falls back to substring search when Redis unavailable', async () => {
    // Test fallback behavior
  })

  it('sorts results by similarity score', async () => {
    // Test sorting logic
  })
})
```

### Step 3: Run Tests (They Should Fail)
```bash
npm test
# Tests should fail - we haven't implemented yet
```

### Step 4: Implement Code
Write minimal code to make tests pass:

```typescript
// Implementation guided by tests
export async function searchMarkets(query: string) {
  // Implementation here
}
```

The rest: https://github.com/WorldFlowAI/everything-claude-code/blob/HEAD/skills/tdd-workflow/SKILL.md
