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 背景与配置。