唯讀模式做 Code Review
CatDesk 的 multi-tools 模式暴露 10 個工具,包括 write、delete、run_command。審查隊友的 PR 時,這些能力不是助力而是風險:你只是想讓它看程式碼,不需要它能改任何東西。
CatDesk 為此提供第二種工具模式:read-only,只暴露 3 個工具。這篇範例用它安全地審完一個 PR。
情境
隊友開了一個修改退貨邏輯的 PR,你要審查。你的習慣是讓 AI 先過一遍找出問題,再自己看細節。但最近聽過太多「AI 順手把檔案改了」的故事,你希望這場對話從工具層面就沒有寫入能力。
目標
在唯讀模式下完成 PR 審查:對話只能讀與搜,write、edit、delete、run_command、start_command、poll_command、cancel_command 全部不會暴露給 ChatGPT。
步驟一:切換工具模式
在 CatDesk 的 TUI 把工具模式從 multi-tools 切到 read-only。read-only 只暴露 3 個工具,全部是讀取與指引性質:
1. catdesk_instruction // usage guide + AGENTS.md loading
2. read // read one or more files
3. search // rg / grep / built-in search
切完別急著回到舊對話。README 的提示講得很明白:改了 MCP 相關設定(工具模式或 widget 開關)之後,要開新對話並在 ChatGPT 設定裡重新整理 CatDesk;最保險的做法是移除再重裝連接器。
步驟二:給 ChatGPT 的 prompt
I'm reviewing PR #142 (refund logic changes). Here is the diff:
--- a/src/refunds/service.ts
+++ b/src/refunds/service.ts
@@ -40,7 +40,9 @@
- if (order.status !== "paid") return reject();
+ if (order.status !== "paid" && order.status !== "processing")
+ return reject();
@@ -58,6 +60,7 @@
+ await notification.send(user, refund);
Review it. Read the full files and any callers involved, check the
logic against the rest of the codebase, and list concrete issues.
You are in read-only mode: analysis only, no edits.
CatDesk 工具呼叫序列
1. catdesk_instruction
2. read(paths: ["src/refunds/service.ts"])
3. search(pattern: "status === \"processing\"")
4. search(pattern: "notification.send")
5. read(paths: ["src/notifications/sender.ts", "tests/refunds.test.ts"])
ChatGPT 找出什麼
唯讀並不妨礙審查深度,反而不吵雜。ChatGPT 回報兩個實際問題:
processing狀態的訂單現在一定會進入退貨流程,但search全工作區只有這個 PR 動過這個判斷,其他地方仍假設processing不可退貨,狀態機可能被繞過。notification.send是 fire-and-forget 嗎?讀了sender.ts確認它會丟例外,放在這裡會讓退貨成功卻回傳失敗。
因為沒有寫入工具,它把修改建議寫成文字讓你貼回 PR,而不是自己動手。這正是你要的行為。
結果與重點
兩個問題都以具體行號與證據回報,審查完成,你的工作區一個位元都沒被改動。
三個重點帶走:
- read-only 模式從工具層面移除寫入與 shell,是審查、安全分析、讀懂陌生程式碼的正確模式。
- 切換工具模式後要開新對話、重新整理連接器,舊對話的設定不會自動跟上。
- 想更進一步降低風險,連接器權限也能設成 Allow read actions,和唯讀工具模式是兩層各自獨立的閘門。