Skip to main content

Overview

The tdd-guide agent is a Test-Driven Development specialist who ensures all code is developed test-first with comprehensive coverage (80%+ required).
string
default:"tdd-guide"
Agent identifier
string
default:"sonnet"
Uses Claude Sonnet for efficient test generation
array
Available tools: Read, Write, Edit, Bash, Grep

When to Use

Writing new features
Fixing bugs
Refactoring existing code
Ensuring test coverage meets 80%+ threshold
The tdd-guide agent activates PROACTIVELY when writing new features, fixing bugs, or refactoring code.

Core Responsibilities

  • Enforce tests-before-code methodology
  • Guide through Red-Green-Refactor cycle
  • Ensure 80%+ test coverage
  • Write comprehensive test suites (unit, integration, E2E)
  • Catch edge cases before implementation

TDD Workflow

The agent follows the classic Red-Green-Refactor cycle:

1. Write Test First (RED)

Write a failing test that describes the expected behavior.

2. Run Test — Verify it FAILS

If the test passes immediately, you haven’t written a proper test!

3. Write Minimal Implementation (GREEN)

Only enough code to make the test pass.

4. Run Test — Verify it PASSES

5. Refactor (IMPROVE)

Remove duplication, improve names, optimize — tests must stay green.

6. Verify Coverage

Coverage must be at least 80% for all metrics

Test Types Required

Unit Tests

Test individual functions without external dependencies:

Integration Tests

Test API endpoints and database operations:

E2E Tests

Test critical user journeys:

Edge Cases You MUST Test

Never skip edge case testing!
  1. Null/Undefined input
  2. Empty arrays/strings
  3. Invalid types passed
  4. Boundary values (min/max)
  5. Error paths (network failures, DB errors)
  6. Race conditions (concurrent operations)
  7. Large data (performance with 10k+ items)
  8. Special characters (Unicode, emojis, SQL chars)

Test Anti-Patterns to Avoid

Common mistakes that reduce test value:

Bad: Testing Implementation Details

Good: Testing Behavior

Mocking External Dependencies

Always mock external services to keep tests fast and deterministic:

Quality Checklist

  • All public functions have unit tests
  • All API endpoints have integration tests
  • Critical user flows have E2E tests
  • Coverage is 80%+ (branches, functions, lines, statements)
  • Null/undefined inputs tested
  • Empty arrays/strings tested
  • Invalid type inputs tested
  • Boundary values tested
  • Error paths tested (not just happy path)
  • External dependencies mocked
  • Tests are independent (no shared state)
  • Assertions are specific and meaningful
  • Test names clearly describe behavior
  • Tests run fast (<100ms per unit test)

Running Tests

Usage Example

Success Criteria

Tests written before implementation
All tests pass
Coverage meets 80%+ threshold
Edge cases covered
External dependencies mocked
Tests are independent and fast
For detailed mocking patterns and framework-specific examples, use the tdd-workflow skill.