원클릭으로
test-driven-development
Use when implementing features/fixes. Iron law: ¬∃ production code without failing test.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Use when implementing features/fixes. Iron law: ¬∃ production code without failing test.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | test-driven-development |
| description | Use when implementing features/fixes. Iron law: ¬∃ production code without failing test. |
| version | 1.0.0 |
| tags | ["testing","process"] |
∀ features/fixes where TDD applies. Simple tasks may skip TDD.
¬∃ production_code without failing_test_first. If code ∃ before test -> DELETE IT ∧ start over. Sunk cost irrelevant — time gone regardless.
RED(write 1 test -> run -> observe FAIL) -> GREEN(minimal code to pass) -> REFACTOR(structure, tests stay green)
it("should validate email format", () => {
const result = validateEmail("not-an-email");
expect(isErr(result)).toBe(true);
});
Rules: 1 behavior/test | descriptive name | describe/it/expect (¬test()) | MUST run ∧ watch FAIL
∀ test: fails for right reason (missing feature ¬syntax error). GREEN before impl -> feature ∃ ∨ test wrong — investigate.
export const validateEmail = (email: string): Result<string, Error> => {
if (!email.includes("@")) return Err(new Error("Invalid email"));
return Ok(email);
};
Only enough code to pass. No more.
Improve structure, ¬change behavior, tests stay green.
Deleting hours of work to start test-first is correct. Time gone regardless. Starting over w/ proper TDD produces better code faster than retrofitting tests.
3+ test fixes attempted -> question the design, ¬ the test. Test probably right; impl approach wrong.
| Pattern | Problem | Fix |
|---|---|---|
| Tests after impl | Never verified test catches failures | Write test first -> watch fail -> implement |
| Mock behavior testing | expect(mock).toHaveBeenCalled() tests mock, ¬code | Use ∈-memory adapters implementing real interface |
| Over-mocking | Mock everything, test nothing real | ∈-memory adapters: real interface, ¬I/O |
| "Too simple for TDD" | Simple code is where hidden bugs live | Follow the cycle regardless |
Vitest: describe/it/expect/beforeEach/afterEach | ¬test() | colocated .spec.ts | globals: true
Avoid horizontal slicing — drafting every test before writing implementation code yields tests that verify imagined shapes rather than real behavior.
Use vertical slices via tracer bullets:
Rules:
Per-cycle checklist:
Use when reviewing architecture decisions. C4 model, dependency inversion, hexagonal boundaries.
Use during discuss-slice and plan-slice to stress-test a spec or plan against domain vocabulary before approval.
Use during research-slice to build disposable experiments that answer technical uncertainty.
Use during project:init to scaffold repo-level agent configuration (CLAUDE.md, AGENTS.md, tracker labels).
Use when debugging. 4-phase investigation, root cause, minimal fix.
Use during discuss-slice to synthesize conversation context into a formal PRD with user stories, implementation decisions, testing decisions, and exclusions.