跳转至

CLI 参考

openclaw 是主要的 CLI 入口点。每个核心命令都有专属参考页面,或由它所别名的命令一并记录。本索引列出了适用于整个 CLI 的命令、全局标志和输出样式规则。

按意图分类的设置命令:

  • openclaw setup 和 openclaw onboard 首先验证推理,然后启动 OpenClaw 进行网关、工作区、频道、技能和健康设置。
  • openclaw setup --baseline 创建基线配置和工作区,而无需走完引导式入门流程。
  • openclaw configure 修改现有设置中的特定部分:模型认证、网关、频道、插件或技能。
  • openclaw channels add 在基线存在后配置频道账户。仅选择频道时使用引导式设置。账户、凭据或频道配置标志则使用适合脚本的直接路径。

命令页面

区域 命令
设置与入门 openclaw · setup · onboard · configure · config · completion · doctor · dashboard
重置、备份与迁移 backup · database · migrate · reset · uninstall · update
消息与代理 message · agent · agents · claws · attach · acp · mcp
健康与会话 status · health · triage · sessions · resume · audit
网关与日志 fleet · gateway · logs · system
模型与推理 models · promos · infer · capability (alias for infer) · memory · wiki
网络与节点 connect · directory · nodes · node · worker
运行时与沙箱 approvals · exec-policy (see approvals) · sandbox · tui · chat/terminal (aliases for tui --local) · browser
工作树 worktrees
自动化 cron (alias automations) · hooks · webhooks · transcripts
发现与文档 dns · docs
配对与频道 pairing · qr · devices · channels · users
安全与插件 security · secrets · skills · plugins · proxy
遗留别名 daemon (gateway service) · clawbot (namespace)
插件(可选) file-transfer · path · policy · voicecall · workboard (if installed)

全局标志

标志 用途
--dev 将状态隔离到 ~/.openclaw-dev 下,默认网关端口 19001,并偏移派生端口
--profile <name> 将状态隔离到 ~/.openclaw-<name> 下(OPENCLAW_STATE_DIR/OPENCLAW_CONFIG_PATH)
--container <name> 在名为 <name> 的运行中的 Podman/Docker 容器内运行 CLI(默认:环境变量 OPENCLAW_CONTAINER)
--log-level <level> 覆盖文件和控制台输出的全局日志级别
--no-color 禁用 ANSI 颜色(同时支持 NO_COLOR=1)
--update 是 openclaw update 的简写;适用于源码检出和软件包安装
-V, --version, -v 输出版本号并退出

将命令特定的选项放在命令名称之后,例如 openclaw status --json。全局选项(如 --profile)可以放在命令之前。

未知的根选项会以选项错误和帮助提示的方式失败,而不会启动引导流程或 TUI。

具名的 --profile 会替换从另一个 profile 继承的规范状态和配置路径,包括正在运行的 Gateway 服务。显式自定义的状态目录和配置路径保持不变。

使用 -- 停止选项解析。命令词在其后仍会分派:例如 openclaw -- config get gateway.port 读取已配置的端口。-- 之后的 --help 之类的标记是位置参数。

输出模式

  • ANSI 颜色和进度指示器仅在 TTY 会话中渲染。
  • OSC-8 超链接在支持的情况下渲染为可点击链接。否则,CLI 会打印普通 URL。
  • 在受限的报告命令上,--json 会将 stdout 保留给一个 JSON 文档。CLI 会抑制样式和进度输出。警告和诊断信息保留在 stderr 中。
  • 交互式 UI 和向导、长时间运行的服务器和流、Shell 集成以及纯副作用命令在无有意义报告可返回时,可以省略 --json。
  • 长时间运行的命令会显示进度指示器(支持时使用 OSC 9;4)。

JSON 失败

成功的 JSON 负载保持命令特定。当处于 JSON 输出模式的命令失败时,它会以非零状态退出,并向 stdout 写入一个带有如下信封的 JSON 文档:

{
  "ok": false,
  "error": {
    "type": "cli_error",
    "message": "Description of the failure"
  }
}

命令可以在此信封之外添加领域特定字段,例如逐项结果。由 Gateway 支持的 agent 轮次在 Gateway 接受运行后失败时,也会在信封之外记录已接受的 runId 和 origin: "gateway",以便脚本报告进行中的运行。失败消息会经过清理。人类可读的诊断信息也可能写入 stderr,因此脚本应解析 stdout,并且仍然检查退出状态。

颜色调色板

OpenClaw 在 CLI 输出中使用 lobster 调色板:

Token Hex 用途
accent #FF5A2D 标题、标签、主要高亮
accentBright #FF7A3D 命令名称、强调
accentDim #D14A22 次要高亮文本
info #FF8A5B 信息性值
success #2FBF71 成功状态
warn #FFB020 警告、选项标志、回退
error #E23D2D 错误、失败
muted #8B7F77 弱化、元数据

调色板的权威来源:packages/terminal-core/src/palette.ts。

命令树

完整命令树

此图涵盖核心命令及其主要子命令。插件添加的子命令(例如 skills、plugins 和 wiki 下的子命令)会独立演进。运行 <command> --help 获取权威的最新列表。

