TDD Workflow
SkillAI & modelsThe tdd-workflow skill is a set of test-driven development principles that guides an AI agent through the RED-GREEN-REFACTOR cycle. It makes the agent write a failing test first, then the minimum code to pass it, then clean up while keeping tests green. It also covers the three laws of TDD, the AAA test pattern, when TDD is worth using, and common anti-patterns to avoid.
Use TDD Workflow in Claude, ChatGPT or Ahel Desktop
Free. Sign in, add TDD Workflow and connect your AI. About a minute.
Also: Claude Code · Cursor · Codex
Then ask your AI: use the TDD Workflow skill
Details
Instructions available. Your AI can read the instructions. Execution depends on the setup they require.
Account requirements not reviewed. Check the skill instructions before use; ahel provides instructions and does not run this skill.
No other account needed.
Add the tdd-workflow skill to your agent so it can read the skill file.
What your AI can do with it
- Write a failing test before any production code (RED)
- Write the minimum code needed to pass the test (GREEN)
- Refactor code while keeping all tests green (REFACTOR)
- Apply the three laws of TDD to each change
- Structure tests with the Arrange, Act, Assert pattern
- Avoid anti-patterns such as skipping RED or testing implementation
Getting started
- Add the tdd-workflow skill to your agent so it can read the skill file.
- Confirm the agent has access to the tools the skill allows: Read, Write, Edit, Glob, Grep, and Bash.
- Ask the agent to implement a small feature or bug fix and state that it should follow TDD.
- Check that the agent writes a failing test first, then code to pass it, then refactors with tests still green.
What this skill tells your AI
The instructions your AI receives, as published by davila7/claude-code-templates in cli-tool/components/skills/development/tdd-workflow/SKILL.md and read by ahel’s review.
Write tests first, code second.
1. The TDD Cycle
🔴 RED → Write failing test
↓
🟢 GREEN → Write minimal code to pass
↓
🔵 REFACTOR → Improve code quality
↓
Repeat...
2. The Three Laws of TDD
- Write production code only to make a failing test pass
- Write only enough test to demonstrate failure
- Write only enough code to make the test pass
3. RED Phase Principles
What to Write
| Focus | Example |
|---|---|
| Behavior | "should add two numbers" |
| Edge cases | "should handle empty input" |
| Error states | "should throw for invalid data" |
RED Phase Rules
- Test must fail first
- Test name describes expected behavior
- One assertion per test (ideally)
4. GREEN Phase Principles
Minimum Code
| Principle | Meaning |
|---|---|
| YAGNI | You Aren't Gonna Need It |
| Simplest thing | Write the minimum to pass |
| No optimization | Just make it work |
GREEN Phase Rules
- Don't write unneeded code
- Don't optimize yet
- Pass the test, nothing more
5. REFACTOR Phase Principles
What to Improve
| Area | Action |
|---|---|
| Duplication | Extract common code |
| Naming | Make intent clear |
| Structure | Improve organization |
| Complexity | Simplify logic |
REFACTOR Rules
- All tests must stay green
- Small incremental changes
- Commit after each refactor
6. AAA Pattern
Every test follows:
| Step | Purpose |
|---|---|
| Arrange | Set up test data |
| Act | Execute code under test |
| Assert | Verify expected outcome |
7. When to Use TDD
| Scenario | TDD Value |
|---|---|
| New feature | High |
| Bug fix | High (write test first) |
| Complex logic | High |
| Exploratory | Low (spike, then TDD) |
| UI layout | Low |
8. Test Prioritization
| Priority | Test Type |
|---|---|
| 1 | Happy path |
| 2 | Error cases |
| 3 | Edge cases |
| 4 | Performance |
9. Anti-Patterns
| ❌ Don't | ✅ Do |
|---|---|
| Skip the RED phase | Watch test fail first |
| Write tests after | Write tests before |
| Over-engineer initial | Keep it simple |
| Multiple asserts | One behavior per test |
| Test implementation | Test behavior |
10. AI-Augmented TDD
Multi-Agent Pattern
| Agent | Role |
|---|---|
| Agent A | Write failing tests (RED) |
| Agent B | Implement to pass (GREEN) |
| Agent C | Optimize (REFACTOR) |
Remember: The test is the specification. If you can't write a test, you don't understand the requirement.
Signals
- GitHub stars
- 32k
- Forks
- 4k
- Last commit
- Oct 2026
Others that do the same job
Questions
- What is the RED-GREEN-REFACTOR cycle?
- RED means write a failing test. GREEN means write the minimum code to pass it. REFACTOR means improve the code while all tests stay green. The cycle repeats for each change.
- What are the three laws of TDD?
- Write production code only to make a failing test pass. Write only enough test to demonstrate failure. Write only enough code to make the test pass.
- When is TDD worth using?
- TDD has high value for new features, bug fixes, and complex logic. It has low value for exploratory work and UI layout, where a spike followed by TDD works better.
Advanced
- Item type
- skill
- Key
tdd-workflow-davila7- Source
- github.com/davila7/claude-code-templates
github.com/davila7/claude-code-templates
Related picks
Skill · addyosmani
Does the same job in other wordsskill-creator
Skill · anthropics
More in AI & modelswayfinder
Skill · mattpocock
More in AI & modelswizard
Skill · mattpocock
More in AI & modelsalgorithmic-art
Skill · anthropics
More in AI & modelscode-review-and-quality
Skill · addyosmani
More in AI & models