Use when implementing features, writing code, executing implementation plans, practicing TDD, or making code changes based on a plan.
This skill provides guidance for executing implementation plans effectively during the SDLC implementation phase.
Implementation transforms plans into working code. The goal is to execute systematically, write tests alongside code, and ensure all changes integrate cleanly with the existing codebase.
Follow the strict RED-GREEN-REFACTOR cycle:
Critical TDD Rules:
Before marking a task complete:
src/foo.ts β src/foo.test.ts)Follow the testing pyramid with colocated unit tests:
src/
services/
auth.ts # Production code
auth.test.ts # Unit tests (colocated)
utils/
validation.ts # Production code
validation.test.ts # Unit tests (colocated)
tests/
integration/ # Integration tests only
auth-flow.test.ts # Cross-component tests
src/foo.ts tests in src/foo.test.tstests/integration/When tests fail during implementation, DO NOT give up or mark as blocked. Instead:
| Error Pattern | Likely Cause | Fix |
|---|---|---|
| "expected X to be Y" | Implementation logic error | Check the production code, not the test |
| "undefined is not a function" | Missing import or wrong signature | Verify imports and function signatures |
| Mock not called | Dependency injection not wired | Pass mocked deps through to inner functions |
| Timeout | Missing await or infinite loop | Check async code and loop conditions |
Critical: Never recreate production logic in tests. Export functions from production code and import them in tests.
// β BAD - Recreating logic in test
test('calculates total', () => {
// Recreating the formula from production code
const total = items.reduce((sum, item) => sum + item.price * item.qty, 0);
expect(result).toBe(total);
});
// β
GOOD - Import from production
import { calculateTotal } from './cart.js';
test('calculates total', () => {
const result = calculateTotal(items);
expect(result).toBe(150); // Known expected value
});
When testing time-dependent code, always use mocked dates:
import { vi, beforeEach, afterEach } from 'vitest';
beforeEach(() => {
vi.useFakeTimers();
vi.setSystemTime(new Date('2025-01-15T10:00:00Z'));
});
afterEach(() => {
vi.useRealTimers();
});
test('creates timestamp', () => {
const result = createRecord();
expect(result.createdAt).toBe('2025-01-15T10:00:00.000Z');
});
Documentation-only implementation - Writing plans/notes instead of actual code changes to src/. This is the most common failure mode.
Test-last development - Writing all implementation then all tests. Tests and code should be written together.
Ignoring test failures - Don't skip failing tests. Fix them or understand why they fail.
Over-engineering - Write the minimum code needed. Don't add features not in the plan.
Batch verification - Don't wait until the end to run tests. Run them after each task.
Skipping the plan - Don't improvise. Follow the implementation plan systematically.
Before marking implementation complete, verify:
.ts/.js files in src/ were modifiednpm test shows 0 failuresnpm run build completes without errors