Communitygithub.com

테스트 주도 개발 (TDD)

레드-그린-리팩터(red-green-refactor) 루프를 통한 테스트 주도 개발 방식입니다. 사용자가 TDD를 사용하여 기능을 구축하거나 버그를 수정하려고 할 때, '레드-그린-리팩터'를 언급하거나 통합 테스트를 원하거나 테스트 우선 개발을 요청할 때 사용하세요.

테스트 주도 개발 (TDD)란 무엇인가요?

이 스킬은 **테스트 주도 개발(TDD)** 방법론을 따르며, 특히 동작 검증을 구현 세부 사항보다는 **공개 인터페이스**에 집중하는 **통합 스타일 테스트**를 강조합니다. 이는 단순한 단위 테스트가 아닌, 실제 코드 경로를 공개 API를 통해 실행하는 테스트를 권장합니다. 핵심 워크플로우는 **수직 슬라이스(vertical slicing)** 방식으로, 한 번에 하나의 테스트를 작성하고(레드), 그 테스트를 통과할 최소한의 코드를 구현하며(그린), 리팩터링하는 순환을 반복합니다. 이 방법은 '테스트를 모두 먼저 작성한 후 모든 코드를 구현'하는 수평 슬라이스(horizontal slice) 안티패턴을 피하도록 설계되었습니다. 또한, 각 주기마다 계획 수립, 추적탄(tracer bullet) 방식의 첫 번째 테스트, 점진적 루프, 리팩터링 단계를 거치며, 사용자와의 협의를 통해 중요한 동작에 테스트 노력을 집중합니다. 이 스킬은 Claude Code, Cursor 등 AI 코딩 에이전트와 함께 사용하기에 적합하며, `tests.md`, `mocking.md`, `deep-modules.md`, `interface-design.md`, `refactoring.md` 같은 보조 문서와 연계됩니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/cdcoonce/Portfolio_Website/tree/HEAD/.claude/skills/tdd

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

테스트 주도 개발

철학

핵심 원칙: 테스트는 구현 세부 사항이 아닌 공개 인터페이스를 통해 동작을 검증해야 합니다. 코드는 완전히 변경될 수 있지만, 테스트는 변경되지 않아야 합니다.

좋은 테스트는 통합 스타일입니다. 실제 코드 경로를 공개 API를 통해 실행합니다. 시스템이 무엇을 하는지 설명하고 어떻게 하는지는 설명하지 않습니다. 좋은 테스트는 명세서처럼 읽힙니다. "사용자가 유효한 장바구니로 결제할 수 있음"은 정확히 어떤 기능이 존재하는지 알려줍니다. 이러한 테스트는 내부 구조에 신경 쓰지 않기 때문에 리팩터링에도 견딥니다.

나쁜 테스트는 구현에 결합되어 있습니다. 내부 협력 객체를 목(mock)으로 대체하고, 비공개(private) 메서드를 테스트하거나, 외부 수단(데이터베이스를 인터페이스 대신 직접 조회하는 등)을 통해 검증합니다. 경고 신호: 동작은 변경되지 않았지만 리팩터링할 때 테스트가 깨집니다. 내부 함수 이름을 바꿨는데 테스트가 실패한다면, 그 테스트는 구현을 테스트한 것이지 동작을 테스트한 것이 아닙니다.

예시는 tests.md를, 목킹 지침은 mocking.md를 참조하세요.

안티패턴: 수평 슬라이스(Horizontal Slice)

모든 테스트를 먼저 작성하고, 그다음에 모든 구현을 작성하지 마세요. 이것은 "수평 슬라이싱"입니다. RED를 "모든 테스트 작성", GREEN을 "모든 코드 작성"으로 취급하는 것입니다.

이것은 형편없는 테스트를 만듭니다:

  • 벌크로 작성된 테스트는 실제 동작이 아닌 상상된 동작을 테스트합니다.
  • 결국 사용자 대면 동작이 아닌 것들의 형태(데이터 구조, 함수 시그니처)를 테스트하게 됩니다.
  • 테스트는 실제 변경에 둔감해집니다. 동작이 깨져도 통과하고, 동작이 정상이어도 실패합니다.
  • 구현을 이해하기 전에 테스트 구조에 전념하게 되면서 앞을 내다보지 못하게 됩니다.