openclaw [--dev] [--profile <name>] <command>
  openclaw
  setup
  onboard
  configure
  config
    get
    set
    patch
    unset
    file
    schema
    validate
  database
    preflight
    ownership
      status
      claim
  completion
  doctor
  triage
  dashboard
  backup
    create
    verify
    restore
    sqlite
      create
      list
      verify
      restore
    git
      init
      create
      log
      verify
      restore
    enable
    disable
  migrate
    list
    plan <provider>
    apply <provider>
  security
    audit
  secrets
    reload
    store
    audit
    configure
    apply
  reset
  uninstall
  update
    wizard
    status
    repair
  channels
    list
    status
    capabilities
    resolve
    logs
    dead-letters list|resubmit
    add
    remove
    login
    logout
  directory
    self
    peers list
    groups list|members
  skills
    search
    install
    update
    verify
    workshop list|inspect|propose-create|propose-update|revise|apply|reject|quarantine
    list
    info
    check
  plugins
    list
    search
    inspect
    install
    uninstall
    update
    enable
    disable
    doctor
    build
    validate
    pack
    init
    registry
    marketplace list|entries|refresh
  workboard
    list
    create
    show
    dispatch
  memory
    status
    index
    search
  transcripts
    list
    show
    path
  path
    resolve
    find
    set
    validate
    emit
  wiki
    status
    doctor
    init
    compile
    lint
    ingest
    okf import
    search
    get
    apply synthesis|metadata
    bridge import
    unsafe-local import
    chatgpt import|rollback
    obsidian status|search|open|command|daily
  message
    send
    broadcast
    poll
    react
    reactions
    read
    edit
    delete
    pin
    unpin
    pins
    permissions
    search
    thread create|list|reply
    emoji list|upload
    sticker send|upload
    role info|add|remove
    channel info|list
    member info
    voice status
    event list|create
    timeout
    kick
    ban
  agent
  agents
    list
    add
    delete
    bindings
    bind
    unbind
    set-identity
  attach
  acp
  mcp
    serve
    list
    show
    set
    unset
  status
  health
  sessions
    cleanup
  audit
  tasks
    list
    audit
    maintenance
    show
    notify
    cancel
    flow list|show|cancel
  gateway
    call
    usage-cost
    health
    stability
    diagnostics export
    status
    probe
    discover
    install
    uninstall
    start
    stop
    restart
    run
  fleet
    create
    backup
    restore
    doctor
    list
    status
    logs
    start
    stop
    restart
    upgrade
    rm
  worktrees
    list
    create
    remove
    restore
    gc
  daemon
    status
    install
    uninstall
    start
    stop
    restart
  logs
  system
    event
    heartbeat last|enable|disable
    presence
  models
    list
    status
    set
    set-image
    aliases list|add|remove
    fallbacks list|add|remove|clear
    image-fallbacks list|add|remove|clear
    scan
    auth list|add|login|setup-token|paste-token|paste-api-key|login-github-copilot
    auth order get|set|clear
  promos
    list
    claim <slug>
  infer (alias: capability)
    list
    inspect
    model run|list|inspect|providers|auth login|logout|status
    image generate|edit|describe|describe-many|providers
    audio transcribe|providers
    tts convert|voices|personas|providers|status|enable|disable|set-provider|set-persona
    video generate|describe|providers
    web search|fetch|providers
    embedding create|providers
  sandbox
    list
    recreate
    explain
  cron
    status
    list
    get
    add
    edit
    rm
    enable
    disable
    runs
    run
  nodes
    status
    describe
    list
    pending
    approve
    reject
    rename
    invoke
    notify
    push
    canvas present|hide|navigate
    camera list|snap|clip
    screen record
    location get
  devices
    list
    remove
    clear
    approve
    reject
    rotate
    revoke
  users
    list
    link-email <email> --to <profileId>
    merge <sourceProfileId> --into <targetProfileId>
  node
    run
    status
    install
    uninstall
    stop
    restart
  connect
  worker
  approvals
    get
    set
    allowlist add|remove
  exec-policy
    show
    preset
    set
  browser
    status
    start
    stop
    reset-profile
    tabs
    open
    focus
    close
    profiles
    create-profile
    delete-profile
    screenshot
    snapshot
    navigate
    resize
    click
    type
    press
    hover
    drag
    select
    upload
    fill
    dialog
    wait
    evaluate
    console
    pdf
  hooks
    list
    info
    check
    enable
    disable
    install
    update
  webhooks
    gmail setup|run
  proxy
    start
    run
    coverage
    sessions
    query
    blob
    purge
  pairing
    list
    approve
  qr
  clawbot
    qr
  docs
  dns
    setup
  resume
  tui
  chat (alias: tui --local)
  terminal (alias: tui --local)

插件可以添加额外的顶级命令,例如 openclaw workboard 或 openclaw voicecall。

聊天斜杠命令

聊天消息支持 /... 命令。参见 斜杠命令。

重点:

  • /status - 快速诊断。
  • /trace - 会话范围的插件跟踪/调试行。
  • /config - 持久化配置更改。
  • /debug - 仅在内存中生效的运行时配置覆盖,不写入磁盘。需要 commands.debug: true。

用量跟踪

当 OAuth/API 凭据可用时,openclaw status --usage 和控制界面会显示提供商的用量/配额。数据直接来自提供商用量端点,并规范化为 X% left。具有当前用量窗口的提供商:Anthropic、Gemini CLI、GitHub Copilot、MiniMax、OpenAI Codex、Xiaomi 和 z.ai。

有关详细信息,参见 用量跟踪。

本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 cl/openclaw