From add
Writes minimal production-quality code to make failing tests pass (TDD GREEN phase). Reads feature specs, test mappings, and config to implement only what's needed.
How this skill is triggered — by the user, by Claude, or both
Slash command
/add:implementer specs/{feature}.md [--ac AC-001,AC-002]specs/{feature}.md [--ac AC-001,AC-002]This skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Write minimal production-quality code to make failing tests pass. This is the GREEN phase of TDD.
Write minimal production-quality code to make failing tests pass. This is the GREEN phase of TDD.
The Implementer takes failing tests (from test-writer) and writes the smallest amount of code necessary to make them all pass. The goal is:
npm test or python -m pytest1b. Read the impact hint (v0.9.0 — AC-022)
The tdd-cycle orchestrator emits a files-likely-affected block via
core/lib/impact-hint.sh. Consume it as part of this skill's context:
## Files likely to need changes
- app/auth.py
- app/session.py
## Files to be careful around (recent anti-pattern learnings exist)
- app/session.py [L-042]
Use the first list as the starting set for Step 2 (Design Implementation)
Treat the second list as warnings: those paths have recent anti-pattern learnings — read the learning (by ID) before editing
If the hint reports "No source files implied by RED diff" (AC-024), fall back to the spec's acceptance criteria for implementation targets
Read the feature spec
Load test mapping
Determine implementation structure
Read .add/config.json
Check for session handoff — per the Session-Handoff Preflight in ${CLAUDE_PLUGIN_ROOT}/references/skill-epilogue.md
For each failing test:
Example analysis:
// Test:
it('should return sum of two numbers', () => {
expect(add(2, 3)).toBe(5);
});
// Requires:
// - Function named 'add'
// - Takes two number parameters
// - Returns number (sum)
Create a plan without writing code:
Start with simplest, most-dependent-upon functions first:
For JavaScript/TypeScript:
// src/feature.ts - minimal implementation
export function add(a: number, b: number): number {
return a + b;
}
export class Feature {
constructor(private config: FeatureConfig) {}
doSomething(input: string): string {
return input.toUpperCase();
}
}
For Python:
# src/feature.py - minimal implementation
def add(a: int, b: int) -> int:
return a + b
class Feature:
def __init__(self, config):
self.config = config
def do_something(self, input_str: str) -> str:
return input_str.upper()
After implementing each logical unit:
npm test or python -m pytestAs tests progress to GREEN:
If a failing test seems wrong, it is NOT your decision to delete it. Stop, surface the
discrepancy to the human, and (if confirmed) rerun the cycle with --allow-test-rewrite.
Silent deletion fails Gate 3.5 and halts the cycle. The directive is:
"Test deletion during a TDD cycle is forbidden. Fix the implementation, not the test."
Run full test suite:
npm test
# or
python -m pytest
Verify:
Example output:
PASS tests/feature.test.ts
Feature Name
AC-001: requirement
✓ test_AC_001_behavior_a (15ms)
✓ test_AC_001_behavior_b (12ms)
AC-002: requirement
✓ test_AC_002_behavior_c (8ms)
Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Coverage: 85%
Before returning control to the tdd-cycle orchestrator, capture the test surface snapshot for Gate 3.5:
python3 ${CLAUDE_PLUGIN_ROOT}/../../scripts/check-test-count.py snapshot \
--phase green \
--cycle-id {N} \
--spec-slug {slug} \
--base-sha {cycle-base-sha}
The snapshot lives at .add/cycles/cycle-{N}/tdd-{slug}-green.json and is compared
against the RED snapshot by /add:verify Gate 3.5. If tests_removed > 0 without an
override, the cycle fails with a structured error naming each removed test.
Implementation code must:
After implementation reaches GREEN:
npm test -- --shuffleUpon successful GREEN phase completion, output:
# Implementation Complete (GREEN Phase) ✓
## Feature
{feature-name} v{spec-version}
## Test Results
- Tests Passing: {count}/{total}
- Tests Failing: 0/{total}
- Test Duration: {seconds}s
## Acceptance Criteria Implementation
- AC-001: ✓ Implemented and passing
- AC-002: ✓ Implemented and passing
... (all ACs listed)
## Code Coverage
- Line Coverage: {percentage}%
- Branch Coverage: {percentage}%
- Function Coverage: {percentage}%
## Implementation Files Created/Modified
- {file-path}: {N} functions, {N} classes
- {file-path}: {N} functions
## Next Steps
1. Run /add:reviewer to check code quality
2. Run /add:tdd-cycle REFACTOR phase to improve code
3. Merge implementation
## Notes
- All tests green as of {timestamp}
- Ready for code review and refactoring
- No over-engineering; minimal viable implementation
Tasks to create (mechanics per ${CLAUDE_PLUGIN_ROOT}/references/skill-epilogue.md):
| Phase | Subject | activeForm |
|---|---|---|
| Read tests | Reading failing tests | Reading failing tests... |
| Analyze | Analyzing requirements | Analyzing requirements... |
| Implement | Writing implementation code | Writing implementation code... |
| Verify GREEN | Confirming all tests pass | Verifying tests pass (GREEN confirmed)... |
Tests still failing after implementation
Type errors or compilation failures
Tests pass but coverage is low
Existing implementation conflicts with tests
Performance issues
The implementer respects:
End-of-skill epilogue: follow ${CLAUDE_PLUGIN_ROOT}/references/skill-epilogue.md (observation + learning checkpoint + progress tracking).
npx claudepluginhub mountainunicorn/add --plugin addExecutes TDD DEV stage: verifies failing tests exist, reads tests and design, implements minimal code one test at a time until all pass, verifies build, commits.
[DEPRECATED] Guides Claude Code through the green phase of TDD: writing minimal code to make failing tests pass. Replaced by sw:tdd-cycle --phase green.
Enforces RED-GREEN-REFACTOR TDD cycle: write a failing test first, then minimal code to pass, then refactor. Use when implementing features or fixing bugs during the implement phase.