OpenClawCheatsheet

OpenClaw CLI & Configuration Cheatsheet📋

Every essential OpenClaw CLI command and configuration pattern in one place. Covers installation, gateway management, channels, agents, sessions, automation, security, and deployment. Bookmark this and stop searching the docs.

Quick Reference

NameSyntaxDescription
openclaw onboardopenclaw onboard --install-daemonInteractive setup wizard. Configures auth, gateway, and optional channels.
openclaw gatewayopenclaw gateway [--port 18789]Start the Gateway process. Default port: 18789.
openclaw gateway statusopenclaw gateway statusCheck if the Gateway is running and healthy.
openclaw channels loginopenclaw channels login <platform> [--token] [--label]Connect a new channel (WhatsApp, Telegram, Discord, etc.).
openclaw channels listopenclaw channels list [--show-access]List all connected channels and their status.
openclaw sessions listopenclaw sessions list [--agent <id>] [--active]List sessions, optionally filtered by agent or active status.
openclaw models scanopenclaw models scanDiscover available models across all configured providers.
openclaw cron addopenclaw cron add --schedule "<cron>" --agent <id> --message "<msg>"Schedule a recurring agent task using cron syntax.
openclaw dashboardopenclaw dashboardOpen the Control UI in the browser.
openclaw updateopenclaw updateUpdate OpenClaw to the latest version.

Installation & Setup

Install (macOS/Linux)

curl -fsSL https://openclaw.ai/install.sh | bash

Downloads and installs the OpenClaw CLI. Requires Node.js 22 or higher.

bash

Tips

  • Use nvm or fnm to install Node.js 22 if you have an older version
  • On Windows, use the PowerShell installer: iwr -useb https://openclaw.ai/install.ps1 | iex

Onboarding Wizard

openclaw onboard --install-daemon

Interactive wizard that configures authentication, gateway, channels, and daemon.

bash

Tips

  • The --install-daemon flag sets up the Gateway to start automatically on boot
  • You can re-run onboard at any time to reconfigure

Environment Variables

OPENCLAW_HOME, OPENCLAW_STATE_DIR, OPENCLAW_CONFIG_PATH

Override default paths for production deployments.

bash

Tips

  • Default home is ~/.openclaw/
  • Useful for FHS-compliant server deployments

Gateway Management

Start Gateway

openclaw gateway [--port <number>]

Start the Gateway process. Use a process manager for production.

bash

Tips

  • Default port is 18789
  • Control UI available at http://127.0.0.1:18789/
  • Always use pm2 or systemd in production

Gateway Configuration

~/.openclaw/openclaw.json

Minimal working configuration. Uses ${VAR} syntax for secrets.

json

Tips

  • Never hardcode tokens — use ${VAR_NAME} environment references
  • Use openclaw config show to inspect the active config
  • Validate with openclaw config validate --strict

Config & Logs

openclaw config show | openclaw logs

Inspect configuration and view filtered logs.

bash

Tips

  • Use --strict flag to catch misconfigurations before deployment
  • Filter logs by type: error, automation, elevated, agent

Channels

Connect Channels

openclaw channels login <platform> [--token] [--label]

Connect chat platforms to the Gateway. Each platform has its own auth method.

bash

Tips

  • WhatsApp uses QR code scanning
  • Discord requires bot intents enabled in Developer Portal
  • Use --label for human-readable account names

Channel Config with Access Control

channels.{platform}.allowedUsers | allowedGuilds | corsOrigins

Restrict channel access with user IDs, guild IDs, or CORS origins.

json

Tips

  • allowedUsers locks Telegram to specific user IDs
  • allowedGuilds restricts Discord to specific servers
  • corsOrigins prevents unauthorized WebChat embedding

Send a Test Message

openclaw message send --target <id> --message "<text>"

Send a message through a connected channel for testing.

bash

Tips

  • Useful for verifying channel connectivity
  • The target format depends on the channel type

Agents & Models

Agent Configuration

agents.list[].{id, model, workspace, agentDir}

Define agents with model, workspace, and agent directory.

json

Tips

  • Model format: provider:model-name
  • Each agent gets an isolated workspace directory
  • Use descriptive IDs: 'coder', 'support', 'deployer'

Model Failover

model.{primary, failover[]}

Automatic fallback to secondary models when the primary is unavailable.

json

Tips

  • Failover is tried in order: first match wins
  • Mix cloud and local models for maximum availability
  • Use openclaw models scan to check available models

Agent Bindings

agents.{id}.bindings[].{type, accountId, guildId, roles}

Route messages to agents. Priority: peer > guild+roles > guild > account > channel > default.

json

Tips

  • Always define a default binding to catch unmatched messages
  • Binding types: peer, parent_peer, guild, team, account, channel, default
  • First-match-in-tier resolves conflicts

View Agent Prompt

openclaw agent prompt --id <agent>

Inspect agent configuration, assembled prompt, and available tools.

bash

Tips

  • The prompt is composed from SOUL.md + IDENTITY.md + USER.md + AGENTS.md + MEMORY.md
  • Use this to debug unexpected agent behavior

Sessions & Memory

Session Management

