autospec provides built-in shell completion support for bash, zsh, fish, and powershell using Cobra's completion system.
- Automatic command completion: Tab-complete all commands (
full,prep,specify,plan,tasks,implement, etc.) - Flag completion: Complete command flags (e.g.,
--max-retries,--debug,--specs-dir) - Stays in sync: Automatically updates as commands change
- Multiple shells: Works with bash, zsh, fish, and powershell
- One-command installation: Use
autospec completion installto automatically configure your shell
The easiest way to set up shell completions is using the install command:
# Auto-detect your shell and install completions
autospec completion install
# Or specify a shell explicitly
autospec completion install bash
autospec completion install zsh
autospec completion install fish
autospec completion install powershellThis command:
- Auto-detects your shell from the
$SHELLenvironment variable - Creates a backup of your shell configuration file (e.g.,
~/.bashrc.autospec-backup-YYYYMMDD-HHMMSS) - Appends the completion configuration to your rc file
- Provides instructions for activating the completions
# Show manual installation instructions without modifying files
autospec completion install --manual
# Show manual instructions for a specific shell
autospec completion install bash --manual- Bash/Zsh/PowerShell: Appends a sourcing block to your rc file that loads completions dynamically
- Fish: Writes a completion file directly to
~/.config/fish/completions/autospec.fish
The installed completions use eval/source style, meaning they automatically stay up-to-date when you upgrade autospec - no need to regenerate completion files!
Before modifying any rc file, a timestamped backup is created:
- Format:
~/.bashrc.autospec-backup-20231215-143022 - Backups are retained permanently for easy recovery
The install command is idempotent - running it multiple times won't add duplicate entries. If completions are already installed, the command detects the existing configuration and skips installation.
If you prefer manual control or the automatic installation doesn't work for your setup, follow the shell-specific instructions below.
# Create completions directory
mkdir -p ~/.zsh_completions
# Generate completion file
autospec completion zsh > ~/.zsh_completions/_autospecAdd these lines to your ~/.zshrc (before any existing compinit call):
# Add custom completions directory to fpath
fpath=(~/.zsh_completions $fpath)
# Initialize completion system (if not already present)
autoload -U compinit
compinitImportant: The fpath line must appear before compinit. If you already have compinit in your .zshrc, add the fpath line above it.
exec zshautospec <tab>You should see all available subcommands with descriptions. If you have fzf installed, you'll get fuzzy filtering!
# System-wide (requires root)
autospec completion bash | sudo tee /etc/bash_completion.d/autospec > /dev/null
# User-specific
mkdir -p ~/.bash_completions
autospec completion bash > ~/.bash_completions/autospecAdd to your ~/.bashrc:
# Load autospec completion
if [ -f ~/.bash_completions/autospec ]; then
source ~/.bash_completions/autospec
fisource ~/.bashrcautospec completion fish > ~/.config/fish/completions/autospec.fishsource ~/.config/fish/config.fish
# or just start a new shellautospec completion powershell | Out-String | Invoke-Expression# Add to your PowerShell profile
autospec completion powershell >> $PROFILEAfter setup, test completion works:
# Type and press TAB
autospec <TAB>
# Should show:
# full -- Run complete workflow: specify → plan → tasks → implement
# prep -- Prepare for implementation: specify → plan → tasks
# specify -- Generate feature specification
# plan -- Generate implementation plan
# tasks -- Generate task list
# implement -- Execute implementation
# doctor -- Check dependencies
# status -- Show current spec status
# config -- Manage configuration
# init -- Initialize configuration
# version -- Show version information
# completion -- Generate completion script
# help -- Help about any commandComplete flags for any command:
autospec prep --<TAB>
# Shows:
# --max-retries -- Maximum number of retry attempts
# --dry-run -- Show what would be executed without running
# --skip-preflight -- Skip pre-flight dependency checks
# --debug -- Enable debug logging
# --specs-dir -- Specs directory path
# --config -- Config file pathautospec config <TAB>
# Shows:
# show -- Display current configurationSome shells provide intelligent completion based on context. For example, in zsh with fuzzy completion:
autospec imp<TAB>
# Fuzzy matches to "implement"Check if completion file exists:
# Zsh
ls -la ~/.zsh_completions/_autospec
# Bash
ls -la ~/.bash_completions/autospec
# Fish
ls -la ~/.config/fish/completions/autospec.fishVerify fpath (zsh only):
echo $fpath | grep zsh_completionsShould show ~/.zsh_completions in the path.
Rebuild completion cache (zsh only):
rm -f ~/.zcompdump*
exec zshCheck compinit is called (zsh only):
grep -n compinit ~/.zshrcMake sure fpath modification appears before compinit.
Regenerate the completion file:
# Zsh
autospec completion zsh > ~/.zsh_completions/_autospec
# Reload
exec zshMake sure completion files are readable:
chmod 644 ~/.zsh_completions/_autospecWhen you update autospec, regenerate completion files:
# Zsh
autospec completion zsh > ~/.zsh_completions/_autospec
exec zsh
# Bash
autospec completion bash > ~/.bash_completions/autospec
source ~/.bashrc
# Fish
autospec completion fish > ~/.config/fish/completions/autospec.fishautospec uses Cobra's built-in completion system, which automatically generates completion scripts from the command structure.
When you run autospec completion <shell>, Cobra:
- Analyzes all registered commands and flags
- Generates shell-specific completion code
- Outputs a completion script for your shell
This means:
- Completions are always accurate and up-to-date
- No manual maintenance required
- New commands automatically get completion support
- Supports multiple shells with zero extra work
On macOS, bash is often outdated (v3.x). For best results:
- Install modern bash via Homebrew:
brew install bash - Or use zsh (default shell since macOS Catalina)
Use WSL (Windows Subsystem for Linux) and follow the Linux/bash instructions.
Most Linux distributions use bash or zsh by default. Follow the respective setup instructions above.
- Cobra Shell Completions Documentation
- Zsh Completion System
- CLI Usage:
autospec --help