Execute TDD workflow for user stories - spawn tester agent to write tests (RED), then coder agent to implement (GREEN). Use when executing stories in test-first discipline with parallel wave-based orchestration.
This skill inherits all available tools. When active, it can use any tool Claude has access to.
Purpose: Execute test-driven development (TDD) pattern for enriched user stories Trigger: Called by execution-phase or /build during story implementation Input: User stories with acceptance criteria, execution plan with waves Output: Tests written, implementation code, story files updated
Per story:
RED → Write tests (tester agent)
GREEN → Implement to pass tests (coder agent)
READY → Story completed with tests passing
For each story in the current wave:
a. RED Phase - Test Writing:
b. GREEN Phase - Implementation:
c. Production Verification:
After each phase, update story file with:
## Implementation Status
- Status: [🧪 Testing | 🔄 Implementing | ✅ Complete]
- Assignee: {agent-name}
- Test File: {path}
- Files Modified: {list}
- Tests Passing: {count}/{total}
for each story in current_wave:
// RED phase
tester_agent = spawn(tester, {story, AC})
test_file = await tester_agent.write_tests()
updateStoryFile(story, Status="🧪 Testing", TestFile=test_file)
// GREEN phase
impl_agent = spawn(coder, {story, test_file})
impl_files = await impl_agent.implement_to_pass_tests()
updateStoryFile(story, Status="🔄 Implementing", FilesModified=impl_files)
// Production check
run_tests(test_file) // Must all pass
updateStoryFile(story, Status="✅ Complete", Verified="yes")
return {
story_id: story.id,
test_file: test_file,
impl_files: impl_files,
tests_passed: all_tests_passed,
status: "complete"
}
Tester Agent Spawn (RED Phase):
CONSTITUTION: 1) Change only what must change 2) Fix root cause 3) Read first
4) Verify before done 5) Do exactly what asked
ROLE: Tester Agent (TDD RED Phase)
TASK: Write tests from acceptance criteria
STORY: {story_id}
AC (Acceptance Criteria):
{acceptance_criteria_list}
DELIVERABLE: Test file at {test_file_path}
- Mock passing scenarios
- Mock failing scenarios
- Cover all AC points
- No implementation code yet (RED phase)
VERIFY: Test file compiles and runs (no tests passing yet)
Model: sonnet (balanced reasoning)
Coder Agent Spawn (GREEN Phase):
CONSTITUTION: 1) Change only what must change 2) Fix root cause 3) Read first
4) Verify before done 5) Do exactly what asked
ROLE: Coder Agent (TDD GREEN Phase)
TASK: Implement to pass all tests
STORY: {story_id}
AC (Acceptance Criteria):
{acceptance_criteria_list}
TESTS: Must pass {test_file_path}
- Run tests continuously
- All tests MUST pass
- Implement minimal code to pass
- No over-engineering
DELIVERABLE: Implementation code at {impl_file_paths}
- Code implements AC
- All tests passing
- List files modified
VERIFY: Run test file - confirm 100% passing
Model: sonnet (balanced cost)
| Constraint | Value | Rationale |
|---|---|---|
| Max concurrent | 10 | Prevent resource exhaustion |
| Wave batching | Yes | Control complexity |
| Tester→Coder | Seq | RED before GREEN (TDD pattern) |
| Story→Story | Par | Parallelism within wave |
{
"story_id": "US-001",
"wave": 1,
"tester_agent": "tester",
"test_file": "src/__tests__/feature.test.ts",
"tests_passed": true,
"test_count": 8,
"coder_agent": "coder",
"impl_status": "success",
"files_modified": ["src/feature.ts", "src/feature.spec.ts"],
"ac_complete": true,
"verified": true
}
Wave 1: Story US-001 (Authentication)
1. Tester writes auth.test.ts (RED)
- Mock User model
- Mock login scenarios
- Test passing & failing cases
2. Coder implements AuthService (GREEN)
- Read auth.test.ts
- Implement login/logout
- All 12 tests pass
3. Production check: tests still passing ✓
Wave 2: US-002 + US-003 (Parallel)
Stories US-002 (Database) and US-003 (API) run in parallel:
US-002:
1. Tester writes db.test.ts (RED)
2. Coder implements Repository (GREEN)
US-003:
1. Tester writes api.test.ts (RED)
2. Coder implements Routes (GREEN)
Both stories complete before Wave 3 starts
Story files (US-001.md) track progress:
# US-001: Add Authentication
## Acceptance Criteria
- [ ] User can login with email + password
- [ ] User can logout
- [ ] Invalid credentials rejected
## Implementation Status
- Status: ✅ Complete
- Assignee: coder-agent
- Test File: src/**tests**/auth.test.ts
- Tests Passing: 12/12
- Files Modified: src/auth.ts, src/services/AuthService.ts
- Verified: yes
## Completion
- Tester: auth.test.ts written (8 tests)
- Coder: AuthService + login routes (4 files)
- Coverage: 95% (lines)
Called by: execution-phase, /build command Calls: Tester agent (core-claude-plugin:generic:tester), Coder agent (core-claude-plugin:generic:coder) Next: Story file updates for validation-phase