Skip to content

feat: add completion subcommand for bash and zsh shell completion#27395

Open
dwmkerr wants to merge 1 commit intoanthropics:mainfrom
dwmkerr:feat/completion-command
Open

feat: add completion subcommand for bash and zsh shell completion#27395
dwmkerr wants to merge 1 commit intoanthropics:mainfrom
dwmkerr:feat/completion-command

Conversation

@dwmkerr
Copy link

@dwmkerr dwmkerr commented Feb 21, 2026

Summary

  • Add shell completion scripts for bash, zsh, and fish in scripts/completions/
  • Add generate-completions.sh wrapper that outputs the appropriate script for each shell
  • Covers all subcommands (auth, mcp, plugin, install, doctor, setup-token, update), nested subcommands (e.g. mcp add, plugin marketplace list), global flags, and option value completions

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

UX pattern

The claude completion <shell> pattern follows established CLI conventions:

  • GitHub CLI: gh completion -s bash
  • pnpm: pnpm completion bash
  • volta: volta completions bash

The internal CLI already has completion infrastructure (shell detection, cache file management at ~/.claude/completion.*, and a registered completion subcommand) — these scripts provide the actual completion definitions that the existing plumbing can serve.

Validation

All scripts pass syntax checks:

  • bash -n claude.bash — valid
  • zsh -n claude.zsh — valid
  • Fish syntax follows the same patterns used by the fish community

Closes #7738

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Bash completion for Claude Code tool

1 participant