Agent skill

dev-coding-debug

Stars 163
Forks 31

Install this agent skill to your Project

npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/development/dev-coding-debug

SKILL.md

🐞 체계적 디버깅 (Dev Coding Debug)

이 μ›Œν¬ν”Œλ‘œμš°λŠ” obra/superpowers의 **"The Iron Law"**λ₯Ό μ€€μˆ˜ν•©λ‹ˆλ‹€. κ·Όλ³Έ 원인 규λͺ… μ—†μ΄λŠ” μ ˆλŒ€ μ½”λ“œλ₯Ό μˆ˜μ •ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

1. μ΄ˆκΈ°ν™” (Initialization)

  1. 원칙 확인: this documentλ₯Ό 읽고 Iron Lawλ₯Ό μƒκΈ°ν•©λ‹ˆλ‹€.
  2. 증상 μ •μ˜: μ‚¬μš©μžλ‘œλΆ€ν„° μ •ν™•ν•œ μ—λŸ¬ λ©”μ‹œμ§€μ™€ ν˜„μƒμ„ μž…λ ₯λ°›μŠ΅λ‹ˆλ‹€.

2. 쑰사 (Phase 1: Root Cause Investigation)

"μΆ”μΈ‘ν•˜μ§€ 말고 증거λ₯Ό μˆ˜μ§‘ν•˜μ„Έμš”."

  1. μ—λŸ¬ 뢄석: μŠ€νƒ νŠΈλ ˆμ΄μŠ€μ™€ μ—λŸ¬ μ½”λ“œλ₯Ό μ •λ°€ λΆ„μ„ν•©λ‹ˆλ‹€.
  2. μž¬ν˜„ (Reproduction): 버그λ₯Ό ν™•μ‹€ν•˜κ²Œ λ°œμƒμ‹œν‚€λŠ” μ΅œμ†Œ λ‹¨μœ„μ˜ 슀크립트λ₯Ό μž‘μ„±ν•©λ‹ˆλ‹€. (ν•„μˆ˜)
  3. κΈ°κΈ°/둜그 μΆ”κ°€ (Instrumentation): 데이터가 μ˜€μ—Όλ˜λŠ” 지점을 μ°ΎκΈ° μœ„ν•΄ 둜그λ₯Ό μΆ”κ°€ν•˜κ³ , 데이터 흐름을 역좔적(Trace)ν•©λ‹ˆλ‹€.

3. 뢄석 (Phase 2: Pattern Analysis)

"정상적인 νŒ¨ν„΄κ³Ό 무엇이 λ‹€λ₯Έκ°€μš”?"

  1. 정상 사둀 μ°ΎκΈ°: ν”„λ‘œμ νŠΈ λ‚΄μ—μ„œ 잘 λ™μž‘ν•˜λŠ” μœ μ‚¬ν•œ μ½”λ“œλ₯Ό μ°ΎμŠ΅λ‹ˆλ‹€.
  2. 비ꡐ 뢄석: 정상 μ½”λ“œμ™€ λ¬Έμ œκ°€ μžˆλŠ” μ½”λ“œμ˜ 차이점을 ν•œ 쀄 ν•œ 쀄 λΉ„κ΅ν•©λ‹ˆλ‹€.
  3. 차이점 λͺ©λ‘: μ‚¬μ†Œν•΄ λ³΄μ΄λŠ” 차이점이라도 λͺ¨λ‘ λ‚˜μ—΄ν•©λ‹ˆλ‹€.

4. κ°€μ„€ (Phase 3: Hypothesis & Testing)

"과학적 방법둠을 μ μš©ν•˜μ„Έμš”."

  1. κ°€μ„€ 수립: "X λ•Œλ¬Έμ— Yκ°€ λ°œμƒν•œλ‹€"λŠ” 가섀을 ν•˜λ‚˜ μ„Έμ›λ‹ˆλ‹€.
  2. μ΅œμ†Œ 검증: 가섀을 ν™•μΈν•˜κΈ° μœ„ν•΄ λ³€μˆ˜ ν•˜λ‚˜λ§Œ λ³€κ²½ν•˜μ—¬ ν…ŒμŠ€νŠΈν•©λ‹ˆλ‹€. (μˆ˜μ •μ΄ μ•„λ‹˜)
  3. 반볡: 가섀이 ν‹€λ Έλ‹€λ©΄ λ³€κ²½ 사항을 되돌리고(Revert), μƒˆλ‘œμš΄ 가섀을 μ„Έμ›λ‹ˆλ‹€. κΈ°μ‘΄ λ³€κ²½ μœ„μ— 덧칠 κΈˆμ§€.

