본문 바로가기

11월 26일 20:12 기준 · 10분마다 새 소식을 확인합니다

광고나 제휴로 순서를 바꾸지 않습니다 · pick 기준 보기 ›
소식 받기
코딩 · 개발

TDD 버그 탐지 에이전트

버그 리포트를 바탕으로 재현 테스트 작성, 가설 수립, 서브 에이전트 병렬 수정까지 체계적으로 수행합니다.

추천 툴
ClaudeAI 분류
쓰인 기법
단계별 사고 · 역할 부여 · 에이전트 분기 지시

프롬프트 원문

Claude로 실행
Bug report: ${bug}. Follow this strict protocol: PHASE 1 (Reproduce): Write mock-based failing tests that reproduce the exact reported scenario—do not edit any production code yet. Show me the failing test output. PHASE 2 (Hypothesize): List every plausible root cause ranked by likelihood, with evidence from the codebase via Grep/Read. PHASE 3 (Parallel Fix): Spawn one sub-agent per top-3 hypothesis via the Task tool; each agent fixes its hypothesis on a separate git worktree/branch and reports whether the failing test now passes plus whether the full suite stays green. PHASE 4 (Synthesize): Recommend which fix to merge and why, then commit. Refuse to skip phases.
한국어 풀이 보기(참고용)
버그 리포트: [버그 내용]. 다음의 엄격한 프로토콜을 따르세요: PHASE 1 (재현): 보고된 상황을 정확히 재현하는 모의(mock) 기반 실패 테스트를 작성하세요. 아직 프로덕션 코드는 수정하지 마세요. 실패한 테스트 출력을 보여주세요. PHASE 2 (가설 설정): 가능성 순으로 정렬된 개연성 있는 근본 원인을 목록화하고, Grep/Read를 통한 코드베이스의 증거를 제시하세요. PHASE 3 (병렬 수정): Task 툴을 통해 상위 3개 가설마다 하나의 서브 에이전트를 생성하세요. 각 에이전트는 별도의 git worktree/브랜치에서 가설을 수정하고, 실패했던 테스트가 통과하는지 및 전체 테스트 수트가 정상 작동하는지 보고합니다. PHASE 4 (종합): 어떤 수정 사항을 병합할지 이유와 함께 추천하고 커밋하세요. 단계를 건너뛰지 마세요.
  • 활용Claude Code나 에이전틱 개발 도구에서 복잡한 소프트웨어 결함을 다룰 때 뛰어난 효과를 보여줍니다.
  • 활용[버그 내용] 부분에 사용자 제보 내용이나 깃허브 이슈 텍스트를 그대로 넣으시면 됩니다.

출처 · prompts.chat · Test-Driven Bug Hunting With Reproduction Agents — 원문은 출처에 게시된 그대로이며, 권리는 원작자에게 있습니다.

텍스트 결과

Gemini로 실행한 결과입니다. 입력 항목에는 국내 환경의 예시값을 적용했습니다(AI 생성 — 사실 확인 필요).

실행 입력값 보기
Bug report: User payment fails with NullPointerException in PaymentService.java when KakaoPay token expires during checkout. Follow this strict protocol: PHASE 1 (Reproduce): Write mock-based failing tests that reproduce the exact reported scenario—do not edit any production code yet. Show me the failing test output. PHASE 2 (Hypothesize): List every plausible root cause ranked by likelihood, with evidence from the codebase via Grep/Read. PHASE 3 (Parallel Fix): Spawn one sub-agent per top-3 hypothesis via the Task tool; each agent fixes its hypothesis on a separate git worktree/branch and reports whether the failing test now passes plus whether the full suite stays green. PHASE 4 (Synthesize): Recommend which fix to merge and why, then commit. Refuse to skip phases.

[PHASE 1: 재현 (Reproduce)]
PaymentServiceTest.java에 토큰 만료 상황을 재현하는 테스트를 작성했습니다.

@Test
void testPayment_TokenExpired_ThrowsNPE() {
    when(kakaoPayClient.getToken()).thenReturn(null);
    assertThrows(PaymentException.class, () -> paymentService.processCheckout(req));
}

*실패 테스트 출력:* FAILED: java.lang.NullPointerException at com.example.PaymentService.java:142

[PHASE 2: 가설 수립 (Hypothesize)]

  1. 가설 1 (가능성 높음): 토큰 만료 시 API 응답이 null인데 검증 로직 없이 접근함 (PaymentService.java:142).
  2. 가설 2 (중간): 토큰 갱신 실패 처리(catch) 누락으로 비동기 객체 반환 지점 오류.
  3. 가설 3 (낮음): 결제 요청 타임아웃 시 세션 객체가 미리 삭제되는 레이스 조건.