올바른 접근 방식: 추적탄(tracer bullet)을 통한 수직 슬라이스. 하나의 테스트 → 하나의 구현 → 반복. 각 테스트는 이전 주기에서 배운 내용에 응답합니다. 방금 코드를 작성했기 때문에 어떤 동작이 중요하고 어떻게 검증할지 정확히 알 수 있습니다.

잘못된 예 (수평):
  RED:   test1, test2, test3, test4, test5
  GREEN: impl1, impl2, impl3, impl4, impl5

올바른 예 (수직):
  RED→GREEN: test1→impl1
  RED→GREEN: test2→impl2
  RED→GREEN: test3→impl3
  ...

워크플로우

1. 계획 수립

코드를 작성하기 전에:

  • 사용자와 필요한 인터페이스 변경 사항을 확인
  • 사용자와 테스트할 동작을 확인 (우선순위 지정)
  • 깊은 모듈 기회 식별 (작은 인터페이스, 깊은 구현)
  • 테스트 용이성을 위한 인터페이스 설계
  • 테스트할 동작 나열 (구현 단계 아님)
  • 계획에 대한 사용자 승인 받기

질문: "공개 인터페이스는 어떻게 되어야 합니까? 어떤 동작을 가장 중요하게 테스트해야 합니까?"

모든 것을 테스트할 수는 없습니다. 사용자와 정확히 어떤 동작이 가장 중요한지 확인하세요. 가능한 모든 엣지 케이스가 아닌, 중요한 경로와 복잡한 로직에 테스트 노력을 집중하세요.

2. 추적탄(Tracer Bullet)

시스템에 대해 하나의 사실을 확인하는 하나의 테스트를 작성하세요:

RED:   첫 번째 동작에 대한 테스트 작성 → 테스트 실패
GREEN: 통과할 수 있는 최소 코드 작성 → 테스트 통과

이것이 추적탄입니다. 경로가 종단 간(end-to-end) 작동함을 증명합니다.

3. 점진적 루프

남은 각 동작에 대해:

RED:   다음 테스트 작성 → 실패
GREEN: 통과할 최소 코드 → 통과

규칙:

  • 한 번에 하나의 테스트
  • 현재 테스트를 통과할 충분한 코드만
  • 미래의 테스트를 예측하지 않음
  • 테스트는 관찰 가능한 동작에 집중

4. 리팩터링

모든 테스트가 통과한 후, 리팩터링 후보를 찾으세요:

  • 중복 추출
  • 모듈 심화 (복잡성을 단순한 인터페이스 뒤로 이동)
  • 자연스러운 곳에 SOLID 원칙 적용
  • 새로운 코드가 기존 코드에 대해 무엇을 드러내는지 고려
  • 각 리팩터링 단계 후 테스트 실행

RED 상태에서는 절대 리팩터링하지 마세요. 먼저 GREEN 상태로 만드세요.

주기별 체크리스트

[ ] 테스트가 구현이 아닌 동작을 설명하는가?
[ ] 테스트가 공개 인터페이스만 사용하는가?
[ ] 내부 리팩터링 후에도 테스트가 유지되는가?
[ ] 코드가 이 테스트를 위해 최소한인가?
[ ] 예측된 기능이 추가되지 않았는가?

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

cdcoonce/Portfolio_Website

Git commit workflow with enforced conventional commit style. Use when Claude needs to stage and commit changes, craft commit messages, or the user asks to commit, make a commit, or save their work. Ensures consistent commit message format, proper scoping, and atomic commits across the project.

cdcoonce/Portfolio_Website

AI-powered code quality analysis for Python, Markdown, and Mermaid diagrams. Use this skill when: (1) reviewing code for quality issues, (2) checking Python files for PEP8 violations, unused code, missing type hints, docstring problems, complexity issues, or potential runtime errors, (3) validating Markdown documentation for broken links, heading structure, or formatting issues, (4) validating Mermaid diagram syntax, (5) the user asks for a "code review" or "quality check", (6) analyzing code snippets pasted in conversation, or (7) suggesting and applying fixes for code quality issues.

cdcoonce/Portfolio_Website

Deploy the portfolio chat agent Lambda function to AWS. Use when the user asks to deploy, redeploy, push to Lambda, update the chat agent, or after updating context files or lambda_function.py. Rebuilds the knowledge base, packages dependencies, and deploys to AWS Lambda.

cdcoonce/Portfolio_Website

