A CLI tool to manage and run Claude Code with different contexts.
- List available contexts from a configuration file
- Run Claude Code with a specific context temporarily
- Support for environment variables in authentication tokens for enhanced security
go install github.com/dsdashun/ccctx@latestThe tool looks for a configuration file at ~/.ccctx/config.toml. If it doesn't exist, it will be created with a default example.
Example configuration:
[context.work]
base_url = "https://api.anthropic.com"
auth_token = "work-token-here"
model = "claude-3-5-sonnet-20241022"
[context.personal]
base_url = "https://api.anthropic.com"
auth_token = "env:ANTHROPIC_PERSONAL_TOKEN"
model = "claude-3-5-haiku-20241022"
small_fast_model = "claude-3-5-haiku-20241022"
[context.staging]
base_url = "https://api.anthropic.com"
auth_token = "env:ANTHROPIC_STAGING_TOKEN"# List available contexts
ccctx list
# Run Claude with a context (interactive mode with arrow keys)
ccctx run
# Run Claude with a specific context
ccctx run personal
# Run Claude with a specific context and additional arguments
ccctx run personal -- --help
# Run Claude in interactive mode with additional arguments
ccctx run -- --version
# Run Claude with model specification
ccctx run -- --model=xxxxxThe run command executes Claude with the specified context environment variables without affecting your current shell environment.
In interactive mode (when no context name is provided), you can:
- Use arrow keys (↑ ↓) or vim keys (j/k) to navigate between contexts
- Press Enter to select the highlighted context
- Press ESC to cancel the operation
- The interface is now powered by tview for a richer terminal experience
All arguments after the -- separator are forwarded to Claude, allowing you to use Claude's full functionality.
For example: ccctx run personal -- --help or ccctx run -- --version
You can optionally specify model preferences for each context using the model and small_fast_model fields:
[context.production]
base_url = "https://api.anthropic.com"
auth_token = "env:ANTHROPIC_API_KEY"
model = "claude-3-5-sonnet-20241022"
small_fast_model = "claude-3-5-haiku-20241022"When these fields are provided:
modelsets theANTHROPIC_MODELenvironment variablesmall_fast_modelsets theANTHROPIC_SMALL_FAST_MODELenvironment variable- Both fields are optional - if not provided, the environment variables won't be set
For enhanced security, you can use environment variables instead of hardcoding authentication tokens in your configuration file. Use the env: prefix followed by the environment variable name:
[context.production]
base_url = "https://api.anthropic.com"
auth_token = "env:ANTHROPIC_API_KEY"When using this format:
- The tool will read the value from the specified environment variable
- If the environment variable is not set or empty, an error will be displayed
- This prevents accidentally committing sensitive tokens to version control
Important: Make sure to export the environment variable in your shell:
export ANTHROPIC_API_KEY="your-api-key-here"
# Or add to your ~/.bashrc fileCCCTX_CONFIG_PATH: Override the default config file path (~/.ccctx/config.toml)