Skip to content
Skill

TDD Skill — Red-Green-Refactor

by mfranzon

AI Summary

You are guiding the developer through strict Test-Driven Development. You write code directly to the real files — the user can always undo with git. Pause only when the user's input is needed, not at every step. 1. Determine the input type: 2. Detect the language and test framework from the project.

Install

Copy this and paste it into Claude Code, Cursor, or any AI assistant:

I want to install the "TDD Skill — Red-Green-Refactor" skill in my project.

Please run this command in my terminal:
# Install skill into your project
mkdir -p .claude/skills/tdd && curl --retry 3 --retry-delay 2 --retry-all-errors -o .claude/skills/tdd/SKILL.md "https://raw.githubusercontent.com/mfranzon/tdd/main/SKILL.md"

Then restart Claude Code (or reload the window in Cursor) so the skill is picked up.

Description

tdd skill for coding agents

TDD Skill — Red-Green-Refactor

You are guiding the developer through strict Test-Driven Development. You write code directly to the real files — the user can always undo with git. Pause only when the user's input is needed, not at every step.

Phase 1: Setup

• Determine the input type: • If the input is a file path (ends in .md, .txt, or exists on disk): read the plan file. • If the input is an inline description (e.g., "add JWT authentication with refresh tokens"): use it directly as the feature specification. Ask clarifying questions with AskUserQuestion only if the description is too vague to decompose into increments (e.g., "build an app"). A single sentence like "add user login with email and password" is enough to start. • Detect the language and test framework from the project. If ambiguous, ask: • Python → pytest • TypeScript → vitest • Go → testing (stdlib) See references/language-configs.md for runner commands and conventions. • Break the feature into small, testable increments. See references/increments.md for decomposition patterns. • Create a task list using TaskCreate — one task per increment. • Present the increment list to the user with AskUserQuestion: • "Here are the increments I've identified. Want to reorder, add, remove, or modify any before we start?" • Options: "Looks good, let's start" / "I want to modify the list"

Phase 2: TDD Loop

For each increment, follow Red-Green-Refactor strictly. Mark the current increment as in_progress via TaskUpdate.

RED — Write a Failing Test

• Write the failing test directly to the real test file (e.g., tests/test_feature.py, following existing project conventions). Show the test in a fenced code block and briefly explain what behavior it verifies. • Run the test using the appropriate runner (see language-configs.md). Use Bash. • Confirm the test fails. If it passes unexpectedly, stop and flag this: • "The test passed already — this means either the behavior is already implemented or the test isn't asserting the right thing. Let's investigate before moving on." • Pause with AskUserQuestion: • "RED: test fails as expected. Review the test above — ready to move to GREEN?" • Options: "Looks good, write the code" / "I want to change the test first"

Discussion

0/2000
Loading comments...

Health Signals

MaintenanceCommitted 1mo ago
Active
Adoption100+ stars on GitHub
136 ★ · Growing
DocsMissing or thin
Undocumented

GitHub Signals

Stars136
Forks5
Issues0
Updated1mo ago
View on GitHub
No License

My Fox Den

Community Rating

Sign in to rate this booster

Works With

Claude Code