CLI Reference
The openclaw command-line interface provides all operations for running tasks, managing the server, working with configuration, and managing plugins. All commands accept --help for detailed usage information.
Global Options
These options can be used with any subcommand:
openclaw [options] COMMAND
Options:
--config, -c PATH Config file path (default: ./openclaw.yaml)
--log-level LEVEL Override log level: DEBUG, INFO, WARNING, ERROR
--format FORMAT Output format: text, json (default: text)
--no-color Disable ANSI color in output
--version Show version and exit
--help Show this message and exitopenclaw run
Run a task directly and print the output. Blocks until completion.
openclaw run [OPTIONS] TASK
Options:
--agent NAME Agent name from config to use (default: first configured)
--output FILE Write output to file instead of stdout
--timeout SECONDS Override task timeout
--max-tokens N Override max tokens for this task
--dry-run Validate task and config without executing
Examples:
openclaw run "Summarize the news from today"
openclaw run --output report.md "Research competitor pricing"
openclaw run --agent code-reviewer "Review the changes in diff.txt"
echo "my task" | openclaw run - # read task from stdinopenclaw start / stop / status
Manage the OpenClaw REST API server as a background process.
openclaw start [OPTIONS]
--port PORT Port to listen on (default: 8080)
--host HOST Host to bind to (default: 0.0.0.0)
--workers N Number of worker processes (default: 4)
--daemon Run as background daemon (detach from terminal)
openclaw stop # Graceful shutdown; finish in-progress tasks
openclaw status # Show running status, uptime, and task statistics
openclaw restart # Graceful restart (zero-downtime for queued tasks)openclaw config
openclaw config validate # Validate config file; exit 0 if valid
openclaw config show # Show effective config (with env var overrides)
openclaw config init # Interactive wizard to generate a starter config
openclaw config get KEY # Get a specific config value (e.g., llm.model)
openclaw config set KEY VALUE # Override config value in the local config fileopenclaw task
openclaw task list # List recent tasks (status, duration, task IDs)
openclaw task status TASK_ID # Get status of a specific task
openclaw task output TASK_ID # Print the output of a completed task
openclaw task cancel TASK_ID # Cancel a queued or running task
openclaw task retry TASK_ID # Re-run a failed task with the same inputopenclaw plugin
openclaw plugin list # List installed plugin packages and their tools
openclaw plugin install PKG # Install a plugin package (pip install + register)
openclaw plugin uninstall PKG # Remove a plugin package
openclaw plugin validate PKG # Validate that a plugin package loads correctlyExit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | General error (see stderr for details) |
| 2 | Configuration error (invalid config file) |
| 3 | Task execution failed |
| 4 | Task timed out |
| 5 | Token budget exceeded |
| 10 | LLM provider error (API key invalid, rate limit, outage) |
Shell Completion
The OpenClaw CLI supports tab completion for commands, options, and dynamic values (like task IDs and agent names). Install shell completion to dramatically speed up CLI usage:
# Bash (add to ~/.bashrc)
eval "$(_OPENCLAW_COMPLETE=bash_source openclaw)"
# Zsh (add to ~/.zshrc)
eval "$(_OPENCLAW_COMPLETE=zsh_source openclaw)"
# Fish (save to ~/.config/fish/completions/openclaw.fish)
_OPENCLAW_COMPLETE=fish_source openclaw > ~/.config/fish/completions/openclaw.fishWith completion installed, typing openclaw task followed by Tab will list recent task IDs. Typing openclaw run -- followed by Tab shows all available options. This is especially useful for the openclaw task commands when debugging specific failed tasks.
Piping and Shell Scripting
The --format json option makes it easy to integrate OpenClaw into shell scripts and pipelines. Every command that produces output supports JSON format, which pipes cleanly to jq for parsing and filtering:
# Get the output of the most recent failed task
openclaw task list --format json | jq -r '[.[] | select(.status=="failed")] | first | .task_id' | xargs openclaw task output
# Run a task and extract just a JSON field from the output
openclaw run --format json "Return a JSON object with keys name and version" | jq '.output | fromjson | .version'
# Batch-run tasks from a file and check all succeeded
while IFS= read -r task; do
openclaw run --format json "$task" | jq -e '.status == "completed"' || echo "FAILED: $task"
done < tasks.txtTroubleshooting Common CLI Issues
Several common issues arise when first using the CLI. If openclaw run immediately returns an error about a missing config file, run openclaw config init to create a starter config, or specify the config path explicitly with --config /path/to/openclaw.yaml. If the CLI silently hangs, the server may be waiting for an LLM API response — add --log-level DEBUG to see the request-response cycle.
On Windows, if PowerShell reports an execution policy error when activating the virtual environment, run Set-ExecutionPolicy -Scope CurrentUser RemoteSigned once to allow scripts, then retry. If you get a "command not found" error for openclaw, ensure the virtual environment is activated and that pip install openclaw completed successfully without errors.
Automating with the CLI
The CLI is designed for scripting. Combine it with standard Unix tools to build powerful automation workflows. Common patterns: running daily-scheduled tasks with a cron job, processing a file of tasks in parallel with GNU parallel, monitoring task completion with a polling loop, and chaining task outputs as inputs to subsequent tasks. The --format json flag and exit codes make all these patterns reliable and scriptable without screen-scraping text output.
Getting Help
Every subcommand accepts --help for detailed inline documentation including option descriptions and examples. The openclaw --version command reports the installed version and is the first thing to check when reporting a bug. When filing a bug report, always include the output of openclaw --version and openclaw config show (with secrets redacted) — this gives maintainers the context needed to reproduce the issue. The CLI help text is always up to date with the installed version, unlike online documentation which may describe a slightly different version.