OpenClaw Completion Command Reference

Reference for the openclaw completion CLI command, covering generation, caching, and installation of shell completion scripts for zsh, bash, powershell, and fish. Useful for developers setting up CLI autocompletion.

Read this when

  • You want shell completions for zsh/bash/fish/PowerShell
  • You need to cache completion scripts under OpenClaw state

openclaw completion

Shell completion scripts can be generated, stored in OpenClaw state, and optionally added to your shell profile.

Usage

openclaw completion                          # print the detected shell's script
openclaw completion --shell fish             # print fish script
openclaw completion --write-state            # cache scripts for all shells
openclaw completion --write-state --install  # cache, then install in one step
openclaw completion --shell bash --write-state

Options

  • -s, --shell <shell>: specifies the shell target (zsh, bash, powershell, fish; auto-detected from $SHELL, defaulting to PowerShell on Windows and zsh elsewhere)
  • -i, --install: installs completion by inserting a source line for the cached script into your shell profile
  • --write-state: writes completion script(s) to $OPENCLAW_STATE_DIR/completions (defaulting to ~/.openclaw/completions) without sending anything to stdout; using --shell targets only that shell, otherwise all four are generated
  • -y, --yes: bypasses install confirmation prompts for non-interactive use

Install flow

Since --install links your profile to the cached script, that cache must already exist: if it's absent, the command errors out and instructs you to run openclaw completion --write-state. To handle both steps at once, combine --write-state --install. When --shell isn't supplied, the command respects a recognized $SHELL; if $SHELL is absent or unrecognized, it falls back to PowerShell on Windows and zsh elsewhere.

The installation adds a compact # OpenClaw Completion section to your shell profile and swaps out any previous slow source <(openclaw completion ...) lines for the cached source line:

ShellProfile
bash~/.bashrc (uses ~/.bash_profile when ~/.bashrc isn't present)
fish~/.config/fish/config.fish
powershell~/.config/powershell/Microsoft.PowerShell_profile.ps1 (on Windows: Documents/PowerShell/Microsoft.PowerShell_profile.ps1, or Documents/WindowsPowerShell/... for Windows PowerShell)
zsh$ZDOTDIR/.zshrc when ZDOTDIR is set; otherwise ~/.zshrc (an empty ZDOTDIR resolves to /.zshrc)

Profile edits are prepared next to the target file and swapped in atomically only after a fully durable write completes. If the install fails, the existing profile stays untouched.

Notes

  • When neither --install nor --write-state is given, the script goes to stdout.
  • Building completions eagerly loads the entire command tree, plugin CLI commands included, so nested subcommands show up.
  • After a successful update, openclaw update automatically refreshes the completion cache; openclaw doctor can fix missing or outdated completion setups.
384 words · updated Aug 22, 2026