5. ν•΄κ²° (Phase 4: Implementation)

"증상이 μ•„λ‹Œ 원인을 κ³ μΉ˜μ„Έμš”."

  1. μ‹€νŒ¨ ν…ŒμŠ€νŠΈ (Red): μ‹λ³„λœ 원인을 νƒ€κ²ŸμœΌλ‘œ ν•˜λŠ” μ‹€νŒ¨ ν…ŒμŠ€νŠΈ μΌ€μ΄μŠ€λ₯Ό ν™•μ •ν•©λ‹ˆλ‹€.
  2. 단일 μˆ˜μ • (Green): κ·Όλ³Έ 원인을 μ œκ±°ν•˜λŠ” μ΅œμ†Œν•œμ˜ μ½”λ“œλ₯Ό μž‘μ„±ν•©λ‹ˆλ‹€.
  3. 검증 (Verification): ν…ŒμŠ€νŠΈ 톡과 및 νšŒκ·€ ν…ŒμŠ€νŠΈ(Regression Test) μˆ˜ν–‰.
  4. 정리 (Cleanup): λ””λ²„κΉ…μš© λ‘œκ·Έμ™€ μž„μ‹œ μ½”λ“œλ₯Ό 깨끗이 μ‚­μ œν•©λ‹ˆλ‹€.

6. μ’…λ£Œ (Completion)

  1. 회고: μ–΄λ–€ 뢀뢄이 κ·Όλ³Έ μ›μΈμ΄μ—ˆλŠ”μ§€ μ‚¬μš©μžμ—κ²Œ μ„€λͺ…ν•˜κ³  μ’…λ£Œν•©λ‹ˆλ‹€.

Standards & Rules

Systematic Debugging (Dev Coding Debug)

Core Principles (The Iron Law)

NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST.

If you haven't completed Phase 1 (Root Cause) and Phase 2 (Pattern Analysis), you cannot propose fixes. Symptom fixes are failure.

πŸ—οΈ The Four Phases

Phase 1: Root Cause Investigation

Goal: Understand WHAT and WHY.

  1. Read Errors: sticky to the error message. Don't skip stack traces.
  2. Reproduce: Can you trigger it reliably? If not, gather more data.
  3. Instrumentation: For multi-component systems, log data flow at boundaries.
  4. Trace: Follow the bad value backwards to its source (root-cause-tracing).

Phase 2: Pattern Analysis

Goal: Find the standard before fixing.

  1. Find Working Examples: Locate similar code that works.
  2. Compare: Read reference implementations completely.
  3. Identify Differences: List every difference, however small.

Phase 3: Hypothesis and Testing

Goal: Scientific Method.

  1. Single Hypothesis: "I think X is the root cause because Y".
  2. Test Minimally: Change ONE variable at a time to test the hypothesis.
  3. Verify: If it didn't work, revert and form a NEW hypothesis. NO layering fixes.

Phase 4: Implementation

Goal: Fix the root cause, not the symptom.

  1. Failing Test: Create a minimal reproduction test case (Red).
  2. Single Fix: Address the identified root cause (Green).
  3. Verify: Ensure no regressions.

�️ Supporting Techniques

1. Root Cause Tracing ("Why did this happen?")

Don't just fix the bad value. Find where it came from.

  • Technique: Ask "What called this with a bad value?" repeatedly until you find the source.
  • Rule: Fix at the source, not at the symptom.

2. Defense-in-Depth ("Make it impossible")

Don't just validate at one place.

  • Layer 1 (Entry): Reject invalid input at IDL/API boundary.
  • Layer 2 (Logic): Ensure data makes sense for the operation.
  • Layer 3 (Guard): Environment checks (e.g., test vs prod).
  • Layer 4 (Debug): Logging for forensics.

3. Condition-Based Waiting (No sleep)

Never guess how long something takes.

  • Bad: sleep(50)
  • Good: waitFor(() => condition)
  • Why: Flaky tests often come from arbitrary timeouts.

�🚩 Red Flags (STOP immediately)

  • "Quick fix for now"
  • "Just try changing X"
  • "One more fix attempt" (Limit: 3 attempts. Then question Architecture.)
  • Proposing solutions before tracing.

βœ… Quality Standards

  • Reproduction Script: Must exist before fixing.
  • Log Cleanup: All temporary instrumentation removed.
  • Safe YAML: Frontmatter descriptions quoted.

Checklist

  • Phase 1: Did you identify the exact line/reason for failure?
  • Phase 2: Did you compare with a working example?
  • Phase 4: Is there a test case that failed before and passes now?
  • Cleanup: Are all print/console.log removed?

Didn't find tool you were looking for?

Be as detailed as possible for better results