### Summary
Using the zsh completion snippet:
```zsh
source <(openclaw completion --shell zsh)
causes this error on shell startup:
command not found: compdef
Environment
- OpenClaw:
2026.1.30
- Shell: zsh
- OS: macOS
Reproduction
- In
.zshrc, add:
source <(openclaw completion --shell zsh)
- Do not run
compinit before this line.
- Start a new zsh session.
- Observe:
command not found: compdef.
Expected behavior
Completion should load cleanly, or docs/setup should clearly state that compinit must be initialized first.
Actual behavior
The generated completion uses compdef, which is unavailable unless zsh completion is initialized.
Workaround
This fixes it:
autoload -Uz compinit
compinit
source <(openclaw completion --shell zsh)
(optional guard)
if command -v openclaw >/dev/null 2>&1; then
source <(openclaw completion --shell zsh)
fi
causes this error on shell startup:
Environment
2026.1.30Reproduction
.zshrc, add:compinitbefore this line.command not found: compdef.Expected behavior
Completion should load cleanly, or docs/setup should clearly state that
compinitmust be initialized first.Actual behavior
The generated completion uses
compdef, which is unavailable unless zsh completion is initialized.Workaround
This fixes it:
(optional guard)