Slash Commands
基於 Cursor 官方 Slash Commands 參考解釋 /plan、/ask、/model、/auto-run、/sandbox、/mcp、/rules、/commands、/compress 等會話內命令。
Slash commands 是 Cursor CLI 會話裡的控制面板。它們不負責“寫程式碼”,而是負責切模式、調許可權、管理上下文、檢視環境和退出會話。
閱讀目標:讀完本章,你應該能把 slash commands 分成模式類、許可權類、上下文類、MCP 類和會話管理類,並知道哪些命令適合團隊 SOP。
1. 模式類命令
| Command | 用途 |
|---|---|
/plan | 切到 Plan mode,先設計方案再編碼 |
/ask | 切到 Ask mode,只讀探索 |
/model <model> | 設定或列出模型 |
| `/max-mode [on | off]` |
典型用法:
/ask
Explain how billing events are stored. Do not edit files.
/plan
Design a safe migration plan for the webhook handler.團隊培訓時,把 /ask 和 /plan 放在最前面。新手最大的問題通常不是不會讓 Agent 改程式碼,而是太早讓它改。
2. 許可權和執行類命令
| Command | 用途 |
|---|---|
/auto-run [state] | 開關或檢視 auto-run,支援 on、off、status |
/sandbox | 配置 sandbox mode 和 network access |
/mcp list | 瀏覽、啟用、配置 MCP servers |
/mcp enable <name> | 啟用某個 MCP server |
/mcp disable <name> | 停用某個 MCP server |
商業級預設值:
- 初次進入陌生儲存庫,先關 auto-run 或保持審批。
- 不清楚命令風險時,不放寬 sandbox。
- 只啟用當前任務需要的 MCP server。
- 每次啟用外部 MCP,都說明它能讀寫什麼。
3. 上下文和規則類命令
| Command | 用途 |
|---|---|
/rules | 建立或編輯 rules |
/commands | 建立或編輯 commands |
/compress | 壓縮對話,釋放 context |
/compress 適合長會話中段,但壓縮前要把關鍵約束寫清楚:目標、禁止動作、已改檔案、待驗證命令、未解決問題。
Before compressing, summarize:
1. What has changed.
2. Files touched.
3. Tests already run.
4. Remaining risks./rules 和 /commands 是專案能力沉澱入口。頻繁重複的約束應該寫進 rules;頻繁重複的操作才適合做 commands。
4. 會話管理類命令
| Command | 用途 |
|---|---|
/new-chat | 開啟新會話 |
/resume <chat> | 按 folder name 恢復舊會話 |
/usage | 檢視 Cursor streaks 和 usage stats |
/about | 顯示環境和 CLI 設定 |
/help [command] | 檢視幫助 |
/feedback <message> | 給 Cursor team 反饋 |
/copy-request-id | 複製最近 request ID |
/copy-conversation-id | 複製 conversation ID |
/logout | 退出登入 |
/quit | 退出 CLI |
/vim | 開關 Vim keys |
/setup-terminal | 自動配置 terminal keybindings |
排障時優先用 /about、/copy-request-id 和 /copy-conversation-id。這三類資訊能把“感覺卡住了”變成可定位的問題。
5. 常用組合
只讀調研:
/ask
@src/auth @tests/auth
Explain the login flow and list risky assumptions.先計劃再執行:
/plan
Plan a minimal fix for the checkout flaky test.
Do not edit files until the plan is accepted.長會話壓縮前:
/compress壓縮後第一條訊息建議補充:
Continue from the compressed summary.
Before editing, restate remaining files, tests, and blockers.MCP 臨時關閉:
/mcp list
/mcp disable server-name6. 風險邊界
| 命令 | 風險 |
|---|---|
/auto-run on | 可能減少命令審批,陌生專案不建議預設開啟 |
/sandbox | 放寬後可能擴大 shell 和網路風險 |
/mcp enable | 外部工具可能讀寫專案或遠端系統 |
/model | 模型變化會影響成本、速度和能力邊界 |
/compress | 壓縮可能丟掉細節,壓縮前要固化關鍵約束 |
/logout | 會影響後續 CLI 認證和 CI 排查 |
Slash commands 是控制權,不是裝飾命令。每一次改變許可權、模型、MCP 或上下文,都要能解釋為什麼。
深讀:什麼時候應該開新會話
當任務目標、程式碼區域或決策上下文已經明顯變化時,開新會話比繼續壓縮舊會話更穩。舊會話裡殘留的約束可能讓 Agent 誤以為還在處理上一件事。
如果只是同一任務的後續驗證,用 /compress 保留主線即可。
本章自檢
完成本章後,用這 3 個問題檢查自己是否真正理解:
/ask和/plan分別應該在什麼階段使用?/compress前為什麼要先整理已改檔案和待驗證命令?- 啟用 MCP server 前應該確認哪些許可權邊界?
透過標準:你能為團隊寫一頁 CLI slash command SOP,明確哪些命令可預設使用,哪些命令需要說明理由。
官方來源
- Cursor Slash Commands —— 官方 slash command 列表。
- Terminal Setup —— 官方 terminal keybindings 配置。
- Cursor MCP —— 官方 MCP 背景與配置。