openclaw completion
Generate shell completion scripts, cache them under OpenClaw state, and optionally install them into your shell profile.
Usage
Options
-s, --shell <shell>: shell target (zsh,bash,powershell,fish; detected from$SHELL, otherwise PowerShell on Windows and zsh elsewhere)-i, --install: install completion by adding a source line for the cached script to your shell profile--write-state: write completion script(s) to$OPENCLAW_STATE_DIR/completions(default~/.openclaw/completions) without printing to stdout; with--shellwrites only that shell, otherwise all four-y, --yes: skip install confirmation prompts (non-interactive)
Install flow
--install points your profile at the cached script, so the cache must exist first: if it is missing, the command fails and tells you to run openclaw completion --write-state. Combine --write-state --install to do both in one step. Without --shell, the command preserves a recognized $SHELL; when $SHELL is missing or unrecognized, it defaults to PowerShell on Windows and zsh elsewhere.
The install writes a small # OpenClaw Completion block into your shell profile and replaces any older slow source <(openclaw completion ...) lines with the cached source line:
Profile changes are staged beside the destination and atomically replace it only after a complete durable write. A failed install leaves an existing profile unchanged.
Installed source lines preserve literal cache paths, including spaces, quotes, dollar signs, and backslashes. Reinstalling replaces OpenClaw’s previous source line after the state directory changes.
Permission failures
If Doctor or onboarding cannot update your shell profile, completion remains optional and setup continues. When a cache is available, the warning includes a command to load that cache in your current matching shell session. Run the complete command as printed. This does not install completion for future shell sessions. For persistent installation, resolve the reported permission or read-only error before retryingopenclaw completion --install. The failure location may be a
staging directory or a symlink target, not the profile itself. Atomic replacement
also needs write access to the destination directory. The installer uses the
profile selected in the table above; it has no profile-file destination option.
Notes
- Without
--installor--write-state, the command prints the script to stdout. - Completion generation eagerly loads the full command tree, including plugin CLI commands, so nested subcommands are included.
- Bash completion supports both
--flag valueand--flag=value, including named profiles before nested commands. openclaw updaterefreshes the completion cache automatically after a successful update;openclaw doctorcan repair missing or stale completion setups.