plugins/vibeworks-library/skills/tdd-workflow/SKILL.md
Test-driven development methodology — red-green-refactor cycle, writing failing tests first, minimal implementation, and iterative refinement. Use when implementing features test-first, when the user asks for TDD, or when writing tests before code.
npx skillsauth add claude-code-community-ireland/claude-code-resources tdd-workflowInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
TDD is a design discipline, not just a testing technique. Writing tests first forces you to think about the interface before the implementation, producing code that is inherently testable, loosely coupled, and driven by actual requirements.
Checklist before moving to GREEN:
it should return 404 when resource not found).The "simplest thing that could work" principle:
return 42, write return 42. Do not write a general formula yet.if statement. Do not write a loop yet.Checklist before moving to REFACTOR:
Refactoring targets:
Return to Step 1 with the next smallest behavior.
Use descriptive names that serve as documentation:
// Pattern: [unit]_[scenario]_[expected result]
test_calculateTotal_withEmptyCart_returnsZero
test_calculateTotal_withSingleItem_returnsItemPrice
test_calculateTotal_withDiscount_appliesDiscountToSubtotal
// BDD-style
describe("calculateTotal") {
it("should return zero for an empty cart")
it("should return the item price for a single item")
it("should apply discount to subtotal")
}
// Given-When-Then
given_emptyCart_when_calculateTotal_then_returnsZero
Rules:
describe or test class.RED: Write a test for a single function or method.
GREEN: Implement just that function.
REFACTOR: Clean up the function and its test.
Cycle time: 1-5 minutes.
RED: Write a test that exercises two or more components together.
GREEN: Wire the components and implement any missing glue code.
REFACTOR: Extract shared setup, clean interfaces between components.
Cycle time: 5-15 minutes.
RED: Write a test that sends an HTTP request and asserts on status + body.
GREEN: Implement the route handler with minimal logic.
REFACTOR: Extract validation, business logic, and serialization into separate layers.
Cycle time: 5-20 minutes.
# RED: First test — empty slug
def test_shorten_rejects_empty_url():
with pytest.raises(ValueError):
shorten("")
# GREEN: Minimal implementation
def shorten(url):
if not url:
raise ValueError("URL cannot be empty")
pass # nothing else needed yet
# RED: Second test — returns a short code
def test_shorten_returns_six_char_code():
result = shorten("https://example.com")
assert len(result) == 6
# GREEN: Hardcode, then generalize
def shorten(url):
if not url:
raise ValueError("URL cannot be empty")
return url[:6] # naive but passing
# RED: Third test — codes are unique
def test_shorten_returns_unique_codes():
a = shorten("https://example.com/a")
b = shorten("https://example.com/b")
assert a != b
# GREEN: Now we need real logic
import hashlib
def shorten(url):
if not url:
raise ValueError("URL cannot be empty")
return hashlib.md5(url.encode()).hexdigest()[:6]
# REFACTOR: Extract hashing, add type hints, rename for clarity
When adding features to code without tests:
The Mikado Method for legacy TDD:
Is the behavior well-understood?
YES -> Classic TDD (test-first)
NO -> Spike first (throwaway prototype), then TDD the real implementation
Is the code interacting with external systems?
YES -> Write a contract/interface test, then use a fake/stub for unit TDD
NO -> Pure function TDD (easiest case)
Is the code algorithmically complex?
YES -> Start with simple examples, build up with property-based tests
NO -> Standard example-based TDD
Are you fixing a bug?
YES -> Write a test that reproduces the bug FIRST, then fix it
NO -> Normal TDD cycle
tools
Automate changelog generation from commits, PRs, and releases following Keep a Changelog format. Use when setting up release workflows, generating release notes, or standardizing commit conventions.
documentation
Project Guidelines Skill (Example)
development
Development skill from everything-claude-code
documentation
Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.