tdd-workflow
Test-Driven Development workflow principles. RED-GREEN-REFACTOR cycle.
Author
Category
Development ToolsInstall
Hot:0
Download and extract to your skills directory
Copy command and send to OpenClaw for auto-install:
Download and install this skill https://openskills.cc/api/download?slug=sickn33-skills-tdd-workflow&locale=en&source=copy
TDD Workflow - Test-Driven Development Smart Assistant
Skill Overview
TDD Workflow is a Claude skill that follows the principles of test-driven development. Guided by the RED-GREEN-REFACTOR loop, it helps you write tests first and then implement code, enabling you to build more reliable, maintainable software.
Suitable Scenarios
1. New Feature Development
Using TDD when developing new features ensures code has test coverage from the very beginning. The skill will guide you to first write a failing test (RED), then implement the minimum amount of code to make the test pass (GREEN), and finally optimize the code structure (REFACTOR). This approach effectively reduces bugs later and improves code quality.
2. Bug Fixes and Regression Testing
When fixing bugs, TDD Workflow recommends writing test cases that reproduce the issue first, ensuring the test fails before making fixes. This not only verifies that the bug has been resolved, but also helps prevent similar issues from happening again. The skill prioritizes test coverage for the Happy Path, error scenarios, and edge cases.
3. Implementing Complex Business Logic
For complex business rules and algorithms, TDD helps clarify requirement boundaries. By writing tests using the AAA pattern (Arrange-Act-Assert), you can clearly define inputs, outputs, and edge conditions before you start coding. The skill also supports a multi-agent collaboration mode, allowing different agents to handle writing tests, implementing functionality, and optimizing code.
Core Features
1. RED-GREEN-REFACTOR Loop Guidance
Strictly follows the three TDD laws: write production code only to make failing tests pass; write only enough code to demonstrate the failing test; write only enough code to make the tests pass. Provides targeted guidance at each stage to ensure no steps are skipped and to avoid over-engineering.
2. AAA Test Pattern Support
Guides each test case to follow the standard structure of Arrange (prepare test data), Act (execute the code under test), and Assert (verify results). Supports behavior-descriptive test naming, such as “should add two numbers,” so the tests themselves become documentation.
3. Test Prioritization and Coverage Strategy
Helps build a complete testing pyramid with the priority order: Happy Path → error scenarios → edge cases → performance tests. Clearly indicates the scenarios where TDD delivers the most value (new features, bug fixes, complex logic) and where it delivers less value (exploratory development, UI layout work).
Common Questions
What is the TDD RED-GREEN-REFACTOR loop?
RED-GREEN-REFACTOR is the core loop of test-driven development. In the RED phase, you first write a failing test to ensure the test can indeed detect the problem. In the GREEN phase, you write the simplest code to make the test pass, without any optimization. In the REFACTOR phase, you optimize the code structure while keeping the tests passing—removing duplication and improving naming. This loop repeats continuously to gradually build functionality.
What scenarios is test-driven development best for?
TDD has the highest value in these scenarios: new feature development, ensuring code has test coverage from the start; bug fixing, writing tests first to prevent regressions; and complex business logic implementation, using tests to clarify requirement boundaries. In contrast, exploratory programming, quick prototype validation, or pure UI layout adjustments typically yield lower benefits from TDD—you can do a Spike first and then add tests.
How do I start practicing the TDD workflow?
The key to starting TDD is not skipping the RED phase—you must see the test fail. Begin with a simple Happy Path test, and organize your test code using the AAA pattern: prepare data, execute functionality, and assert results. Remember the YAGNI principle: in the GREEN phase, write only the code needed for the test to pass—don’t optimize in advance. This skill supports an AI-assisted multi-agent mode, which can separately handle the three stages: writing tests, implementing functionality, and optimizing code.