ccenv
v1.3.0
Published
Claude Code environment variable switcher
Maintainers
Readme
ccenv
🚀 Interactive CLI tool for switching Claude Code environment variables quickly and seamlessly.
✨ New in v1.1.0: Interactive list navigation with arrow keys for seamless environment switching!

✨ Key Features
- 🎯 Interactive Navigation - Use arrow keys to browse and select environments
- ⚡ Instant Switching - One keystroke to change your entire Claude Code environment
- 🔄 Automatic Application - Environment variables applied immediately (with shell integration)
- 💾 Persistent Sessions - New terminals remember your last environment
- 📁 Project-aware - Automatically switch environments when entering project directories
- 🔧 Shell Integration - Works seamlessly with zsh, bash, and other shells
- 🎨 Beautiful UI - Colorful, intuitive command-line interface
Quick Start
1. Install
npm install -g ccenv
# or
pnpm install -g ccenv2. Add Environment Configuration
ccenv add work
# Interactive prompts for ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY3. Install Shell Integration (Recommended)
ccenv install
# Auto-detects and configures zsh/bash integration
source ~/.zshrc # or source ~/.bashrc4. Switch Environment
🎯 Interactive Mode (Recommended)
ccenv list -i
# Navigate with ↑↓ arrow keys
# Press Enter to select environment
# ✓ Switched to environment: work
# 🎉 Environment variables automatically applied!⚡ Direct Switch
ccenv use work
# ✓ Applied ccenv environment: work
# Environment variables automatically applied to current shellUsage
Core Commands
# Add new environment
ccenv add <name>
# 🎯 Interactive list (navigate with arrow keys)
ccenv list -i
ccenv list --interactive
# List all environments (traditional view)
ccenv list
# Switch environment (auto-apply with shell integration)
ccenv use <name>
# Show current environment
ccenv current
# Export environment variables
ccenv current --export🎯 Interactive Features
Navigate environments with ease using arrow keys:
ccenv list -iWhat you get:
- ↑↓ Arrow key navigation through all environments
- 📋 Live preview of Base URL and API Key (masked)
- ⚡ Instant switching - just press Enter to select
- 🔄 Automatic application of environment variables (with shell integration)
- 🔙 Easy exit - select "← Back" to return to standard list
Demo:
? Select an environment to switch to: (Use arrow keys)
❯ work (current)
https://api.anthropic.com | sk-123...
personal
https://api.personal.com | sk-456...
mirror
https://api.mirror.com | sk-789...
← Back (just list)Shell Integration Features
After installing shell integration, you get these automated features:
Auto-apply Environment Variables
ccenv use work # Direct command mode ccenv list -i # Interactive mode # Both automatically set environment variables, no manual eval needed!Persistent Environment
# New terminals automatically restore last environment echo $ANTHROPIC_BASE_URL # Auto-loadedProject-level Environment
# Create .ccenv file in project directory echo "work" > .ccenv cd project # Automatically switches to work environment
Manual Integration
If you prefer not to install automatic integration:
# Manually apply to current shell
eval "$(ccenv current --export)"
# Or load specific environment
eval "$(ccenv use work --source)"Environment Variables
ccenv manages these environment variables for Claude Code:
ANTHROPIC_BASE_URL- Anthropic API base URLANTHROPIC_API_KEY- Anthropic API key
Configuration Files
~/.ccenv/config.json- Environment configurations~/.ccenv/current_env- Current environment persistence file.ccenv- Project-level environment configuration file
Example Workflow
# Set up multiple environments
ccenv add work
ccenv add personal
ccenv add mirror
# Install automation
ccenv install
# 🎯 Interactive mode - navigate with arrow keys
ccenv list -i
# Select environment with Enter key
# ✓ Switched to environment: work
# 🎉 Environment variables automatically applied!
# Or direct command mode
ccenv use work
echo $ANTHROPIC_BASE_URL # https://api.work.com
# New terminals automatically restore environment
# Projects with .ccenv files auto-switch environmentsDevelopment
Setup
# Clone repository
git clone <repository-url>
cd ccenv
# Install dependencies
pnpm install
# Development mode
pnpm dev <command> [args]
# Example: pnpm dev add test
# Build TypeScript to JavaScript
pnpm build
# Test built CLI
node dist/index.js --helpProject Structure
ccenv/
├── src/
│ ├── commands/ # CLI command implementations
│ ├── config/ # Configuration management
│ ├── index.ts # CLI entry point
│ └── types.ts # TypeScript interfaces
├── dist/ # Built JavaScript files
├── package.json
└── tsconfig.jsonArchitecture
- CLI Framework: Commander.js for argument parsing
- Interactive Prompts: Inquirer.js for user input
- Configuration: JSON files in
~/.ccenv/ - Shell Integration: Dynamic script generation following volta/bun patterns
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Run
pnpm buildto ensure it compiles - Test with
node dist/index.js - Submit a pull request
