概述
Slash Commands 是 OpenClaw Gateway 处理的聊天命令系统,以 / 开头作为独立消息发送。分为三类:Commands(独立命令)、Directives(内联指令,影响模型行为)、Inline shortcuts(内联快捷方式)。命令路由由 Gateway 处理,ACP 会话绑定后普通文本路由到 ACP harness,但 /acp、/status、/unfocus 等管理命令始终保持本地处理。
核心功能
- Commands:独立
/...消息,涵盖会话管理、模型控制、发现状态、Skills、子 Agent、ACP、Owner 管理等 - Directives:
/think、/fast、/verbose、/trace、/reasoning、/elevated、/exec、/model、/queue,在消息发送前被剥离,仅对授权发送者生效 - Inline shortcuts:
/help、/commands、/status、/whoami,可嵌入普通消息中立即执行 - Native commands:Discord/Telegram 支持原生命令注册(
commands.native: "auto"),Slack 需手动创建 - Skill commands:
user-invocableSkills 自动暴露为 slash command,/skill <name>作为通用入口 - Dock commands:生成的跨 channel 会话路由命令(
/dock-discord、/dock-telegram等) - Fast path:白名单发送者的纯命令消息绕过队列和模型直接处理
配置/使用
关键配置项
{
commands: {
native: "auto", // Discord/Telegram 原生命令注册
nativeSkills: "auto", // Skill 命令原生注册
text: true, // 文本命令解析
bash: false, // ! <cmd> 主机 shell 命令
config: false, // /config 读写 openclaw.json
mcp: false, // /mcp 读写 MCP 配置
plugins: false, // /plugins 插件管理
debug: false, // /debug 运行时覆盖
restart: true, // /restart 重启 Gateway
ownerAllowFrom: [], // Owner 专属命令白名单
allowFrom: {}, // 命令授权白名单(按 provider)
useAccessGroups: true, // 使用 channel 白名单授权
},
}常用命令速查
| 类别 | 命令 | 说明 |
|---|---|---|
| 会话 | /new [model] | 新建 session |
| 会话 | /reset | 重置 session |
| 会话 | /compact | 压缩上下文 |
| 会话 | /stop | 中止当前 run |
| 模型 | /model [name] | 查看/切换模型 |
| 模型 | /think <level> | 设置思考级别 |
| 模型 | /queue <mode> | 管理队列模式 |
| 状态 | /status | 运行时状态 |
| 状态 | /tools | 当前可用工具 |
| Skills | /skill <name> | 运行指定 Skill |
| 子 Agent | /subagents list | 列出子 Agent |
| ACP | /acp spawn | 启动 ACP session |
| Owner | /config set | 写入配置(需 commands.config: true) |
| Owner | /plugins enable | 启用插件(需 commands.plugins: true) |
| 侧边 | /btw <question> | 侧边问题,不污染 session |
/tools 命令
运行时查询当前 Agent 实际可用工具,结果按 session 作用域(agent/channel/thread/sender/model 变化均影响输出)。
/debug 运行时覆盖
仅内存生效,不写磁盘,/debug reset 清除所有覆盖:
/debug set messages.responsePrefix="[openclaw]"
/debug unset messages.responsePrefix
/debug reset
相关页面
- concepts/tool-skills — Skill slash command 注册机制
- concepts/tool-plugin — 插件可注册额外 slash command
- queue —
/queue命令控制的队列模式 - concepts/tool-acp-agents —
/acp命令管理的 ACP session - concepts/tool-btw —
/btw侧边问题详细行为