npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

claude-code-env

v1.0.0

Published

CLI tool to switch AI providers for Claude Code

Downloads

5

Readme

Claude Code Environment Manager (ccenv)

A command-line tool to easily switch between different AI providers for Claude Code by managing the ~/.claude/settings.json configuration.

Features

  • Switch between multiple AI providers with a single command
  • Support for both direct provider APIs and PPINFRA proxy
  • Automatic environment variable management
  • Secure token handling with masked output
  • Easy configuration through JSON file

Installation

Local Development

# Clone the repository
git clone <your-repo-url>
cd claude-code-env

# Install dependencies
npm install

# Build the project
npm run build

# Link globally to use 'ccenv' command
npm link

Global Installation (After Publishing)

npm install -g claude-code-env

Configuration

The tool supports two ways to configure API tokens (in priority order):

1. Environment Variables (Recommended)

Set environment variables before running the command:

# Export variables in your shell
export DEEPSEEK_AUTH_TOKEN="your_actual_deepseek_api_token"
export KIMI_AUTH_TOKEN="your_actual_kimi_api_token"
export GLM_AUTH_TOKEN="your_actual_glm_api_token"

# Then run ccenv
ccenv deepseek

Or set them inline:

DEEPSEEK_AUTH_TOKEN="your_token" ccenv deepseek

2. Configuration File (Fallback)

If environment variables are not set, the tool falls back to src/base.json:

{
  "DEEPSEEK": {
    "DEEPSEEK_AUTH_TOKEN": "your_actual_deepseek_api_token",
    ...
  },
  "KIMI": {
    "KIMI_AUTH_TOKEN": "your_actual_kimi_api_token",
    ...
  },
  ...
}

After updating the tokens in base.json, rebuild the project:

npm run build

Priority: Environment variables take precedence over base.json values.

Usage

Basic Commands

# Show help
ccenv help

# Switch to a provider
ccenv deepseek      # Switch to DeepSeek
ccenv glm           # Switch to GLM-4.6
ccenv kimi          # Switch to Kimi
ccenv qwen          # Switch to Alibaba Qwen
ccenv minimax       # Switch to MiniMax
ccenv longcat       # Switch to LongCat

# Use PPINFRA proxy
ccenv pp kimi       # Switch to PPINFRA Kimi
ccenv pp deepseek   # Switch to PPINFRA DeepSeek
ccenv pp glm        # Switch to PPINFRA GLM
ccenv pp qwen       # Switch to PPINFRA Qwen
ccenv pp minimax    # Switch to PPINFRA MiniMax

# Clear configuration
ccenv clear         # Clear all environment variables

# Dynamic providers (any provider not in base.json)
ZAI_AUTH_TOKEN="your_token" ZAI_BASE_URL="https://api.z.ai/api/anthropic" ccenv zai

Dynamic Provider Support

You can use any provider not defined in base.json by setting environment variables:

# Minimum required variables
PROVIDER_AUTH_TOKEN="your_token" \
PROVIDER_BASE_URL="https://api.provider.com/anthropic" \
ccenv provider

# With optional model configuration
PROVIDER_AUTH_TOKEN="your_token" \
PROVIDER_BASE_URL="https://api.provider.com/anthropic" \
PROVIDER_MODEL="model-name" \
PROVIDER_SMALL_FAST_MODEL="fast-model" \
ccenv provider

Example with ZAI:

ZAI_AUTH_TOKEN="your_zai_token" \
ZAI_BASE_URL="https://api.z.ai/api/anthropic" \
ZAI_MODEL="claude-sonnet-4-5" \
ccenv zai

This allows you to use any Anthropic-compatible API provider without modifying the code.

Workflow Example

# Switch to DeepSeek provider
ccenv deepseek

# Launch Claude Code
# Claude Code will now use DeepSeek API

# Switch to PPINFRA Kimi
ccenv pp kimi

# Relaunch Claude Code
# Claude Code will now use PPINFRA with Kimi model

# Clear configuration when done
ccenv clear

Supported Providers

Direct Provider APIs

| Provider | Command | Base URL | Default Model | |----------|---------|----------|---------------| | DeepSeek | ccenv deepseek | https://api.deepseek.com/anthropic | deepseek-chat | | Kimi | ccenv kimi | https://api.moonshot.cn/anthropic | kimi-k2-turbo-preview | | GLM | ccenv glm | https://open.bigmodel.cn/api/anthropic | glm-4.6 | | Qwen | ccenv qwen | https://dashscope.aliyuncs.com/compatible-mode/anthropic | qwen3-max | | MiniMax | ccenv minimax | https://api.minimax.io/anthropic | MiniMax-M2 | | LongCat | ccenv longcat | https://api.longcat.chat/anthropic | LongCat-Flash-Thinking |

