feat: add completion subcommand for bash and zsh shell completion#27395
Open
dwmkerr wants to merge 1 commit intoanthropics:mainfrom
Open
feat: add completion subcommand for bash and zsh shell completion#27395dwmkerr wants to merge 1 commit intoanthropics:mainfrom
dwmkerr wants to merge 1 commit intoanthropics:mainfrom
Conversation
Add shell completion scripts for bash, zsh, and fish that can be output via `claude completion <shell>`. The scripts cover all subcommands, nested subcommands, flags, and option values from the current CLI. Installation: # Bash — add to ~/.bashrc: eval "$(claude completion bash)" # Zsh — add to ~/.zshrc: eval "$(claude completion zsh)" # Fish — save to completions directory: claude completion fish > ~/.config/fish/completions/claude.fish The UX pattern follows gh CLI (`gh completion -s bash`), pnpm (`pnpm completion bash`), and volta (`volta completions bash`). Closes anthropics#7738
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scripts/completions/generate-completions.shwrapper that outputs the appropriate script for each shellauth,mcp,plugin,install,doctor,setup-token,update), nested subcommands (e.g.mcp add,plugin marketplace list), global flags, and option value completionsInstallation
UX pattern
The
claude completion <shell>pattern follows established CLI conventions:gh completion -s bashpnpm completion bashvolta completions bashThe internal CLI already has completion infrastructure (shell detection, cache file management at
~/.claude/completion.*, and a registeredcompletionsubcommand) — these scripts provide the actual completion definitions that the existing plumbing can serve.Validation
All scripts pass syntax checks:
bash -n claude.bash— validzsh -n claude.zsh— validCloses #7738