| name | dual-audit |
| description | 雙 AI 全倉庫 bug audit。用 /loop 自動分批掃描每個原始碼檔,每批由 code-reviewer subagent + Codex (codex:codex-rescue) 兩邊獨立審查並比對findings,駁回 false positive、保留兩邊都認可的 bug。適用全專案 deep bug sweep。 |
Dual-Audit Skill
雙 AI 自動化全倉庫 bug 審查。Claude 的 code-reviewer subagent + OpenAI Codex 平行審查,交叉比對找出真 bug、駁回 false positive。
何時使用
- 需要對整個倉庫做 deep bug audit
- 想要兩邊獨立審查的 second opinion 機制
- 「掃過每一個檔案找 bug」這類大範圍任務
前置條件
- Codex plugin 已裝(
/codex:setup 顯示 ready: true)
- 倉庫有
memory/ 目錄可寫入進度
- 已
cd 到目標倉庫(或 prompt 內帶絕對路徑)
執行流程
Step 1:初始化
第一次呼叫時:
-
盤點檔案:
find <repo>/src -type f \( -name "*.js" -o -name "*.jsx" -o -name "*.ts" -o -name "*.tsx" \) | grep -v "/test/" | sort > /tmp/audit_files.txt
-
建立 progress tracker <repo>/memory/audit_progress.md:
- 標記「Skip」清單:已知不需審的(_deprecated/、main entry、constants-only)
- 切 batches:每批 5 個檔(最後一批可 7)
- 列出
[ ] 待辦項
-
驗證 Codex 就緒:
node "/Users/aes/.claude/plugins/cache/openai-codex/codex/<ver>/scripts/codex-companion.mjs" setup --json
若 ready: false,停下來提示使用者 /codex:setup。
Step 2:每批執行(用 /loop dynamic mode)
把整個 audit 任務交給 /loop(無 interval,self-pace)。每次喚醒做 ONE batch:
-
派 Claude code-reviewer agent(透過 Agent tool):
- 給該 batch 的 5 個絕對路徑
- 要求實際讀檔、不只看檔名
- 強調「避免 false positive — 看到 hardcoded ID/key 要 grep 確認語意」
- 列出已知 false positive pattern(避免重複犯錯)
-
派 Codex agent(透過 Agent tool with subagent_type: "codex:codex-rescue"):
- 同一批檔案
- 要求驗證或駁回 Claude agent 的 findings
- 額外做獨立掃描找漏網
-
交叉比對:
- 兩邊都標 → confirmed bug
- 只一邊標 → 待驗證或 false positive 候選
- Claude 驗證關鍵 claims(特別是 Critical),讀實際檔案確認
- 駁回明顯誤判(記下 false positive 紀錄)
-
寫回 progress:
- 更新 batch 為
[x] 並列出 confirmed bug
- false positive 區塊獨立列出
-
ScheduleWakeup 600s(10 分鐘)排下一輪:
prompt: 完整原 /loop input verbatim
delaySeconds: 600
reason: "繼續 audit batch N+1"
Step 3:多輪掃描
跑完一輪所有 batch 後,繼續排下一輪(不要停),focus 切換:
- Round 1:通用 bug
- Round 2:邊界 / NaN / error path
- Round 3:跨檔契約一致性 / caller-callee 假設
- Round 4:concurrency / state mutation timing / async race 細節
每輪前先讀 audit_progress.md,把已抓過的 bug 列在 prompt 「不要重複」清單裡,agent 才不會重複報相同議題。
Step 4:收尾 + 集中修補
所有輪都跑完才停:
- 不再 ScheduleWakeup(loop 自然停止)
- 產生最終摘要 寫到
audit_progress.md 結尾:
- 真 Critical 列表(按嚴重度排序)
- Important 列表(節錄)
- false positive 紀錄
- 統計:總檔數 / Critical / Important / Minor / False positive
- 系統性 pattern(如 NaN 傳播、async race)獨立列出
- 集中修補:把 confirmed bug 一次修完(不是邊掃邊修)
- Codex 審查 fix:修完後派
codex:codex-rescue 對 diff 做獨立 second-opinion,確認 fix 真的解到問題且沒引入回歸
- 驗證:
npm test + npm run build + 任何特定 verifier
- commit + push:commit message 標 audit/codex 雙確認
重要 anti-patterns(避免重複犯錯)
每個專案各有領域 false positive。Audit 開始前先列出:
'me' 在某些 codebase 是合法 self-id,不是 hardcoded bug
- 台灣民法 1223 條第 3、4 順位特留分本來就是 1/3(不是 1/2)
- 設計選擇(如 hard delete、無 export、無 RBAC)不是 bug
- pre-existing 議題(如 localStorage quota)若已知接受不重複報
每次新專案要 prompt 內補充該專案的 anti-patterns,agent 才不會誤判。
何時停止 loop
- 所有 batch 跑完(progress 全
[x])
- 使用者主動要求停(不再排 ScheduleWakeup)
- Codex 一直 unauthenticated / 連續失敗(先停下提示
/codex:setup)
不適用情境
- 單檔審查 → 直接用
/code-review skill 或單派 code-reviewer agent
- 純 PR diff 審查 → 用內建
/review
- 安全專項審查 → 用內建
/security-review
Output 範例
Batch 5 done — 找到第一個真 Critical:
🔴 taxConfig.js:20 — 2026 deduction 應為 843.15 而非 842.15
2 Important(dual-write syncError 沒讀 / CustomerDrawer journal delete race)
1 Minor
下一批 600s 後。
最終摘要範例見 memory/audit_progress.md 的「全部 X batches 完成」段。