USE WHEN: Explicitly requested tests-first behavior. Implements features using red-green-refactor cycle with test-first discipline. DON'T USE WHEN: Tests-first not explicitly requested (use pwf-work or pwf-work-plan instead). This skill requires explicit opt-in. REQUIRED INPUT: Feature description with clear expected behavior. OUTPUT: Implementation with test coverage, following TDD cycle. PROCESS: 1. Write failing test (red) 2. Implement minimal code to pass (green) 3. Refactor while keeping tests passing 4. Repeat until feature complete CYCLE: Red → Green → Refactor
Use this skill when explicitly requested to use tests-first behavior.
Opt-in only — requires explicit user request for TDD.
TDD cycles align well with Paperclip heartbeat model:
Rules:
Rules:
Rules:
Continue cycle until feature complete:
Execute red-green-refactor cycles until feature complete.
npm run validate # TypeScript + lint
npm test # All tests
Apply docs-maintenance-after-work skill:
If >5 files touched or complex logic:
pwf-review// Service test pattern
describe('FeatureService', () => {
let service: FeatureService;
let repository: MockType<Repository<Feature>>;
beforeEach(async () => {
const module = await Test.createTestingModule({
providers: [
FeatureService,
{ provide: getRepositoryToken(Feature), useFactory: repositoryMockFactory }
]
}).compile();
service = module.get(FeatureService);
repository = module.get(getRepositoryToken(Feature));
});
it('should [expected behavior]', () => {
// Arrange
const input = ...;
const expected = ...;
// Act
const result = service.method(input);
// Assert
expect(result).toEqual(expected);
});
});
// Component test pattern
describe('FeatureComponent', () => {
let component: FeatureComponent;
let fixture: ComponentFixture<FeatureComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [FeatureComponent],
providers: [{ provide: FeatureService, useValue: mockService }]
});
fixture = TestBed.createComponent(FeatureComponent);
component = fixture.componentInstance;
});
it('should [expected behavior]', () => {
// Test implementation
});
});
Stop TDD cycle and reassess if:
Options:
pwf-work for exploratory implementationpwf-brainstorm to clarify approachProvide:
pwf-review — after TDD completionpwf-commit-changes — structured commitspwf-doc-capture — document patterns discovered