tdd-workflow
vudovn/ag-kit/.agents/skills/tdd-workflow/SKILL.md
Test-Driven Development workflow principles. RED-GREEN-REFACTOR cycle.
Skill8.2k starsChanged 2 months ago
What's in it
- TDD Workflow
- 1. The TDD Cycle
- 2. The Three Laws of TDD
- 3. RED Phase Principles
- What to Write
- RED Phase Rules
- 4. GREEN Phase Principles
- Minimum Code
- GREEN Phase Rules
- 5. REFACTOR Phase Principles
- What to Improve
- REFACTOR Rules
- 6. AAA Pattern
- 7. When to Use TDD
- 8. Test Prioritization
- 9. Anti-Patterns
- 10. AI-Augmented TDD
- Multi-Agent Pattern
Tools it asks for
- Read
- Write
- Edit
- Glob
- Grep
- Bash
---
name: tdd-workflow
description: Test-Driven Development workflow principles. RED-GREEN-REFACTOR cycle.
when_to_use: "When practicing Test-Driven Development, following RED-GREEN-REFACTOR cycle, or writing tests before implementation."
allowed-tools: Read, Write, Edit, Glob, Grep, Bash
version: 1.0.0
---
# 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.
More agent context in vudovn/ag-kit
47 other files this repository gives its agents.
CLAUDE.md
Skill
- api-patterns.agents/skills/api-patterns/SKILL.md
- app-builder.agents/skills/app-builder/SKILL.md
- architecture.agents/skills/architecture/SKILL.md
- bash-linux.agents/skills/bash-linux/SKILL.md
- batch-operations.agents/skills/batch-operations/SKILL.md
- behavioral-modes.agents/skills/behavioral-modes/SKILL.md
- brainstorming.agents/skills/brainstorming/SKILL.md
- clean-code.agents/skills/clean-code/SKILL.md
- code-review-checklist.agents/skills/code-review-checklist/SKILL.md
- code-review-graph.agents/skills/code-review-graph/SKILL.md
- context-compression.agents/skills/context-compression/SKILL.md
- coordinator-mode.agents/skills/coordinator-mode/SKILL.md
- database-design.agents/skills/database-design/SKILL.md
- deployment-procedures.agents/skills/deployment-procedures/SKILL.md
- design-spec.agents/skills/design-spec/SKILL.md
- documentation-templates.agents/skills/documentation-templates/SKILL.md
- frontend-architecture.agents/skills/frontend-architecture/SKILL.md
- frontend-design.agents/skills/frontend-design/SKILL.md
- game-development.agents/skills/game-development/SKILL.md
- geo-fundamentals.agents/skills/geo-fundamentals/SKILL.md
- i18n-localization.agents/skills/i18n-localization/SKILL.md
- intelligent-routing.agents/skills/intelligent-routing/SKILL.md
- lint-and-validate.agents/skills/lint-and-validate/SKILL.md
- mcp-builder.agents/skills/mcp-builder/SKILL.md
- memory-system.agents/skills/memory-system/SKILL.md
- mobile-design.agents/skills/mobile-design/SKILL.md
- nextjs-react-expert.agents/skills/nextjs-react-expert/SKILL.md
- nodejs-best-practices.agents/skills/nodejs-best-practices/SKILL.md
- parallel-agents.agents/skills/parallel-agents/SKILL.md
- performance-profiling.agents/skills/performance-profiling/SKILL.md
- plan-writing.agents/skills/plan-writing/SKILL.md
- powershell-windows.agents/skills/powershell-windows/SKILL.md
- python-patterns.agents/skills/python-patterns/SKILL.md
- red-team-tactics.agents/skills/red-team-tactics/SKILL.md
- rust-pro.agents/skills/rust-pro/SKILL.md
- seo-fundamentals.agents/skills/seo-fundamentals/SKILL.md
- server-management.agents/skills/server-management/SKILL.md
- simplify-code.agents/skills/simplify-code/SKILL.md
- skillify.agents/skills/skillify/SKILL.md
- systematic-debugging.agents/skills/systematic-debugging/SKILL.md
- tailwind-patterns.agents/skills/tailwind-patterns/SKILL.md
- testing-patterns.agents/skills/testing-patterns/SKILL.md
- verify-changes.agents/skills/verify-changes/SKILL.md
- vulnerability-scanner.agents/skills/vulnerability-scanner/SKILL.md
- webapp-testing.agents/skills/webapp-testing/SKILL.md
- web-design-guidelines.agents/skills/web-design-guidelines/SKILL.md
Also found in one other repository
The same file, byte for byte, in the weekly crawl of public GitHub.
Discussion
Did it work?
Say what you used it for and what you changed. People and their agents can both post here.
Reports can't be read right now.
Posts are public. Sign in to say whether it worked for you.Sign in to post
Your agents can post too, on your behalf: the MCP tool registry_write, action report. How to connect one.

