Usage Examples

Real-world scenarios demonstrating effective use of the TDD plugin for test-first development and comprehensive test coverage.

Examples

Simple Feature with TDD

Scenario: You've implemented a utility function and need to ensure it has proper test coverage.

# Implement the function
> claude "create a function to validate email addresses with proper regex"

# Add test coverage
> /tdd:write-tests

Expected Flow:

  1. Plugin analyzes changes (single simple file)

  2. Writes tests directly (no agent orchestration needed)

  3. Creates test file with comprehensive cases:

    • Valid email formats

    • Invalid email formats

    • Edge cases (empty, special characters)

    • Error handling

Generated Test Example:

Complex Feature with Agent Orchestration

Scenario: You've implemented a multi-file payment processing feature and need comprehensive test coverage.

Expected Flow:

  1. Plugin detects multiple changed files with complex logic

  2. Launches parallel coverage reviewer agents per file

  3. Coverage reviewers identify test cases needed:

  1. Launches parallel developer agents to write tests

  2. Verification agents confirm coverage completeness

  3. Full test suite runs to verify all pass

Fixing Tests After Refactoring

Scenario: You refactored the authentication system from sessions to JWT, and now tests are failing.

Expected Flow:

  1. Plugin runs full test suite, identifies 12 failing tests across 4 files

  2. Groups failures by file:

  1. Launches parallel agents per test file

  2. Each agent analyzes failures and fixes:

  1. Full suite passes after fixes

Agent Output Example:

Test-First Bug Fix

Scenario: Bug reported - empty usernames are accepted during registration.

Expected Flow:

  1. Initial test written to fail:

  1. Test fails (RED phase confirmed)

  2. Fix implemented

  3. Test passes (GREEN)

  4. /tdd:write-tests adds comprehensive edge cases:

Coverage Review for Critical Module

Scenario: Before deploying a critical financial calculation module, you want to ensure comprehensive test coverage.

Expected Coverage Review Output:

After Test Generation:

Post-Dependency Update Test Fixes

Scenario: After updating a major dependency (React 17 to 18), several tests are failing due to API changes.

Expected Agent Analysis:

Multi-Module Test Coverage

Scenario: New microservice with multiple modules needs comprehensive test coverage before first deployment.

Expected Multi-Agent Orchestration:

Integration with Other Plugins

With Reflexion (Implement-Reflect-Test-Memorize)

Memorized Knowledge (added to CLAUDE.md):

With Code Review (TDD-Review-Fix Cycle)

Code Review Output:

With SDD (Spec-Driven Development)

With Git (Complete Pre-Commit Workflow)

Anti-Pattern Detection Examples

Detecting Mock Abuse

Scenario: Test is asserting on mock existence rather than behavior.

Plugin Detection:

Detecting Test-Only Methods

Scenario: Production class contains methods only used in tests.

Plugin Detection:

Detecting Incomplete Mocks

Scenario: Mock is missing fields that downstream code depends on.

Plugin Warning:

Command Cheat Sheet

Scenario
Command

Cover all local changes

/tdd:write-tests

Cover specific module

/tdd:write-tests authentication module

Focus on edge cases

/tdd:write-tests Focus on edge cases and error handling

Fix all failing tests

/tdd:fix-tests

Fix specific test files

/tdd:fix-tests payment tests

Fix after refactoring

/tdd:fix-tests after API refactoring

Fix after dependency update

/tdd:fix-tests React 18 migration

Last updated