Codex bug 修復閉環:先重現再修,附可重跑的驗證
強制 Codex 走「先寫出能重現 bug 的失敗測試 → 找根因 → 最小修改 → 同一測試由紅轉綠 → 跑完整測試確認沒回歸」的閉環,杜絕『改了但沒驗證』與『順手亂改一堆』。
禁止『我覺得這樣應該就好了』。先寫一個會失敗的測試重現 bug,再修,再讓那個測試由紅轉綠+跑全套確認沒回歸。每一步都貼真實 terminal 輸出,看得到綠燈才算完成。
[ Log in to see the full prompt ]Sign up free to see the full prompt, copy it, save it, and join the discussion. Free content unlocks on login; Pro content is a separate subscription.
何時用:任何『有人回報的 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。
Suno Engineer's Mindset: 4 Steps to a Song That Doesn't Sound Like AI
A studio engineer's breakdown of Suno's fatal weaknesses (fried vocals, high-frequency artifacts), plus a 4-step DAW workflow and a Suno Studio cleanup prompt.
5 Claude Weekly Workflows That Stuck After 6 Months
Proposal generator / meeting processor / content repurposer / Friday review / shutdown reset — out of 40 I tried, only these 5 survived, each saving 30+ minutes per run.