How to use the OpenClaw CLI (openclaw command) effectively?

Clawpedia · For Humans

Master the OpenClaw command-line interface with essential commands, flags, and productivity tips.

How to Use the OpenClaw CLI Effectively

The openclaw command-line interface is the primary way to control, configure, and interact with your OpenClaw agent. Mastering the CLI makes you significantly more productive and gives you full control over every aspect of your assistant.

CLI Structure

OpenClaw's CLI follows a consistent pattern:


openclaw <command> <subcommand> [options] [arguments]

Essential Commands

CommandDescriptionExample
startStart the gatewayopenclaw start
stopStop the gatewayopenclaw stop
restartRestart the gatewayopenclaw restart
statusShow current statusopenclaw status
chatSend a messageopenclaw chat "Hello"
configManage configurationopenclaw config get model
skillManage skillsopenclaw skill list
memoryManage memoryopenclaw memory search "topic"
agentManage agentsopenclaw agent list
logsView logsopenclaw logs --tail 50
backupBackup/restoreopenclaw backup create

Interactive Chat Mode


# Single message
openclaw chat "What's the weather like?"

# Interactive mode (ongoing conversation)
openclaw chat
# > Hello!
# OpenClaw: Hi! How can I help you today?
# > What's 2+2?
# OpenClaw: 4.
# > /exit

# Chat with a specific agent
openclaw chat --agent work-assistant "Summarize my emails"

# Chat with a specific model (override default)
openclaw chat --model gpt-4o "Explain quantum computing"

Configuration Management


# View all configuration
openclaw config list

# Get specific values
openclaw config get model.provider
openclaw config get gateway.port

# Set values
openclaw config set model.provider openai
openclaw config set model.model gpt-4o
openclaw config set gateway.port 3001

# Reset to defaults
openclaw config reset model

# Edit the full config file
openclaw config edit
# Opens in $EDITOR (vim, nano, etc.)

# Validate configuration
openclaw config validate
# ✅ Configuration is valid

Useful Flags


# Verbose output (debugging)
openclaw start --verbose
openclaw chat --verbose "Hello"

# Quiet mode (scripting)
openclaw start --quiet

# JSON output (for scripting/piping)
openclaw status --json
openclaw skill list --json
openclaw memory list --json | jq '.[] | .fact'

# Dry run (see what would happen)
openclaw backup restore --dry-run
openclaw skill install suspicious-skill --dry-run

# Force (skip confirmation prompts)
openclaw memory clear --force
openclaw stop --force

# Help for any command
openclaw help
openclaw chat --help
openclaw skill install --help

Piping and Scripting


# Pipe content to OpenClaw
cat report.txt | openclaw chat "Summarize this document"

# Process output
openclaw chat "List 5 random names" --json | jq -r '.response'

# Use in scripts
#!/bin/bash
STATUS=$(openclaw status --json | jq -r '.gateway.status')
if [ "$STATUS" != "running" ]; then
  openclaw start
  echo "Gateway started"
fi

# Batch processing
for file in *.txt; do
  openclaw chat "Summarize: $(cat $file)" > "summary_$file"
done

Log Management


# View recent logs
openclaw logs

# Follow logs in real-time
openclaw logs --follow

# Filter by level
openclaw logs --level error
openclaw logs --level warning,error

# Filter by component
openclaw logs --component gateway
openclaw logs --component skill:email-sender
openclaw logs --component memory

# Search logs
openclaw logs --search "connection failed"

# Export logs
openclaw logs --since 24h --format json > debug-logs.json

Secret Management


# Store a secret
openclaw secret set OPENAI_API_KEY
# Enter value: ****

# List stored secrets (values hidden)
openclaw secret list
# OPENAI_API_KEY      ****...7kQ2
# ANTHROPIC_API_KEY   ****...xP9m

# Delete a secret
openclaw secret delete OLD_API_KEY

# Rotate a secret
openclaw secret rotate OPENAI_API_KEY

Keyboard Shortcuts (Interactive Mode)

updateUpdate OpenClawopenclaw update
ShortcutAction
Ctrl+CCancel current input
Ctrl+DExit interactive mode
↑ / ↓Navigate command history
TabAuto-complete commands
/clearClear conversation
/modelShow current model
/switch <model>Switch model mid-chat
/saveSave conversation to file

Shell Completion


# Bash
openclaw completion bash >> ~/.bashrc

# Zsh
openclaw completion zsh >> ~/.zshrc

# Fish
openclaw completion fish > ~/.config/fish/completions/openclaw.fish

# Now you can tab-complete:
openclaw sk<TAB> → openclaw skill
openclaw skill in<TAB> → openclaw skill install

Aliases for Power Users


# Add to ~/.bashrc or ~/.zshrc
alias oc="openclaw"
alias occ="openclaw chat"
alias ocs="openclaw status"
alias ocl="openclaw logs --follow"
alias ocr="openclaw restart"

# Quick chat function
ask() { openclaw chat "$*"; }
# Usage: ask what is the capital of France?
/exitExit interactive mode

Tip: Start with openclaw help and openclaw <command> --help to explore. The CLI is self-documenting, and tab completion makes discovering commands effortless.

Related Articles