From ccpp
Guides TDD process: write failing tests first (RED), minimal passing code (GREEN), refactor. Supports Vitest/Jest for JS/TS, pytest for Python. Use for test-first development.
How this skill is triggered — by the user, by Claude, or both
Slash command
/ccpp:tddThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
테스트를 먼저 작성하고, 코드를 구현하는 TDD 방식을 적용합니다.
테스트를 먼저 작성하고, 코드를 구현하는 TDD 방식을 적용합니다.
RED → GREEN → REFACTOR → REPEAT
RED: 실패하는 테스트 작성
GREEN: 테스트 통과하는 최소 코드 작성
REFACTOR: 코드 개선 (테스트 유지)
REPEAT: 다음 기능/시나리오
// 타입 먼저 정의
interface CreateUserInput {
name: string;
email: string;
}
// 빈 구현체
export function createUser(input: CreateUserInput): User {
throw new Error('Not implemented');
}
테스트 순서: 정상 → 엣지 → 에러
describe('createUser', () => {
// 정상 케이스 먼저
it('유효한 입력으로 사용자를 생성해야 한다', () => {
const input = { name: '홍길동', email: '[email protected]' };
const result = createUser(input);
expect(result).toMatchObject({ name: '홍길동', email: '[email protected]' });
expect(result.id).toBeDefined();
});
// 엣지 케이스
it('이름 앞뒤 공백을 제거해야 한다', () => {
const result = createUser({ name: ' 홍길동 ', email: '[email protected]' });
expect(result.name).toBe('홍길동');
});
// 에러 케이스
it('이메일이 없으면 ValidationError를 던져야 한다', () => {
expect(() => createUser({ name: '홍길동', email: '' })).toThrow(ValidationError);
});
});
# 반드시 실패하는지 확인 — 바로 통과하면 테스트가 잘못된 것
npm test -- path/to/file.test.ts
# 또는
pytest path/to/test_file.py -v
실패 안 하면 STOP — 테스트를 다시 검토.
다음 테스트 케이스 추가 → RED부터 다시.
| 프레임워크 | 실행 | 워치 | 커버리지 |
|---|---|---|---|
| Vitest | npx vitest run | npx vitest | npx vitest --coverage |
| Jest | npx jest | npx jest --watch | npx jest --coverage |
| pytest | pytest -v | ptw | pytest --cov=src |
| 패턴 | 위치 |
|---|---|
| 코로케이션 | src/user.ts → src/user.test.ts |
| tests | src/user.ts → src/__tests__/user.test.ts |
| Python | src/user.py → tests/test_user.py |
기존 프로젝트 패턴을 따름.
npx claudepluginhub jh941213/my-cc-harness --plugin ccppGuides strict Test-Driven Development (Red-Green-Refactor): write failing tests for normal/edge/error cases, minimal code to pass, refactor with checklists. Includes TypeScript example.
Enforces strict TDD red-green-refactor cycle: write failing test first, minimal implementation to pass, then refactor. Use before coding for test-driven safe development.