openclaw sessions {list, view, end, export}

List, inspect, end, and export conversation sessions.

bash

Tips

  • Sessions are scoped: user + channel + agent = unique session
  • Export is useful for debugging and training data
  • Ending a session clears active state but preserves history

Memory Configuration

agents.{id}.memory.{enabled, maxMessages, compaction, flush}

Configure per-agent conversation memory with compaction and flushing.

json

Tips

  • Compaction summarizes old messages when context is 80% full
  • Pre-compaction flush writes key facts to MEMORY.md before summarizing
  • Disable memory for stateless agents (alerts, commands)

Automation

Cron Jobs

openclaw cron {add, list, remove}

Schedule recurring agent tasks using standard cron syntax.

bash

Tips

  • Uses standard cron format: min hour day month weekday
  • Each cron job sends a message to a specific agent
  • Use cron for fixed routines, heartbeat for adaptive tasks

Webhooks

openclaw webhooks {create, list, remove}

Create HTTP endpoints for external services to trigger agent actions.

bash

Tips

  • Always configure a shared secret for webhook validation
  • Webhook URL format: https://gateway.example.com/webhooks/<name>
  • Configure the URL in the external service (GitHub, CI/CD, etc.)

Event Hooks

hooks.{onNewMessage, onChannelDisconnect, onAgentError}

Trigger actions in response to system events.

json

Tips

  • Hooks are reactive — they fire when events occur
  • Use template variables: {{channel.name}}, {{agent.id}}, {{error.message}}
  • Combine with broadcast groups for cross-platform alerts

Security & Sandboxing

Sandbox Configuration

agents.{id}.sandbox.{mode, scope}

Control agent command execution. Modes: off, basic, strict. Scope: agent, tree.

json

Tips

  • strict: full isolation, no network, minimal syscalls
  • basic: restricted shell, limited environment variables
  • scope: tree applies sandbox to sub-agents recursively

Tool Access Control

agents.{id}.tools.{allow[], deny[]}

Whitelist and blacklist tools per agent. Defense in depth.

json

Tips

  • Use deny as a safety net even with a restrictive allow list
  • Common tools: file_read, file_write, grep, bash, deploy, browser_*
  • Follow least privilege: only grant what's needed

Elevated Access

security.elevation.{enabled, requireApproval, maxDuration}

Controlled temporary access to restricted tools with user approval.

json

Tips

  • maxDuration is in seconds (300 = 5 minutes)
  • Always require approval in production
  • Review elevation logs regularly for security auditing

Plugins & Skills

Plugin Management

openclaw plugins {install, list, remove}

Install and manage channel plugins for Teams, Matrix, LINE, etc.

bash

Tips

  • Plugin channels work identically to built-in channels
  • Configure plugin channels in openclaw.json after installation

Skill Management

openclaw skills {search, install, list, publish}

Find, install, and share reusable agent capabilities via ClawHub.

bash

Tips

  • Skills are SKILL.md files bundled with tool definitions
  • ClawHub is the community registry for skills
  • Create custom skills for your team's specific workflows

Common Patterns

Complete multi-agent production setup

json

A production-ready configuration with a triage agent routing to a sandboxed coder agent. WhatsApp and Discord channels connected with access controls. Failover chain for high availability. Strict sandbox with tool restrictions. Elevated access requires approval.

Docker production deployment

yaml

Complete Docker stack with OpenClaw Gateway and Caddy reverse proxy. Caddy handles TLS automatically via Let's Encrypt. Agent data persisted in a Docker volume. Secrets loaded from .env file. Health checks ensure auto-restart on failures.

Bootstrap files quick setup

bash

Quick setup for an agent's workspace with the three essential bootstrap files. SOUL.md defines personality, IDENTITY.md provides self-knowledge, and MEMORY.md starts empty and accumulates knowledge over time.

Watch Out For

Node.js version below 22 causes cryptic startup errors with no clear message about the version requirement

Always verify with `node --version` before installing. Use nvm (`nvm install 22`) or fnm (`fnm install 22`) to manage versions. OpenClaw requires features only available in Node.js 22+.

Bot tokens reused across multiple gateways cause disconnection loops as each gateway fights for the connection

Each bot token can only be connected to one gateway. Create separate bot applications in the Discord Developer Portal or Telegram BotFather for each gateway instance.

Webhook channels (Telegram, Discord) fail silently when the gateway port is not reachable from the internet

Ensure your firewall/security group allows inbound traffic on the gateway port. For local development, use a tunnel like ngrok or Cloudflare Tunnel to expose the port.

Context window overflow drops older messages silently when maxMessages is high and compaction is disabled

Enable compaction for conversational agents. Compaction summarizes older messages instead of dropping them, preserving key information. Set threshold: 0.8 and preserveRecent: 20 as a starting point.

MEMORY.md grows unbounded over time, consuming more tokens on every message and increasing response latency

Review and prune MEMORY.md periodically. Remove outdated facts, consolidate similar entries, and keep it under 500 words. Every line costs tokens on every single message.

Master OpenClaw with Stanza

Go beyond the cheatsheet with hands-on lessons and challenges.

Dive Deeper