Command completion in Zsh depends on the shell's completion system being initialized before the terminal can suggest subcommands, files, options, and command-specific arguments. Without that setup, pressing Tab may fall back to basic filename completion or show no command-aware choices.
The completion system is loaded with autoload -Uz compinit and initialized with compinit. During initialization, Zsh scans the completion function path and writes a dump file so later interactive shells can start faster. The -d option names that dump file explicitly.
Keep this setup in ~/.zshrc because completion is an interactive shell feature. A new interactive Zsh process should then register built-in command completions such as cd_completion=_cd and create the configured .zcompdump file. If Zsh reports insecure completion directories, inspect them with compaudit and correct ownership or permissions before bypassing the warning.
Related: How to configure Zsh startup files
Related: How to configure Zsh completion styles
Related: How to generate shell completions for Codex
$ zsh --version zsh 5.9 (aarch64-unknown-linux-gnu)
$ cp ~/.zshrc ~/.zshrc.bak
If ~/.zshrc does not exist yet, create it with touch ~/.zshrc and skip the backup.
autoload -Uz compinit
compinit -d "${ZDOTDIR:-$HOME}/.zcompdump"
The -d path keeps the completion dump under the active Zsh config directory when ZDOTDIR is set, and under the home directory otherwise.
$ zsh -n ~/.zshrc
No output from zsh -n means Zsh parsed the startup file without finding a syntax error.
$ zsh -ic 'print cd_completion=${_comps[cd]:-missing}'
cd_completion=_cd
The cd_completion=_cd output shows that Zsh registered the built-in completion function for cd.
$ ls -l "${ZDOTDIR:-$HOME}/.zcompdump"
-rw-r--r-- 1 operator operator 50559 Jun 5 08:19 /home/operator/.zcompdump
$ zsh -ic 'compaudit'
No output means compaudit did not list insecure completion paths.
Do not silence insecure-directory warnings until the listed directories are owned by the expected user or by root and are not writable by other users.