Skip to content

Package Manager Integration

Tab provides a standalone CLI tool that enhances package manager completions with automatic discovery of CLI tools that support Tab completions. This guide focuses on the advanced features and unique capabilities of Tab’s package manager integration.

For basic setup instructions, see the Getting Started guide. Here’s the minimal setup:

Terminal window
# Install and configure
npm install -g @bombsh/tab
tab pnpm zsh > ~/.zsh_completions/tab-pnpm.zsh
echo 'source ~/.zsh_completions/tab-pnpm.zsh' >> ~/.zshrc

Tab automatically detects and provides completions for CLI tools in your project:

Terminal window
# Tab automatically discovers and provides completions for:
pnpm vite dev --port # ← Vite completions
pnpm tsc --target # ← TypeScript completions
pnpm eslint --ext # ← ESLint completions
pnpm jest --config # ← Jest completions

The discovery process:

  1. Scans node_modules/.bin/ for available CLI tools
  2. Tests each tool for Tab compatibility (has a complete command)
  3. Provides completions automatically for compatible tools

A CLI tool is “Tab-compatible” if it follows the Tab protocol:

Terminal window
# Test compatibility
my-cli complete -- --help
# Expected output:
--help Show help information
:0

Tab reads your package.json to provide intelligent completions:

Terminal window
# Automatically suggests scripts from package.json
pnpm run <TAB> # Shows: dev, build, test, lint, etc.
# Suggests dependencies for add/remove commands
pnpm add <TAB> # Shows installed packages
pnpm remove <TAB> # Shows installed packages

Enhanced completions for monorepo setups:

Terminal window
# Workspace filtering
pnpm --filter my-app run build
pnpm --filter "packages/*" run test
pnpm --filter "!packages/docs" run lint
# Tab provides workspace-aware completions for:
# - Workspace names
# - Workspace patterns
# - Workspace-specific scripts

Completions adapt based on your project context:

Terminal window
# In a TypeScript project
pnpm tsc --target <TAB> # Shows: es2020, es2021, es2022, etc.
# In a Vite project
pnpm vite build --mode <TAB> # Shows: development, production, etc.
# In a React project
pnpm create-react-app <TAB> # Shows: my-app, my-component, etc.
Terminal window
# Enhanced workspace commands
pnpm workspace <TAB> # Shows workspace commands
pnpm --filter <TAB> # Shows workspace names and patterns
# Advanced install options
pnpm add --save-dev <TAB> # Shows dependency types
pnpm install --frozen-lockfile # Shows install options
Terminal window
# Config management
npm config get <TAB> # Shows config keys
npm config set <TAB> # Shows config keys
# Package management
npm install --save-dev <TAB> # Shows dependency types
npm run <TAB> # Shows scripts with descriptions
Terminal window
# Workspace operations
yarn workspace <TAB> # Shows workspace commands
yarn workspaces <TAB> # Shows workspace operations
# Cache management
yarn cache <TAB> # Shows cache operations
yarn cache list # Shows cached packages
Terminal window
# Runtime commands
bun run <TAB> # Shows scripts
bun x <TAB> # Shows available binaries
# Development features
bun dev <TAB> # Shows dev commands
bun test <TAB> # Shows test options
Terminal window
# Debug mode for troubleshooting
export DEBUG=1
# Custom timeout for slow completions
export TAB_COMPLETION_TIMEOUT=3000
# Disable automatic discovery (fallback to basic completions)
export TAB_DISABLE_DISCOVERY=1

For large projects, you can optimize performance:

Terminal window
# Increase timeout for projects with many dependencies
export TAB_COMPLETION_TIMEOUT=5000
# Cache completions (experimental)
export TAB_CACHE_COMPLETIONS=1
Terminal window
# Increase timeout
export TAB_COMPLETION_TIMEOUT=3000
# Check for slow CLI tools
DEBUG=1 tab pnpm complete -- --help
Terminal window
# Test CLI compatibility
my-cli complete -- --help
# Check if CLI follows Tab protocol
# Should output completions ending with :{number}
Terminal window
# Verify workspace configuration
cat package.json | grep workspaces
# Check workspace structure
ls packages/ # Should show workspace directories

Enable detailed logging:

Terminal window
# Full debug output
DEBUG=1 tab pnpm complete -- --help
# Check discovery process
DEBUG=1 tab pnpm complete -- vite dev

For advanced users, you can extend Tab’s completion handlers by modifying the source:

tab/bin/completion-handlers.ts
# The completion handlers are in:
# tab/bin/package-manager-completion.ts

Tab works alongside other completion tools:

Terminal window
# Use with existing pnpm completions
source <(pnpm completion)
# Tab enhances existing completions
# rather than replacing them

Stick to one package manager per project for the best experience.

Regularly update your CLI tools to ensure Tab compatibility.

Terminal window
# Test completions in your specific projects
tab pnpm complete -- --help
pnpm vite complete -- --help

Share your Tab setup to ensure consistent experience across your team.