Back to Skills

tdd-test-generation

thkt
Updated Today
27 views
3
3
View on GitHub
Metatestingdesign

About

This Claude Skill provides comprehensive TDD guidance using the RGRC cycle and Baby Steps methodology. It offers systematic test design techniques including equivalence partitioning, boundary value analysis, and decision tables for generating test cases. Use it when implementing TDD workflows, discussing test generation strategies, or building test-generator agents.

Documentation

TDD Test Generation - Comprehensive Test-Driven Development Guide

Overview

This skill provides systematic guidance for Test-Driven Development (TDD) combining:

  1. RGRC Cycle - Red-Green-Refactor-Commit workflow inspired by t_wada
  2. Baby Steps - Incremental development with 2-minute cycles
  3. Systematic Test Design - Equivalence partitioning, boundary value analysis, decision tables
  4. Test Generation - From SOW test plans to executable test cases

When to Use This Skill

Automatic Triggers

Keywords that activate this skill:

  • TDD, Test-Driven Development, テスト駆動開発
  • RGRC, Red-Green-Refactor, Baby Steps
  • Test generation, test design, test cases
  • Equivalence partitioning, boundary value, decision table
  • Coverage, test first, unit test

Explicit Invocation

For guaranteed activation:

  • "Apply TDD skill"
  • "Use TDD test generation skill"
  • "Follow RGRC cycle"

Common Scenarios

  • Implementing features with /code command
  • Generating tests with test-generator agent
  • Planning test coverage strategies
  • Refactoring with test safety nets
  • Reviewing test design quality

Core Concepts

1. Baby Steps - The Foundation

"Make the smallest possible change at each step" - t_wada

Why it matters:

  • Immediate error localization (bug is in last 2-minute change)
  • Continuous working state (always seconds from green)
  • Rapid feedback loop
  • Confidence through small successes

2-Minute Cycle:

  1. Write smallest failing test (30s)
  2. Make it pass minimally (1min)
  3. Run tests (10s)
  4. Tiny refactor (30s)
  5. Commit if green (20s)

2. RGRC Cycle

Goal: "Clean code that works" (動作するきれいなコード) - Ron Jeffries

Red Phase

Write failing test → Verify correct failure reason

Green Phase

Minimal code to pass → "You can sin" (quick/dirty OK)

Refactor Phase

Apply SOLID/DRY → Improve structure → Keep tests green

Commit Phase

All checks pass → Save stable state

3. Systematic Test Design

Quality > Quantity - Fewer well-designed tests catch more bugs

Equivalence Partitioning

Group inputs with same behavior, test one from each:

// Age validation: <18 (invalid), 18-120 (valid), >120 (invalid)
test('partition 1: rejects 17', () => ...)
test('partition 2: accepts 30', () => ...)
test('partition 3: rejects 121', () => ...)

Boundary Value Analysis

Test edges [min-1, min, max, max+1]:

test('boundary: rejects 17 (18-1)', () => ...)
test('boundary: accepts 18 (min)', () => ...)
test('boundary: accepts 120 (max)', () => ...)
test('boundary: rejects 121 (120+1)', () => ...)

Decision Table Testing

Complex logic with multiple conditions:

// isLoggedIn × isPremium × isActive → canAccess
// Use decision table to cover all combinations systematically

Detailed Knowledge Base

Reference Documents

  • [@./references/tdd-rgrc.md] - Complete RGRC cycle guide with t_wada's methodology
  • [@./references/test-design.md] - Systematic test design techniques, coverage goals (C0: 80%, C1: 70%), framework-agnostic patterns

Integration Points

With Agents

  • test-generator - Generates tests from SOW using this skill's principles
  • testability-reviewer - Evaluates test design quality

With Commands

  • /code - Applies TDD during implementation
  • /test - Validates coverage and quality

Integration Method

# In agent YAML frontmatter
dependencies: [tdd-test-generation]

Or explicit reference:

[@~/.claude/skills/tdd-test-generation/SKILL.md]

Quick Start

New Feature

  1. Red - Write failing test
  2. Green - Minimal code
  3. Refactor - Clean up
  4. Commit - Save
  5. Repeat

From SOW

  1. Read SOW test plan
  2. Apply equivalence partitioning
  3. Add boundary values
  4. Generate test cases
  5. Verify coverage

Refactoring

  1. Ensure comprehensive tests
  2. Verify green
  3. Refactor incrementally
  4. Run frequently
  5. Commit when green

Best Practices

Do's ✅

  • Write test before code
  • Keep steps small (Baby Steps)
  • Run tests frequently
  • Commit when green
  • Use systematic test design
  • Apply SOLID/DRY in Refactor, not before

Don'ts ❌

  • Skip Red phase
  • Write multiple tests before any pass
  • Refactor without green tests
  • Commit with failing tests
  • Random test selection
  • Complex architecture in Green phase

Coverage Goals

Industry-recommended targets:

  • C0 (Statement): 80% minimum
  • C1 (Branch): 70% minimum

Why: Cost-benefit balance, focus on critical paths

When NOT to Use TDD

Skip for:

  • Prototypes (throwaway code)
  • External API integration (use mocks)
  • Simple one-off scripts
  • UI experiments (visual iteration first)

Success Metrics

TDD is working when:

  • Tests written before code (100%)
  • Cycles complete in <5 min
  • Refactoring feels safe
  • Coverage meets targets
  • Velocity increases over time

Resources

references/

Comprehensive documentation loaded as needed:

  • tdd-rgrc.md - Detailed RGRC cycle implementation
  • test-design.md - Complete test design techniques guide

scripts/

Currently empty - no automation scripts needed (knowledge-only skill)

assets/

Currently empty - no template files needed (knowledge-only skill)

Quick Install

/plugin add https://github.com/thkt/claude-config/tree/main/tdd-test-generation

Copy and paste this command in Claude Code to install this skill

GitHub 仓库

thkt/claude-config
Path: skills/tdd-test-generation

Related Skills

evaluating-llms-harness

Testing

This Claude Skill runs the lm-evaluation-harness to benchmark LLMs across 60+ standardized academic tasks like MMLU and GSM8K. It's designed for developers to compare model quality, track training progress, or report academic results. The tool supports various backends including HuggingFace and vLLM models.

View skill

langchain

Meta

LangChain is a framework for building LLM applications using agents, chains, and RAG pipelines. It supports multiple LLM providers, offers 500+ integrations, and includes features like tool calling and memory management. Use it for rapid prototyping and deploying production systems like chatbots, autonomous agents, and question-answering services.

View skill

webapp-testing

Testing

This Claude Skill provides a Playwright-based toolkit for testing local web applications through Python scripts. It enables frontend verification, UI debugging, screenshot capture, and log viewing while managing server lifecycles. Use it for browser automation tasks but run scripts directly rather than reading their source code to avoid context pollution.

View skill

business-rule-documentation

Meta

This skill provides standardized templates for systematically documenting business logic and domain knowledge following Domain-Driven Design principles. It helps developers capture business rules, process flows, decision trees, and terminology glossaries to maintain consistency between requirements and implementation. Use it when documenting domain models, creating business rule repositories, or bridging communication between business and technical teams.

View skill