Skip to content
Skillpedia
Testing48k Β· #5933

tdd-workflow

What it does

This skill helps you write code in an organized and reliable way. It guides you through a cycle where you first write a failing test, then the minimal code to make it pass, and finally improve the code's quality.

When to use it

  • βœ“When starting a new feature.
  • βœ“When fixing a bug.
  • βœ“When working with complex logic.

Skill link

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/tdd-workflow/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/tdd-workflow/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œHelp me apply the TDD cycle to create a function that adds two numbers.”

5 new skills a week. 1 minute to read.

How it works

The AI follows a cycle: first, you describe what the code should do and the AI writes a failing test. Then, the AI writes the simplest code to make the test pass. Finally, the AI reviews and improves the code without breaking the tests.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

TDD Workflow

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

  1. Write production code only to make a failing test pass
  2. Write only enough test to demonstrate failure
  3. 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.

When to Use

This skill is applicable to execute the workflow or actions described in the overview.

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
FAQ

What do 'RED', 'GREEN', 'REFACTOR' mean?

'RED' is when the test fails. 'GREEN' is when the code makes the test pass. 'REFACTOR' is when you improve the code while keeping everything working.

Why write the test before the code?

Writing the test first ensures you know exactly what the code needs to do and helps avoid unnecessary code.

What is 'YAGNI'?

YAGNI stands for 'You Aren't Gonna Need It'. It's a principle to write only the code that is strictly necessary at the moment.

Details

Original description by the author

Test-Driven Development workflow principles. RED-GREEN-REFACTOR cycle.

repo: sickn33/agentic-awesome-skills

Popularity

GitHub stars
48k
Ranking position
#5933
License
MIT
Updated
10/15/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills