core-tdd

코어 계층(Domain, UseCase, Service, Command/Query) TDD 개발 지침. Red-Green-Refactor 사이클을 통해 테스트 주도 개발을 수행합니다. 테스트를 먼저 작성하고, 테스트가 통과하는 최소한의 코드를 구현합니다.

⭐5stars🔀1forks📁View on GitHub🕐Updated Jan 11, 2026

When & Why to Use This Skill

This Claude skill provides a comprehensive framework for Test-Driven Development (TDD) specifically tailored for core application layers including Domain, UseCase, Service, and Command/Query. It streamlines the software development lifecycle by enforcing the Red-Green-Refactor cycle, ensuring that code is not only functional but also maintainable and architecturally sound through strict naming conventions and design patterns.

Use Cases

  • Scenario 1: Implementing new business logic in the Domain layer by writing failing tests first to define behavior before writing the minimum viable code.
  • Scenario 2: Standardizing team-wide coding practices by enforcing specific naming conventions (Find, Save, Modify, Delete) and static factory method patterns (newXxx, withId).
  • Scenario 3: Refactoring legacy Service layer code with confidence, using existing test suites to ensure functional integrity while improving code readability and structure.
  • Scenario 4: Accelerating the setup of Mockito-based unit tests for complex services, ensuring proper dependency injection and snake_case test method naming for better clarity.
namecore-tdd
description코어 계층(Domain, UseCase, Service, Command/Query) TDD 개발 지침. Red-Green-Refactor 사이클을 통해 테스트 주도 개발을 수행합니다. 테스트를 먼저 작성하고, 테스트가 통과하는 최소한의 코드를 구현합니다.

코어 계층 TDD 지침

TDD 순서

  1. Command/Query - 테스트 → 구현 → 리팩토링
  2. Domain - 테스트 → 구현 → 리팩토링
  3. UseCase - 인터페이스 정의 (테스트 불필요)
  4. Service - 테스트 → 구현 → 리팩토링

Red-Green-Refactor 사이클

Red (테스트 작성)

  1. 실패하는 테스트 먼저 작성
  2. 컴파일 에러 해결을 위한 최소 stub만 생성
  3. 테스트 실행하여 의도한 실패 확인

Green (구현)

  1. 테스트를 통과시키는 최소한의 코드 작성
  2. 명명 규칙 준수 (Find/Save/Modify/Delete)
  3. 정적 팩토리 메서드 패턴 (newXxx/withId)

Refactor (개선)

  1. 테스트 통과 상태 유지
  2. 중복 제거, 가독성 개선
  3. 아키텍처/코딩 규칙 준수

핵심 규칙

필수 명명 규칙

동작 접두사 금지
조회 Find Get, Query, Retrieve
등록 Save Create, Add, Insert
수정 Modify Update, Edit, Change
삭제 Delete Remove, Erase

정적 팩토리 메서드

  • 신규 생성: newXxx() (예: Family.newFamily(...))
  • 복원: withId() (예: Family.withId(...))
  • 금지: of(), create(), from()

테스트 패턴

  • 클래스: @ExtendWith(MockitoExtension.class)
  • Service: @InjectMocks + @Mock
  • 메서드명: snake_case ({행동}_{결과}_{조건})

상세 지침

[필수] 아래 참조 문서를 모두 읽은 후 작업을 시작하세요: