Write minimal code to make failing tests pass in the GREEN phase of TDD.
Writes minimal code to make failing tests pass during TDD's GREEN phase.
/plugin marketplace add DoubleslashSE/claude-marketplace/plugin install node-tdd@doubleslash-pluginsWrite minimal code to make failing tests pass in the GREEN phase of TDD.
/green [test-file-path]
test-file-path: (Optional) Path to the test file to implement againstUses the implementer agent with tdd-workflow and solid-principles skills.
Identify Failing Tests
Implement Incrementally
Progress Tracking
Achieve GREEN
Write ONLY what's needed to pass the current test:
// Test expects: add(2, 3) === 5
// Step 1: Fake it (if only one test case)
const add = (a: number, b: number): number => 5;
// Step 2: Generalize (when more tests force it)
const add = (a: number, b: number): number => a + b;
Run tests → Pick first failure → Implement → Run tests → Repeat
// Acceptable in GREEN phase:
const processOrder = (order: Order) => {
if (order.items.length === 0) return Result.fail('empty');
if (order.total < 0) return Result.fail('invalid');
// More inline logic is fine - refactor later
return Result.ok({ processed: true });
};
export const createValidator = () => ({
validate: (input: string) => {
// Minimal implementation
},
});
export const createService = (deps: Dependencies) => ({
execute: async () => {
// Use injected deps
},
});
export const parseInput = (raw: string): Result<Parsed, ParseError> => {
try {
return Result.ok(JSON.parse(raw));
} catch {
return Result.fail({ code: 'PARSE_ERROR' });
}
};
# Run all tests
npm test
# Run specific test file
npm test -- path/to/test.ts
# Watch mode
npm test -- --watch
# With Vitest
vitest run
vitest watch
Test Suite: user-service.test.ts
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✓ should create user with valid data
✓ should reject invalid email
✗ should hash password before storing
✗ should emit user.created event
Progress: 2/4 tests passing
Next: Implement password hashing
The command produces:
/green src/services/user-service.test.ts
/tdd - Complete TDD cycle/red - Design failing tests/refactor - Improve code design