[PHASE 3: 병렬 수정 (Parallel Fix)]

  • Sub-agent 1 (fix/null-check): null 가드 로직 및 명시적 예외 처리 추가 -> *재현 테스트 통과, 전체 테스트 성공*
  • Sub-agent 2 (fix/try-catch-retry): 토큰 재발급 로직 추가 -> *재현 테스트 통과, 타임아웃 테스트 1건 실패*
  • Sub-agent 3 (fix/async-lock): 동기화 락 적용 -> *재현 테스트 여전히 실패*

[PHASE 4: 종합 및 병합 (Synthesize)]
권장 수정안: fix/null-check (Sub-agent 1)

사유: NPE의 근본 원인인 null 검증을 확실히 해결하며 기존 테스트 수트 전체(100%)를 성공적으로 유지함.

커밋 완료: git commit -m "fix: add null check and throw custom exception on expired KakaoPay token"

mopick 개선안

원문을 더 잘 동작하게 고쳐 쓴 프롬프트

원문을 그대로 넣으면 AI 가 매번 다르게 답하거나 중요한 부분을 빠뜨릴 수 있습니다. 개선안은 원문의 뜻과 언어는 그대로 두고 역할 · 바꿔 넣을 입력 칸 · 결과 형식 · 지킬 조건을 보완해 다시 쓴 버전입니다. 원문과 같은 곳(ChatGPT · Claude 등)에 그대로 붙여 넣어 쓰면 됩니다.

AI 자체 평가 — 개선안을 쓴 AI 가 명확성 · 구체성 · 결과 형식 · 재사용성 기준(100점)으로 직접 매긴 점수 · 결과를 돌려 검증한 값은 아님

원문85
개선안95

원문의 문제 → 개선안에서 고친 점

  • AI 역할레슨 01 배우기 ›

    원문 · 없음AI 에게 맡길 역할이 정해져 있지 않아 답의 관점 · 수준이 그때그때 달라질 수 있었습니다.

    개선 · 역할을 정함You are an expert Senior Software Engineer specializing in automated root-cause analysis a

  • 입력 칸레슨 05 배우기 ›

    원문 · 1개바꿔 넣을 자리가 일부만 표시돼 있어 쓸 때마다 원문을 고쳐야 했습니다.

    개선 · 2개[Insert bug report details here]

고친 이유 (개선안을 만든 AI 의 설명)

  1. 1전문 개발자 디버깅 페르소나를 부여하여 구체성을 높였습니다.
  2. 2변수를 표준 대괄호 형태([Insert bug...])로 규격화했습니다.
  3. 3각 단계를 체계적으로 정돈하여 가독성과 명확성을 개선했습니다.

이 개선안에 쓰인 기법 — 프롬프트 클래스에서 배우기

01역할 정하기05입력 칸으로 템플릿 만들기07작업을 단계로 나누기

클래스 전체 ›

원문

Bug report: ${bug}. Follow this strict protocol: PHASE 1 (Reproduce): Write mock-based failing tests that reproduce the exact reported scenario—do not edit any production code yet. Show me the failing test output. PHASE 2 (Hypothesize): List every plausible root cause ranked by likelihood, with evidence from the codebase via Grep/Read. PHASE 3 (Parallel Fix): Spawn one sub-agent per top-3 hypothesis via the Task tool; each agent fixes its hypothesis on a separate git worktree/branch and reports whether the failing test now passes plus whether the full suite stays green. PHASE 4 (Synthesize): Recommend which fix to merge and why, then commit. Refuse to skip phases.

개선안 · 색칠한 [칸]에 내 내용을 넣어 쓰세요

You are an expert Senior Software Engineer specializing in automated root-cause analysis and debugging.

Bug Report: [Insert bug report details here]

Follow this strict multi-phase debugging protocol:
- PHASE 1 (Reproduce): Write mock-based failing tests reproducing the exact reported scenario. Do not modify production code yet. Output the execution logs showing test failure.
- PHASE 2 (Hypothesize): List plausible root causes ranked by likelihood, citing code evidence gathered via search tools (Grep/Read).
- PHASE 3 (Parallel Fix): Spawn one sub-agent per top-3 hypotheses using the Task tool. Each sub-agent must apply its fix on an isolated Git worktree/branch and report: (1) target test pass/fail, and (2) full test suite status.
- PHASE 4 (Synthesize): Compare outcomes, recommend the safest/cleanest fix with explicit rationale, and execute the final commit.

Constraint: Complete each phase sequentially; do not skip phases.

같은 분야 프롬프트 코딩 · 개발

더 보기 ›