強制 Codex 走「先寫出能重現 bug 的失敗測試 → 找根因 → 最小修改 → 同一測試由紅轉綠 → 跑完整測試確認沒回歸」的閉環,杜絕『改了但沒驗證』與『順手亂改一堆』。
Fix this bug using a strict reproduce-first, verify-after loop. Do not skip steps. Do not claim it's fixed without showing a passing test run.
## The bug
{{BUG_DESCRIPTION}}
Expected behavior: {{EXPECTED}}
Actual behavior: {{ACTUAL}}
How to trigger (if known): {{REPRO_STEPS}}
## Loop you MUST follow
**1. Reproduce FIRST (red).** Before changing any production code, write or identify a test that fails *because of this bug*. Run it and paste the real failing output. If you genuinely cannot write an automated test (e.g. it needs a live external service), say so explicitly and instead give the exact manual command + observed wrong output that demonstrates the bug. A bug you can't reproduce is not yet understood — keep investigating until you can.
**2. Find the root cause.** Trace from the failing symptom back to the line(s) responsible. State the root cause in 1-2 sentences: *what* is wrong and *why* it produces the observed behavior. Do not pattern-match a fix onto the symptom — explain the mechanism. If there are multiple plausible causes, name them and say how you ruled the others out.
**3. Apply the MINIMAL fix.** Change only what's needed to fix the root cause. No drive-by refactors, no reformatting unrelated lines, no renaming. If you spot adjacent issues, list them at the end as 'noticed but not changed' — do not fold them into this fix.
**4. Verify (green).** Re-run the SAME test from step 1 and paste the now-passing output. Then run the broader suite (`{{TEST_COMMAND}}`) and paste the result to prove no regression. If the suite was already partially failing before your change, note which failures are pre-existing and unrelated.
**5. Report.** Summarize: root cause, the one-line essence of the fix, files touched, and the verification command anyone can re-run.
## Hard rules
- Steps 1 and 4 MUST include actual command output, not a description of what you expect to happen. 'Should pass now' is not acceptable — run it.
- If after a reasonable effort you cannot reproduce, STOP and report what you tried and what info you need, rather than guessing at a fix.
- Keep the diff small and reviewable. The test added in step 1 stays in the codebase as a regression guard.
- Respect existing project conventions (read AGENTS.md / CLAUDE.md if present for the right test command and style).
不用離開網站,直接看這組 prompt 跑出來長怎樣(AI 即時生成,扣 1 點)。
不只複製貼上 — 下載後放到 ~/.claude/skills/bug-reproduce-fix-verify-loop/SKILL.md,之後每個 session 自動可用(觸發時自動載入)。
mkdir -p ~/.claude/skills/bug-reproduce-fix-verify-loop && mv ~/Downloads/SKILL.md ~/.claude/skills/bug-reproduce-fix-verify-loop/SKILL.mdNew-Item -ItemType Directory -Force "$env:USERPROFILE\.claude\skills\bug-reproduce-fix-verify-loop" | Out-Null; Move-Item "$env:USERPROFILE\Downloads\SKILL.md" "$env:USERPROFILE\.claude\skills\bug-reproduce-fix-verify-loop\SKILL.md"何時用:任何『有人回報的 bug』或你自己撞到的錯。為何有效:AI 修 bug 最大的兩個病是『沒重現就猜著改』和『說改好了卻沒跑』。這個 prompt 用 TDD 的紅→綠把它鎖死:步驟 1 先要一個失敗測試(重現=理解),步驟 4 要同一測試轉綠+全套不回歸,且兩步都強制貼真實輸出。技巧:在 Codex CLI 用 `codex exec` 讓它自動跑測試迭代(workspace-write 沙箱下它能反覆 run test 直到綠);{{TEST_COMMAND}} 填你的專案指令(npm test / pytest / go test ./...)。重現不出來時它會停下問你、而不是亂改——這正是你要的。
1. Reproduce (red): $ pytest tests/test_dates.py::test_month_rollover -q FAILED — assert parse('2026-01-31' + 1mo) == '2026-02-28', got ValueError: day is out of range 2. Root cause: add_months() 直接把 month+1 後沿用原 day(31),2 月無 31 日故 datetime 拋錯。應 clamp 到當月最後一天。 3. Fix: src/dates.py add_months() 加 day = min(day, last_day_of(year, month)) 4. Verify (green): $ pytest tests/test_dates.py::test_month_rollover -q 1 passed $ pytest -q 214 passed, 0 failed Report: 根因=月份進位未夾日;修 1 檔 1 函式;回歸測試已留存於 test_month_rollover。
以上為此 Prompt 丟進 Claude Code / Codex 後可得到的描述性成果,實際畫面會因填入的變數而有差異。
[BUG_DESCRIPTION]bug 的描述(症狀、出現在哪個功能/頁面)
[EXPECTED]預期的正確行為
[ACTUAL]實際發生的錯誤行為(含錯誤訊息/stack trace 若有)
[REPRO_STEPS]已知的重現步驟;不知道就填「未知」讓它自己找
[TEST_COMMAND]跑完整測試套件的指令,如 npm test、pytest -q、go test ./...
填下面的欄位,上方 prompt 會即時替換 [方括號] 內容。填好後按「複製組好的 prompt」直接丟進工具。
Fix this bug using a strict reproduce-first, verify-after loop. Do not skip steps. Do not claim it's fixed without showing a passing test run.
## The bug
{{BUG_DESCRIPTION}}
Expected behavior: {{EXPECTED}}
Actual behavior: {{ACTUAL}}
How to trigger (if known): {{REPRO_STEPS}}
## Loop you MUST follow
**1. Reproduce FIRST (red).** Before changing any production code, write or identify a test that fails *because of this bug*. Run it and paste the real failing output. If you genuinely cannot write an automated test (e.g. it needs a live external service), say so explicitly and instead give the exact manual command + observed wrong output that demonstrates the bug. A bug you can't reproduce is not yet understood — keep investigating until you can.
**2. Find the root cause.** Trace from the failing symptom back to the line(s) responsible. State the root cause in 1-2 sentences: *what* is wrong and *why* it produces the observed behavior. Do not pattern-match a fix onto the symptom — explain the mechanism. If there are multiple plausible causes, name them and say how you ruled the others out.
**3. Apply the MINIMAL fix.** Change only what's needed to fix the root cause. No drive-by refactors, no reformatting unrelated lines, no renaming. If you spot adjacent issues, list them at the end as 'noticed but not changed' — do not fold them into this fix.
**4. Verify (green).** Re-run the SAME test from step 1 and paste the now-passing output. Then run the broader suite (`{{TEST_COMMAND}}`) and paste the result to prove no regression. If the suite was already partially failing before your change, note which failures are pre-existing and unrelated.
**5. Report.** Summarize: root cause, the one-line essence of the fix, files touched, and the verification command anyone can re-run.
## Hard rules
- Steps 1 and 4 MUST include actual command output, not a description of what you expect to happen. 'Should pass now' is not acceptable — run it.
- If after a reasonable effort you cannot reproduce, STOP and report what you tried and what info you need, rather than guessing at a fix.
- Keep the diff small and reviewable. The test added in step 1 stays in the codebase as a regression guard.
- Respect existing project conventions (read AGENTS.md / CLAUDE.md if present for the right test command and style).
這組 prompt 專為 Claude Code / Codex 設計。把 prompt 內 5 個方括號 [變數] 換成你自己的內容,貼進 Claude Code / Codex 執行即可。難度中等,照變數說明填好後即可上手。
完整 prompt 免費開放閱讀,不用註冊;登入後可一鍵複製、收藏與留言。
prompt 文字本身你可自由使用與修改。但 AI 生成物(圖/音樂/影片/文字)的商用授權,取決於你在 Claude Code / Codex 使用的方案與其官方服務條款,請以該工具的授權規範為準。
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/codex-bug-reproduce-fix-verify-loop" width="100%" height="380" frameborder="0" style="border:1px solid #e0dcd0;border-radius:4px;" loading="lazy" title="PromptCraft Embed"></iframe>
把方括號 [ ] 內的變數換成你的內容,丟進 Claude Code / Codex。
六個月在 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」。