> For the complete documentation index, see [llms.txt](https://www.openclawbook.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.openclawbook.xyz/en/ch33-cli-tools/33.2-core-command-analysis.md). Agents can also search and read this documentation through its [MCP server](https://www.openclawbook.xyz/~gitbook/mcp).

# 33.2 Core Command Analysis

> **Generated by**: Claude Opus 4.6 (initial draft) / Claude Opus 5 (`v2026.3.9` revision) **Token usage**: Input \~62k tokens, Output \~7k tokens (this section) **Source baseline**: `v2026.3.9` (`v2026.3.8-170-g665f67726`)

***

OpenClaw CLI registers over 25 top-level subcommands, covering Gateway management, message sending/receiving, model configuration, security audits, and more. This section analyzes each core command by usage frequency and functional category, explaining their design and implementation.

## 33.2.1 `gateway` — Start/Manage Gateway Server

`gateway` is OpenClaw's most critical command—it manages the startup, shutdown, and administration of the WebSocket Gateway server.

### Subcommand Overview

| Subcommand              | Description                                             |
| ----------------------- | ------------------------------------------------------- |
| `gateway` (default)     | Run Gateway server in foreground                        |
| `gateway run`           | Explicit foreground run                                 |
| `gateway status`        | Display service status + probe Gateway                  |
| `gateway install`       | Install system service (launchd/systemd/schtasks)       |
| `gateway uninstall`     | Uninstall system service                                |
| `gateway start`         | Start system service                                    |
| `gateway stop`          | Stop system service                                     |
| `gateway restart`       | Restart system service                                  |
| `gateway call <method>` | Call Gateway RPC method                                 |
| `gateway health`        | Get Gateway health status                               |
| `gateway probe`         | Comprehensive probe (reachability + discovery + health) |
| `gateway discover`      | Discover Gateway instances on LAN via Bonjour           |
| `gateway usage-cost`    | Query usage cost statistics                             |

### Service Lifecycle Management

The five commands `gateway install/uninstall/start/stop/restart` delegate to `daemon-cli.ts`, selecting different service management backends based on OS:

* **macOS** — launchd (`launchctl`)
* **Linux** — systemd (`systemctl`)
* **Windows** — schtasks (Task Scheduler)

```bash
# Install as system service, specify port and runtime
openclaw gateway install --port 18789 --runtime node

# Override existing service configuration with --force
openclaw gateway install --force

# View service status + probe running Gateway
openclaw gateway status --deep
```

### Gateway Discovery (Bonjour)

`gateway discover` uses mDNS/Bonjour protocol to search for running Gateway instances on the LAN:

```typescript
// src/cli/gateway-cli/register.ts (simplified)
const beacons = await discoverGatewayBeacons({ timeoutMs, wideAreaDomain });
const deduped = dedupeBeacons(beacons); // Deduplicate
```

> **Sidebar — Bonjour/mDNS**
>
> Bonjour (also called mDNS/DNS-SD) is a zero-configuration network protocol developed by Apple that allows devices to automatically discover services on a LAN without a DNS server. When Gateway starts, it broadcasts its presence to the LAN (including IP address and port), and other devices can find it via Bonjour. This enables multiple devices to automatically discover and connect to Gateway on home/office networks.

### Gateway RPC Invocation

`gateway call` provides a generic RPC invocation interface, allowing direct calls to Gateway-exposed methods:

```bash
# Call health method
openclaw gateway call health --json

# Call cron.list with parameters
openclaw gateway call cron.list --params '{"active": true}'
```

## 33.2.2 `agent` — Send Message to AI Agent

The `agent` command is the primary way users directly converse with the AI Agent, sending messages through the Gateway WebSocket connection and receiving replies.

```bash
# Basic usage: start new session with specified number
openclaw agent --to +15555550123 --message "Analyze today's logs"

# Specify Agent and thinking level
openclaw agent --agent ops --message "Summarize report" --thinking medium

# Continue existing session
openclaw agent --session-id 1234 --message "Continue the analysis above"

# Let Agent reply and send via Slack
openclaw agent --message "Generate weekly report" --deliver --reply-channel slack --reply-to "#reports"
```

### Key Options

| Option                | Description                                                  |
| --------------------- | ------------------------------------------------------------ |
| `--message <text>`    | **Required**, message content                                |
| `--to <number>`       | Recipient number (E.164 format), used to derive session key  |
| `--session-id <id>`   | Directly specify session ID                                  |
| `--agent <id>`        | Specify Agent (override routing binding)                     |
| `--thinking <level>`  | Thinking level: off / minimal / low / medium / high          |
| `--channel <channel>` | Delivery channel: last / whatsapp / telegram / discord / ... |
| `--deliver`           | Send Agent reply to selected channel                         |
| `--local`             | Run embedded Agent locally (requires API key)                |
| `--json`              | Output result in JSON format                                 |
| `--timeout <seconds>` | Timeout (default 600 seconds)                                |

### agents Management Subcommands

Besides `agent` (singular), there's an `agents` (plural) command for managing multi-Agent configuration:

```bash
openclaw agents list --bindings    # List all Agents and routing bindings
openclaw agents add ops --workspace ~/ops --model gpt-4  # Add new Agent
openclaw agents set-identity --agent main --from-identity  # Set identity from IDENTITY.md
openclaw agents delete ops --force   # Delete Agent
```

## 33.2.3 `send` — Send Message via Channel

The `send` command (actually registered as `message send`) allows sending messages directly through a specified channel, bypassing the Agent layer:

```bash
openclaw message send --target +15555550123 --message "Hi"
openclaw message send --channel telegram --target @mychat --message "Hello"
openclaw message send --target +15555550123 --message "Check this photo" --media photo.jpg
```

The `message` command group includes rich subcommands:

| Subcommand                         | Description                  |
| ---------------------------------- | ---------------------------- |
| `message send`                     | Send text/media message      |
| `message broadcast`                | Broadcast message            |
| `message poll`                     | Create poll                  |
| `message react` / `unreact`        | Add/remove emoji reaction    |
| `message read` / `edit` / `delete` | Read/edit/delete message     |
| `message pin` / `unpin`            | Pin/unpin message            |
| `message permissions`              | Permission management        |
| `message search`                   | Search messages              |
| `message thread`                   | Thread message operations    |
| `message emoji` / `sticker`        | Emoji and sticker management |

Each subcommand's registration is split into independent module files (e.g., `register.send.ts`, `register.poll.ts`), sharing channel options and common logic through `createMessageCliHelpers`.

## 33.2.4 `channels` — Channel Management (Login/Configuration)

The `channels` command manages chat channel account configuration and authentication:

```bash
openclaw channels list                     # List all channels + auth status
openclaw channels login --channel whatsapp # Link WhatsApp Web (show QR code)
openclaw channels add --channel telegram --token <bot-token>  # Add Telegram Bot
openclaw channels status --probe           # Probe channel credential status
openclaw channels capabilities             # Show channel capabilities (permissions/features)
openclaw channels resolve @user --channel discord  # Resolve username to ID
```

### Subcommand Details

| Subcommand              | Description                                    |
| ----------------------- | ---------------------------------------------- |
| `channels list`         | List all configured channels and auth profiles |
| `channels status`       | Show Gateway channel connection status         |
| `channels capabilities` | Display channel permissions/features matrix    |
| `channels resolve`      | Resolve name to channel ID                     |
| `channels logs`         | View recent channel logs                       |
| `channels add`          | Add or update channel account                  |
| `channels remove`       | Disable or delete channel account              |
| `channels login`        | Link channel account (e.g., WhatsApp QR scan)  |
| `channels logout`       | Log out channel session                        |

The `channels add` command supports over 30 options, covering all supported channel types (WhatsApp, Telegram, Discord, Slack, Signal, iMessage, Matrix, Tlon, etc.), with channel-specific authentication parameters for each.

## 33.2.5 `models` — Model Management (List/Set/Scan)

The `models` command manages AI model configuration, authentication, and fallback strategies:

```bash
openclaw models                        # Show current model status
openclaw models list --all             # List complete model directory
openclaw models set gpt-4o             # Set default model
openclaw models scan --set-default     # Scan free models and set as default
openclaw models status --probe         # Probe auth status
```

### Command Tree

```
models
├── list                  List models (supports --all/--local/--provider filtering)
├── status                Show configured model status (supports --probe online probing)
├── set <model>           Set default text model
├── set-image <model>     Set default image model
├── scan                  Scan OpenRouter free models
├── auth                  Auth management
│   ├── add               Interactive auth assistant
│   ├── login             Provider plugin auth flow (OAuth/API key)
│   ├── setup-token       Run Provider CLI to create Token
│   ├── paste-token       Paste Token to auth-profiles.json
│   ├── login-github-copilot  GitHub Copilot device auth flow
│   └── order             Per-Agent auth order management
│       ├── get           View auth order
│       ├── set           Set auth order
│       └── clear         Clear auth order override
├── aliases               Model alias management
│   ├── list              List aliases
│   ├── add <alias> <model>   Add alias
│   └── remove <alias>        Remove alias
├── fallbacks             Text model fallback chain
│   ├── list / add / remove / clear
└── image-fallbacks       Image model fallback chain
    ├── list / add / remove / clear
```

`models` is one of the deepest command trees in the CLI, with three-level nesting (`models auth order set`).

## 33.2.6 `sessions` — Session Management

```bash
openclaw sessions                      # List all sessions
openclaw sessions --active 120         # Show only sessions active in last 2 hours
openclaw sessions --json               # JSON format output
openclaw sessions --store ./sessions   # Specify session storage path
```

The `sessions` command is one of the fast-path (Fast-Path) supported commands, able to bypass the complete Commander.js pipeline and execute directly. It displays each session's recipient, last active time, Token usage, and other information.

## 33.2.7 `skills` — Skill Management

```bash
openclaw skills                        # List all skills
openclaw skills list --eligible        # Show only available skills
openclaw skills info browser           # View skill details
openclaw skills check                  # Check skill readiness status
```

The `skills` command's output is carefully designed—using table rendering (`renderTable`), each skill displays a status icon (✓ ready / ⏸ disabled / 🚫 blocked / ✗ missing), emoji name, description, and source. `skills info` also shows detailed requirement checks (binary dependencies, environment variables, config items, OS requirements) and provides installation suggestions.

At the end, a ClawHub tip is appended: `Tip: use npx clawhub to search, install, and sync skills.`

## 33.2.8 `browser` — Browser Control

The `browser` command manages OpenClaw's dedicated browser instance (Chrome/Chromium), supporting remote control:

```bash
openclaw browser status                # Browser status
openclaw browser open https://example.com  # Open URL
openclaw browser screenshot            # Take screenshot
openclaw browser click --selector "#btn"   # Click element
```

Commands are organized into seven modules by function:

| Module                        | Description                              |
| ----------------------------- | ---------------------------------------- |
| `browser-cli-manage`          | Lifecycle management (status/open/close) |
| `browser-cli-extension`       | Browser extension management             |
| `browser-cli-inspect`         | Page inspection (DOM/screenshot)         |
| `browser-cli-actions-input`   | Input operations (click/type/scroll)     |
| `browser-cli-actions-observe` | Observation operations (wait/query)      |
| `browser-cli-debug`           | Debug tools                              |
| `browser-cli-state`           | State management (cookies/storage)       |

All browser commands share Gateway RPC connection options through `addGatewayClientOptions`.

## 33.2.9 `cron` — Scheduled Task Management

The `cron` command manages scheduled tasks based on cron expressions. It's a lazy-loaded subcommand registered in `cron-cli/register.ts`, communicating with the running Gateway via Gateway RPC to manage scheduled tasks.

## 33.2.10 `nodes` — Node Management

The `nodes` command manages nodes in distributed deployments. Also a lazy-loaded subcommand registered in `nodes-cli/register.ts`. Node management involves node discovery, node status queries, and inter-node communication.

## 33.2.11 `doctor` — Health Check and Diagnostics

`doctor` is OpenClaw's "general practitioner"—it detects and fixes common issues:

```bash
openclaw doctor                  # Interactive diagnostics
openclaw doctor --repair         # Auto-repair
openclaw doctor --fix            # Alias for --repair
openclaw doctor --force          # Aggressive repair (override custom config)
openclaw doctor --non-interactive  # Non-interactive mode (safe migrations only)
openclaw doctor --deep           # Scan system services
```

The `doctor` command is registered in `register.maintenance.ts`, grouped with `dashboard`, `reset`, and `uninstall` commands as maintenance commands:

| Command     | Description                            |
| ----------- | -------------------------------------- |
| `doctor`    | Health check + quick fix               |
| `dashboard` | Open Web console                       |
| `reset`     | Reset local config/state               |
| `uninstall` | Uninstall Gateway service + local data |

The special aspect of `doctor`—it's whitelisted in the config guard (`ALLOWED_INVALID_COMMANDS`), allowed to run even if the config file is invalid, since it's designed to fix config issues.

## 33.2.12 `security` — Security Audit

```bash
openclaw security audit           # Run security audit
openclaw security audit --deep    # Include Gateway online probing
openclaw security audit --fix     # Apply security fixes
openclaw security audit --json    # JSON output
```

The `security audit` implementation has two steps:

1. **Fix** (optional): `fixSecurityFootguns()` tightens default config, corrects file permissions (chmod)
2. **Audit**: `runSecurityAudit()` five-layer scan (attack surface → config → filesystem → channels → deep probing)

Output is grouped by severity (CRITICAL → WARN → INFO), each finding includes `checkId`, title, details, and fix suggestions.

## 33.2.13 `onboard` — Onboarding Wizard

`onboard` is the onboarding wizard for new users, guiding through Gateway setup, workspace creation, and skill installation:

```bash
openclaw onboard                              # Interactive wizard
openclaw onboard --flow quickstart            # Quickstart flow
openclaw onboard --non-interactive --accept-risk \
  --auth-choice token --token-provider anthropic \
  --token <key>                               # Non-interactive automated install
```

The `onboard` command has the most options in the CLI (50+), covering all possible configuration combinations:

* **Auth choice**: Support 20+ providers including Anthropic, OpenAI, OpenRouter, Gemini, xAI, Moonshot
* **Gateway config**: Port, binding mode (loopback/tailnet/lan/auto), auth method (token/password)
* **Tailscale integration**: off / serve / funnel three modes
* **Service install**: Auto-detect and install as system service
* **Channels/skills/health check**: All can be skipped via `--skip-*`

## 33.2.14 `update` — Version Update

The `update` command manages OpenClaw version upgrades, supporting three update channels:

```bash
openclaw update                    # Update using current channel
openclaw update --channel beta     # Switch to Beta channel
openclaw update --channel dev      # Switch to Dev channel (Git)
openclaw update status             # View update status
openclaw update wizard             # Interactive update wizard
openclaw --update                  # Shorthand form
```

### Three Update Channels

| Channel  | Install Method     | Source                    |
| -------- | ------------------ | ------------------------- |
| `stable` | npm (`latest` tag) | Official release versions |
| `beta`   | npm (`beta` tag)   | Pre-release versions      |
| `dev`    | Git (main branch)  | Source code compilation   |

### Update Flow

The `update` command implements a complete update orchestration flow:

1. **Detect install type**: Git source vs npm global package
2. **Resolve target version**: Get version number from npm registry tag
3. **Downgrade confirmation**: If target version is lower than current, require user confirmation
4. **Channel switch**: If new channel specified, write to config file
5. **Execute update**:
   * **Git mode**: fetch → rebase → install deps → build → doctor
   * **npm mode**: Detect package manager (npm/pnpm/bun) → global install
   * **Channel switch**: `dev` → clone Git repo; non-`dev` → global npm install
6. **Update plugins**: Sync built-in plugins, update npm-installed plugins
7. **Shell completion**: Update cache, prompt for installation
8. **Restart service**: Restart Gateway daemon + run doctor

The entire flow includes progress indicators (spinner), each step showing elapsed time and success/failure status. After update completes, a random fun quote is output (e.g., "The lobster has molted. Harder shell, sharper claws.").

***

## Section Summary

1. **`gateway`** is the most critical command, managing the complete lifecycle of WebSocket Gateway (foreground run/system service/probe/discovery/RPC invocation), with cross-platform support for launchd/systemd/schtasks
2. **`agent`/`message`** handle AI conversation and raw message sending respectively—`agent` routes through Gateway to AI Agent, `message` directly operates channels
3. **`channels`/`models`** manage two major external dependencies—chat channels and AI models, where `models` command tree reaches three levels deep, including complete auth, alias, and fallback chain management
4. **`doctor`/`security`/`onboard`** form the operations toolkit—diagnose/repair, security audit, guided installation; `doctor` is specially exempted from config validation
5. **`update`** implements three-channel (stable/beta/dev) update orchestration, auto-detecting install type, managing package managers, syncing plugins, restarting services
6. **All commands uniformly use** `runCommandWithRuntime(defaultRuntime, action)` wrapper, ensuring consistent error handling; support `--json` machine-readable output mode