Generate multiple radically different interface designs for a module using parallel sub-agents. Use when user wants to design an API, explore interface options, compare module shapes, or mentions "design it twice".

cdcoonce/Portfolio_Website

Orchestrate the full GitHub-issues-driven development lifecycle. 7-phase pipeline from brainstorm through PR with state tracking and cross-conversation resume. Use when user says "dev cycle", "development workflow", "full development pipeline", or invokes /dev-cycle.

cdcoonce/Portfolio_Website

Production Python coding standards with automatic version detection (3.10-3.13). Use when writing, reviewing, or refactoring Python to ensure adherence to modern type syntax, LBYL exception handling, pathlib operations, ABC-based interfaces, and production-tested patterns. Not Dagster-specific - applies to any Python project.

cdcoonce/Portfolio_Website

Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute. Use when user wants to prevent destructive git operations, add git safety hooks, or block git push/reset in Claude Code.

cdcoonce/Portfolio_Website

GitHub CLI (gh) integration for managing issues, pull requests, branches,

cdcoonce/Portfolio_Website

Interview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree. Use when user wants to stress-test a plan, get grilled on their design, or mentions "grill me".

cdcoonce/Portfolio_Website

Explore a codebase to find opportunities for architectural improvement, focusing on making the codebase more testable by deepening shallow modules. Use when user wants to improve architecture, find refactoring opportunities, consolidate tightly-coupled modules, or make a codebase more AI-navigable.

cdcoonce/Portfolio_Website

CEO/founder-mode plan review. Rethink the problem, find the 10-star product, challenge premises, expand scope when it creates a better product. Three modes: SCOPE EXPANSION (dream big), HOLD SCOPE (maximum rigor), SCOPE REDUCTION (strip to essentials). Use when the user asks for a plan review, CEO review, mega review, or wants a plan challenged/stress-tested before implementation.

cdcoonce/Portfolio_Website

Break a PRD into independently-grabbable GitHub issues using tracer-bullet vertical slices. Use when user wants to convert a PRD to issues, create implementation tickets, or break down a PRD into work items.

cdcoonce/Portfolio_Website

Turn a PRD into a multi-phase implementation plan using tracer-bullet vertical slices, saved as a local Markdown file in docs/plans/. Use when user wants to break down a PRD, create an implementation plan, plan phases from a PRD, or mentions "tracer bullets".

cdcoonce/Portfolio_Website

Generate or update the `.claude/docs/project.md` file that gives Claude project-specific context. Use this skill when the user asks to create, update, regenerate, or refresh project context, or says things like "update project.md", "generate project context", "this repo needs a project.md", or "Claude doesn't know about this project". Also trigger when onboarding Claude to a new repository for the first time.

cdcoonce/Portfolio_Website

Generate comprehensive, high-quality README.md files for code repositories. Use this skill whenever the user asks to create, write, generate, update, or improve a README for any project or repository. Also trigger when the user says things like "document this project", "write docs for this repo", "this repo needs a README", "help me onboard developers to this codebase", or asks for project documentation in markdown. Even if the user just says "README" or "readme" in the context of a codebase, use this skill.

cdcoonce/Portfolio_Website

Create a detailed refactor plan with tiny commits via user interview, then file it as a GitHub issue. Use when user wants to plan a refactor, create a refactoring RFC, or break a refactor into safe incremental steps.

cdcoonce/Portfolio_Website

Set up pre-commit hooks for the current repo. Use when user wants to add pre-commit hooks, configure commit-time linting, formatting, type checking, or testing. Triggers on "pre-commit", "git hooks", "linting hooks", or /setup-pre-commit.

cdcoonce/Portfolio_Website

Triage a bug or issue by exploring the codebase to find root cause, then create a GitHub issue with a TDD-based fix plan. Use when user reports a bug, wants to file an issue, mentions "triage", or wants to investigate and plan a fix for a problem.

cdcoonce/Portfolio_Website

Rewrites the prose sections of wiki pages in-place. Reads source files to understand current context, then updates only the content inside <!-- claude:prose --> ... <!-- claude:prose:end --> markers. Never touches <!-- generated:start --> ... <!-- generated:end --> blocks. Supports targeting a single page with /update-wiki {PageName}.

cdcoonce/Portfolio_Website

Create a PRD through user interview, codebase exploration, and module design, then submit as a GitHub issue. Use when user wants to write a PRD, create a product requirements document, or plan a new feature.

관련 스킬