Skip to content

Test-first workflow plugin that injects red-green-refactor reminders into every Claude Code session.

CCM score
42 of 100
GitHub stars
201
View on GitHub

Own this plugin? Claim it

What it does

  • Adds a test-driven-development skill covering the red-green-refactor cycle for new functions, features, bug fixes, and refactors
  • Ships hooks on UserPromptSubmit that remind Claude to follow TDD on every prompt, and on SubagentStop for subagents
  • Guides writing a failing test first, running it to confirm the failure, implementing minimal code, then refactoring with tests green
  • Designed for teams that practice TDD or work in codebases with comprehensive test coverage

Test-Driven Development (TDD) principles and red-green-refactor cycle enforcement

Add marketplace

/plugin marketplace add TheBushidoCollective/han

Run it inside Claude Code once, then install the plugin below.

Install

/plugin install tdd@han

Run it inside Claude Code after adding the marketplace.

Files

Discovered from source

Test-Driven Development (TDD)

Red → Green → Refactor cycle for all code changes.

The TDD Cycle

  1. RED: Write failing test
  2. GREEN: Write minimal code to pass
  3. REFACTOR: Improve code quality

Repeat for each requirement

When to Apply TDD

✅ Always use TDD for:

  • New functions/methods
  • New features
  • Bug fixes (reproduce first)
  • Refactoring existing code
  • API changes

❌ Skip TDD for:

  • UI styling tweaks
  • Configuration changes
  • Documentation updates

Process

1. Write Failing Test First

# Start with test
test "calculates total with tax" do
  result = Calculator.calculate_total([100, 200])
  assert Money.equal?(result, Money.new(:USD, 324))
end

# Run test - should FAIL
mix test

2. Implement Minimal Code

# Just enough to pass
def calculate_total(prices) do
  prices |> Enum.sum() |> Kernel.*(1.08) |> Money.new(:USD)
end

3. Refactor

Extract constants, improve naming, etc.

Test Patterns by Stack

Backend (Elixir)

  • File: test/path/module_test.exs
  • Pattern: apps/api/test/your_app/task/task_test.exs

Frontend (TypeScript)

  • File: ComponentName.test.tsx
  • Pattern: mobile/libraries/atorasu/atoms/Button/Button.test.tsx

Critical Rules

  • Tests MUST fail first (verify test works)
  • One test per requirement
  • Test behavior, not implementation
  • Run FULL test suite before commit
  • NEVER skip failing tests

Common Pitfalls

  • Writing implementation before test
  • Tests that pass without implementation (false positive)
  • Testing implementation details instead of behavior
  • Not running test to verify it fails first

Verification

# Backend
mix test path/to/test.exs

# Frontend
yarn test path/to/test.tsx

Readme

TDD

Test-Driven Development (TDD) principles and red-green-refactor cycle enforcement.

Overview

This plugin provides comprehensive Test-Driven Development guidance and automatic enforcement through hooks. It ensures that Claude follows the TDD cycle when writing new code, fixing bugs, or adding features.

Features

  • TDD Skill: Complete guidance on the red-green-refactor cycle
  • Automatic Enforcement: Hooks that remind Claude to follow TDD on every user prompt
  • Best Practices: Detailed examples and patterns for different technology stacks

What is TDD?

Test-Driven Development is a software development approach where you:

  1. RED: Write a failing test first
  2. GREEN: Write minimal code to make it pass
  3. REFACTOR: Improve the code while keeping tests green

When to Use

Install this plugin when working on:

  • Projects that require high code quality
  • Teams practicing TDD
  • Codebases with comprehensive test coverage
  • Any project where you want to ensure tests are written before implementation

Hooks

This plugin includes hooks that:

  • Inject TDD reminders on every user prompt (UserPromptSubmit)
  • Remind subagents to follow TDD when they complete (SubagentStop)

Skills Included

  • test-driven-development: Complete TDD guidance with red-green-refactor cycle

Example Workflow

# User asks: "Add a function to calculate tax"

# 1. Claude writes failing test first
test "calculates tax on amount" do
  result = Calculator.calculate_tax(100)
  assert result == 8.0
end

# 2. Runs test - should FAIL
mix test

# 3. Implements minimal code
def calculate_tax(amount) do
  amount * 0.08
end

# 4. Runs test - should PASS
mix test

# 5. Refactors if needed
def calculate_tax(amount) do
  amount * @tax_rate
end

Installation

Install with npx (no installation required):

han plugin install tdd

Details

Marketplace
TheBushidoCollective/han
Source
plugins/patterns/tdd
Category
Pattern
Keywords
tdd, test-driven-development, testing, red-green-refactor, quality
Listed since
Apr 7, 2026

More from TheBushidoCollective/han

All 340

Similar to tdd

More Testing & QA