把 Claude Code 從『看到報錯就亂改』導正成有紀律的 4 步抓蟲流程:先穩定重現 bug,再用最小化定位真正根因(而非症狀),寫一個會失敗的回歸測試,再做範圍最小的修復,最後跑全套測試證明修好且沒打壞別的。
不用離開網站,直接看這組 prompt 跑出來長怎樣(AI 即時生成,扣 1 點)。
不只複製貼上 — 下載後放到 ~/.claude/skills/bug-repro-isolate-fix-verify/SKILL.md,之後每個 session 自動可用(觸發時自動載入)。
mkdir -p ~/.claude/skills/bug-repro-isolate-fix-verify && mv ~/Downloads/SKILL.md ~/.claude/skills/bug-repro-isolate-fix-verify/SKILL.mdNew-Item -ItemType Directory -Force "$env:USERPROFILE\.claude\skills\bug-repro-isolate-fix-verify" | Out-Null; Move-Item "$env:USERPROFILE\Downloads\SKILL.md" "$env:USERPROFILE\.claude\skills\bug-repro-isolate-fix-verify\SKILL.md"何時用:任何具體的 bug 報告——報錯、行為不對、間歇性故障。尤其適合那種『AI 之前改過但越改越亂』的情況,因為它強制先重現+定位再動手。 為何有效:這對應 Claude Code 真實且被廣泛推薦的 4 步除錯方法論——重現問題 → 定位根因 → 套用修復 → 驗證回歸。社群除錯 skill 的核心鐵律就是『no fix without a failing test』。回歸測試被稱為『你的安全帶』:它先證明 bug 存在,再告訴你何時真的修好。最後跑『全套』測試而非單一測試,是因為窄修也可能波及他處。 技巧:① {{CONTEXT}} 盡量給足——stack trace、何時發生、最近改了什麼、發生頻率,診斷準度直接相關。② Phase 2 提到把重度 read-only 調查丟給 Explore subagent(Claude Code 真實的唯讀探索代理,透過 Task/Agent 工具),好處是大量讀檔不會污染主對話的 context;這是真功能,但若你的任務小、不想分流,AI 直接在主線查也行。③ 『最小修復 + 不順手改無關程式』那條規則是防止 AI 把一個 bug 修成三個 bug 的關鍵。④ 若是無法寫自動化測試的 UI/環境問題,至少要求它給出可手動重現的明確步驟與預期/實際行為。
=== PHASE 1: REPRODUCE === Wrote failing test `cart total with 0-qty item`. Ran `npm test`: ✕ cart total ignores 0-qty lines — expected 100, got NaN Reproduced reliably. === PHASE 2: ISOLATE === Root cause: `lineTotal()` divides by qty to derive unit price, so qty=0 yields NaN which poisons the sum. Symptom is 'total shows NaN'; root cause is the unguarded division at cart.ts:42. (Candidates considered: rounding bug, currency parse — ruled out by the repro.) === PHASE 3: FIX === Guard qty=0 lines before the division at cart.ts:42 — narrowest change that removes the NaN source. === PHASE 4: VERIFY === Repro test now passes. Full suite `npm test`: 214 passing, 0 failing. Summary — Root cause: division by qty=0 at cart.ts:42. Fix: skip 0-qty lines. Regression test: 'cart total with 0-qty item' (committed). Noted but NOT touched: cart.ts also lacks negative-qty handling — separate issue.
以上為此 Prompt 丟進 Claude Code 後可得到的描述性成果,實際畫面會因填入的變數而有差異。
[BUG_REPORT]Bug 描述:預期行為 vs 實際行為、觸發步驟、錯誤訊息
[CONTEXT]已知線索:完整 stack trace、發生時機與頻率、最近的相關改動或部署
[RUN_COMMAND]如何跑專案/測試的指令,例如 npm test、pytest、make test,AI 會用它驗證修復
填下面的欄位,上方 prompt 會即時替換 [方括號] 內容。填好後按「複製組好的 prompt」直接丟進工具。
You are fixing a bug. Follow this four-phase loop strictly: REPRODUCE → ISOLATE → FIX → VERIFY. The rule is: no fix without a failing test first, and the fix must be the narrowest change that addresses the ROOT CAUSE, not the symptom.
BUG REPORT:
{{BUG_REPORT}}
KNOWN CONTEXT (stack trace, when it happens, what changed recently, how often):
{{CONTEXT}}
HOW TO RUN THE PROJECT / TESTS:
{{RUN_COMMAND}}
=== PHASE 1: REPRODUCE ===
- First, reproduce the bug reliably. Determine the exact steps, inputs, or command that triggers it.
- If you can, write a failing automated test (or a minimal script/command) that demonstrates the bug. Run it and SHOW the actual failing output.
- If you genuinely cannot reproduce it, STOP and tell me precisely what information or access you are missing. Do not guess at a fix for a bug you cannot trigger.
=== PHASE 2: ISOLATE (root cause) ===
- Narrow down where the defect actually lives. Read the relevant code paths; trace the data/flow from the trigger to the failure. Minimize the reproduction to the smallest case that still fails.
- State the ROOT CAUSE in plain language: the specific line(s)/logic responsible and WHY it produces the observed behavior. Distinguish the root cause from the symptom.
- If recent changes are suspected, inspect the relevant history. List 1-3 candidate causes ranked by likelihood, then commit to the most likely one with your reasoning. If you are uncertain, say so rather than asserting.
- Heavy read-only investigation (searching, reading many files, tracing) is a good place to delegate to a read-only Explore subagent so it doesn't bloat this conversation — but the root-cause conclusion must come back here.
=== PHASE 3: FIX ===
- Make the SMALLEST change that fixes the root cause. Do not refactor unrelated code, do not 'improve' things nearby, do not widen scope. If you spot other issues, note them separately at the end — don't fix them now.
- Explain in one or two lines why this change addresses the root cause identified in Phase 2.
=== PHASE 4: VERIFY ===
- Run the failing test/repro from Phase 1 and SHOW it now passes.
- Run the FULL test suite (not just the one test) via {{RUN_COMMAND}} and SHOW the output, to prove you didn't break anything else.
- Keep the regression test in place permanently — it documents the bug and prevents it from coming back. Confirm it is committed alongside the fix.
Output discipline:
- Always paste REAL command output, never 'it passes now'. If a command can't be run in this environment, say so explicitly.
- End with a short summary: root cause (1 line), the fix (1 line), the regression test added, and any unrelated issues you noticed but deliberately did NOT touch.
- Do not declare the bug fixed unless Phase 1's repro passes AND the full suite is green.這組 prompt 專為 Claude Code 設計。把 prompt 內 3 個方括號 [變數] 換成你自己的內容,貼進 Claude Code 執行即可。難度中等,照變數說明填好後即可上手。
完整 prompt 免費開放閱讀,不用註冊;登入後可一鍵複製、收藏與留言。
prompt 文字本身你可自由使用與修改。但 AI 生成物(圖/音樂/影片/文字)的商用授權,取決於你在 Claude Code 使用的方案與其官方服務條款,請以該工具的授權規範為準。
Studio engineer 視角拆解 Suno 致命弱點(油炸 vocals、高頻 artifact)+ 4 步驟 DAW workflow + Suno Studio 修音 prompt
提案產生器 / 會議處理器 / 內容再利用 / 週五回顧 / 收工 reset — 試了 40 個只有這 5 個沒被丟掉、各省 30+ 分鐘 / 次。
適合:部落格、Medium、Notion 公開頁、Substack — 任何支援 iframe / HTML 嵌入的地方。對方點「看完整」會回到本站、是 prompt 庫的免費 backlink。
<iframe src="https://prompt.luvai.net/embed/claude-code-bug-repro-isolate-fix-verify" width="100%" height="380" frameborder="0" style="border:1px solid #e0dcd0;border-radius:4px;" loading="lazy" title="PromptCraft Embed"></iframe>
You are fixing a bug. Follow this four-phase loop strictly: REPRODUCE → ISOLATE → FIX → VERIFY. The rule is: no fix without a failing test first, and the fix must be the narrowest change that addresses the ROOT CAUSE, not the symptom.
BUG REPORT:
{{BUG_REPORT}}
KNOWN CONTEXT (stack trace, when it happens, what changed recently, how often):
{{CONTEXT}}
HOW TO RUN THE PROJECT / TESTS:
{{RUN_COMMAND}}
=== PHASE 1: REPRODUCE ===
- First, reproduce the bug reliably. Determine the exact steps, inputs, or command that triggers it.
- If you can, write a failing automated test (or a minimal script/command) that demonstrates the bug. Run it and SHOW the actual failing output.
- If you genuinely cannot reproduce it, STOP and tell me precisely what information or access you are missing. Do not guess at a fix for a bug you cannot trigger.
=== PHASE 2: ISOLATE (root cause) ===
- Narrow down where the defect actually lives. Read the relevant code paths; trace the data/flow from the trigger to the failure. Minimize the reproduction to the smallest case that still fails.
- State the ROOT CAUSE in plain language: the specific line(s)/logic responsible and WHY it produces the observed behavior. Distinguish the root cause from the symptom.
- If recent changes are suspected, inspect the relevant history. List 1-3 candidate causes ranked by likelihood, then commit to the most likely one with your reasoning. If you are uncertain, say so rather than asserting.
- Heavy read-only investigation (searching, reading many files, tracing) is a good place to delegate to a read-only Explore subagent so it doesn't bloat this conversation — but the root-cause conclusion must come back here.
=== PHASE 3: FIX ===
- Make the SMALLEST change that fixes the root cause. Do not refactor unrelated code, do not 'improve' things nearby, do not widen scope. If you spot other issues, note them separately at the end — don't fix them now.
- Explain in one or two lines why this change addresses the root cause identified in Phase 2.
=== PHASE 4: VERIFY ===
- Run the failing test/repro from Phase 1 and SHOW it now passes.
- Run the FULL test suite (not just the one test) via {{RUN_COMMAND}} and SHOW the output, to prove you didn't break anything else.
- Keep the regression test in place permanently — it documents the bug and prevents it from coming back. Confirm it is committed alongside the fix.
Output discipline:
- Always paste REAL command output, never 'it passes now'. If a command can't be run in this environment, say so explicitly.
- End with a short summary: root cause (1 line), the fix (1 line), the regression test added, and any unrelated issues you noticed but deliberately did NOT touch.
- Do not declare the bug fixed unless Phase 1's repro passes AND the full suite is green.把方括號 [ ] 內的變數換成你的內容,丟進 Claude Code。
六個月在 Claude / GPT-4 / Gemini 上用人工 rater A/B 測 200+ prompt 後寫的。包含 persona+constraint stacking / anti-example / role reversal QA / cognitive scaffold / emotional priming / uncertainty CoT / steelman first。
一年的 role-play system prompt + 14-step framework 後總結:真正改變品質的是 5 個單行 prompt。沒有 role、沒有 markdown、沒有「you are an expert」。