PPINFRA Providers

All PPINFRA providers use https://api.ppinfra.com/anthropic as the base URL.

| Command | Model | |---------|-------| | ccenv pp deepseek | deepseek/deepseek-v3.2-exp | | ccenv pp kimi | kimi-k2-turbo-preview | | ccenv pp glm | zai-org/glm-4.6 | | ccenv pp qwen | qwen3-next-80b-a3b-thinking | | ccenv pp minimax | minimax/minimax-m2 |

How It Works

  1. The tool reads provider configurations from src/base.json
  2. When you run a command (e.g., ccenv deepseek), it:
    • Reads the current ~/.claude/settings.json
    • Converts provider-specific environment variables to Anthropic format:
      • DEEPSEEK_AUTH_TOKENANTHROPIC_AUTH_TOKEN
      • DEEPSEEK_BASE_URLANTHROPIC_BASE_URL
      • DEEPSEEK_MODELANTHROPIC_MODEL
      • DEEPSEEK_SMALL_FAST_MODELANTHROPIC_SMALL_FAST_MODEL
    • Adds API_TIMEOUT_MS set to 3000000 (3000 seconds)
    • Writes the updated configuration back to ~/.claude/settings.json
  3. When you launch Claude Code, it reads these environment variables and uses the configured provider

Environment Variables Set

Each provider configuration sets the following environment variables in ~/.claude/settings.json:

{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "your_api_key",
    "ANTHROPIC_BASE_URL": "https://api.provider.com/anthropic",
    "ANTHROPIC_MODEL": "model-name",
    "ANTHROPIC_SMALL_FAST_MODEL": "fast-model-name",
    "API_TIMEOUT_MS": "3000000"
  }
}

Development

# Run in development mode
npm run dev help

# Build the project
npm run build

# Run built version
npm start help

# Test the built CLI
node dist/index.js help

Project Structure

claude-code-env/
├── src/
│   ├── index.ts        # Main CLI implementation
│   └── base.json       # Provider configurations
├── dist/               # Compiled JavaScript (generated)
├── docs/
│   ├── docs.md         # Implementation guide
│   └── sample.sh.txt   # Reference configuration
├── package.json
├── tsconfig.json
└── README.md

Environment Variables Reference

The tool reads the following environment variables (provider-specific):

Regular Providers

  • DEEPSEEK_AUTH_TOKEN, DEEPSEEK_BASE_URL, DEEPSEEK_MODEL, DEEPSEEK_SMALL_FAST_MODEL
  • KIMI_AUTH_TOKEN, KIMI_BASE_URL, KIMI_MODEL, KIMI_SMALL_FAST_MODEL
  • GLM_AUTH_TOKEN, GLM_BASE_URL, GLM_MODEL, GLM_SMALL_FAST_MODEL
  • QWEN_AUTH_TOKEN, QWEN_BASE_URL, QWEN_MODEL, QWEN_SMALL_FAST_MODEL
  • MINIMAX_AUTH_TOKEN, MINIMAX_BASE_URL, MINIMAX_MODEL, MINIMAX_SMALL_FAST_MODEL
  • LONGCAT_AUTH_TOKEN, LONGCAT_BASE_URL, LONGCAT_MODEL, LONGCAT_SMALL_FAST_MODEL

PPINFRA Providers

  • PPINFRA_AUTH_TOKEN, PPINFRA_BASE_URL
  • PPINFRA_DEEPSEEK_MODEL, PPINFRA_DEEPSEEK_SMALL_FAST_MODEL
  • PPINFRA_KIMI_MODEL, PPINFRA_KIMI_SMALL_FAST_MODEL
  • PPINFRA_GLM_MODEL, PPINFRA_GLM_SMALL_FAST_MODEL
  • PPINFRA_QWEN_MODEL, PPINFRA_QWEN_SMALL_FAST_MODEL
  • PPINFRA_MINIMAX_MODEL, PPINFRA_MINIMAX_SMALL_FAST_MODEL

Security

  • API tokens can be stored in environment variables (recommended) or src/base.json
  • Environment variables take priority over base.json for better security
  • Token values are masked in console output (shows first 10 characters only)
  • Configuration is stored locally in ~/.claude/settings.json
  • Add src/base.json to .gitignore to avoid committing secrets

Troubleshooting

Command not found: ccenv

Run npm link again in the project directory.

Settings not updating

  1. Check if ~/.claude directory exists
  2. Verify you have write permissions to ~/.claude/settings.json
  3. Try running with sudo if on Linux/Mac

Provider not working

  1. Verify your API token is correctly set in src/base.json
  2. Rebuild the project: npm run build
  3. Check the base URL is correct for your provider
  4. Ensure Claude Code is restarted after switching providers

License

ISC

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.