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

@jigonr/claude-switch

v0.1.0

Published

Simple API provider switcher for Claude Code CLI

Readme

claude-switch

Simple API provider switcher for Claude Code CLI

A lightweight, secure CLI tool to seamlessly switch between different API providers for Claude Code: Claude Pro subscription, Anthropic API, and z.ai (GLM models).

CI codecov npm version License: MIT

Built for Claude Code CLI

Features

  • 🔄 Simple Provider Switching - Switch between 3 providers with one command
  • 🔒 Security First - Separate credential storage with proper permissions
  • 📁 Project-Aware - Auto-detects project-specific configs
  • ⚡ Fast - Built with Bun and TypeScript for optimal performance
  • 🛡️ Type-Safe - Zod schema validation for all configurations
  • 📦 Zero Config - Works out of the box with sensible defaults

Supported Providers

| Provider | Type | Description | |----------|------|-------------| | claude-pro-max | Subscription | Claude Pro via browser authentication | | anthropic | API | Official Anthropic API | | z.ai | API | z.ai API with GLM models |

Installation

# Using npm
npm install -g @jigonr/claude-switch

# Using bun
bun add -g @jigonr/claude-switch

# Using yarn
yarn global add @jigonr/claude-switch

Quick Start

# Show current provider
claude-switch

# Switch to a provider
claude-switch claude-pro-max
claude-switch anthropic
claude-switch z.ai

# List all available providers
claude-switch list

# Show detailed status
claude-switch status

# Import from bash script configuration
claude-switch import-bash

Usage

Basic Commands

Switch Provider

# Switch to Claude Pro subscription
claude-switch claude-pro-max

# Switch to Anthropic API
claude-switch anthropic

# Switch to z.ai (GLM models)
claude-switch z.ai

List Providers

claude-switch list

Output:

Available Providers:

  ● claude-pro-max
    Claude Pro subscription (browser-based)
    Type: subscription

  ○ anthropic
    Anthropic official API
    Type: api

  ○ z.ai
    z.ai API (GLM models)
    Type: api

Current: claude-pro-max

Show Status

claude-switch status

Output:

Current Provider:

  claude-pro-max
  Claude Pro subscription (browser-based)
  Type: subscription

Advanced Usage

Project-Specific Configuration

Create a .claude-switch.json file in your project root:

{
  "provider": "z.ai",
  "inherits": "~/.claude/switch-config.json"
}

claude-switch will automatically detect and use this configuration when run from within the project directory.

Import from Bash Script

If you're migrating from the bash version of claude-switch:

claude-switch import-bash

This will:

  • Import your ~/.claude/glm-config.json settings
  • Extract and securely store your z.ai API key
  • Create the new configuration format
  • Preserve your model preferences

Configuration

Global Configuration

Location: ~/.claude/switch-config.json

{
  "version": "1.0",
  "currentProvider": "claude-pro-max",
  "providers": {
    "claude-pro-max": {
      "type": "subscription",
      "description": "Claude Pro subscription (browser-based)",
      "settings": {
        "env": {
          "API_TIMEOUT_MS": "3000000"
        }
      }
    },
    "anthropic": {
      "type": "api",
      "description": "Anthropic official API",
      "settings": {
        "env": {
          "ANTHROPIC_API_KEY_FILE": "~/.claude/credentials/anthropic.key",
          "API_TIMEOUT_MS": "3000000"
        }
      }
    },
    "z.ai": {
      "type": "api",
      "description": "z.ai API (GLM models)",
      "settings": {
        "env": {
          "ANTHROPIC_API_KEY_FILE": "~/.claude/credentials/zai.key",
          "API_TIMEOUT_MS": "3000000",
          "ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-4.7",
          "ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-4.7",
          "ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-4.5-air"
        }
      }
    }
  }
}

Credential Storage

API keys are stored separately from configuration:

~/.claude/credentials/
├── anthropic.key  (chmod 600)
└── zai.key        (chmod 600)

Security Note: Never commit credential files to version control!

Security

API Key Storage

BAD - Don't store API keys in config files:

{
  "provider": "anthropic",
  "apiKey": "sk-ant-..."  // NEVER DO THIS
}

GOOD - Store keys in separate files:

# Create credentials directory
mkdir -p ~/.claude/credentials

# Store API key securely
echo "your-api-key-here" > ~/.claude/credentials/anthropic.key
chmod 600 ~/.claude/credentials/anthropic.key

File Permissions

Ensure proper permissions on credential files:

chmod 600 ~/.claude/credentials/*.key

Project Configurations

Never commit project-specific configs with sensitive data:

# Add to .gitignore
echo ".claude-switch.json" >> .gitignore

Development

Prerequisites

  • Node.js ≥ 18.0.0
  • Bun ≥ 1.0.0 (recommended) or npm

Setup

# Clone the repository
git clone https://github.com/jigonr/claude-switch.git
cd claude-switch

# Install dependencies
bun install

# Build
bun run build

# Run tests
bun run test

# Lint
bun run lint

# Type check
bun run typecheck

Project Structure

claude-switch/
├── src/
│   ├── commands/           # CLI commands
│   │   ├── switch.ts       # Provider switching logic
│   │   ├── list.ts         # List providers
│   │   └── import.ts       # Import from bash
│   ├── config/             # Configuration management
│   │   ├── schema.ts       # Zod schemas
│   │   ├── manager.ts      # Config I/O
│   │   └── detector.ts     # Project config detection
│   ├── providers/          # Provider type definitions
│   ├── utils/              # Utilities (logger, errors)
│   └── index.ts            # CLI entry point
├── tests/
│   ├── integration/        # Integration tests
│   └── unit/               # Unit tests
└── dist/                   # Built output

Running Tests

# Run all tests
bun run test

# Run with coverage
bun run test:coverage

# Watch mode
bun run test:watch

Troubleshooting

Provider switch doesn't take effect

Make sure you're switching before launching Claude Code:

claude-switch anthropic
claude  # Now launches with Anthropic API

API key not found

Verify your API key is stored correctly:

# Check file exists and has correct permissions
ls -la ~/.claude/credentials/

# Should show:
# -rw------- 1 user user ... anthropic.key
# -rw------- 1 user user ... zai.key

Config validation errors

Reset to default configuration:

# Backup current config
mv ~/.claude/switch-config.json ~/.claude/switch-config.json.bak

# Let claude-switch create a new default
claude-switch list

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details.

Development Workflow

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests (bun run test)
  5. Run linter (bun run lint:fix)
  6. Commit your changes (git commit -m 'feat: add amazing feature')
  7. Push to the branch (git push origin feature/amazing-feature)
  8. Open a Pull Request

License

MIT © J.I. Gonzalez-Rojas

Acknowledgments

Roadmap

  • [ ] Interactive TUI with Ink
  • [ ] Shell completion (bash, zsh, fish)
  • [ ] Validation command for credentials
  • [ ] Doctor command for diagnostics
  • [ ] Support for custom providers
  • [ ] Configuration profiles management

Related Projects

  • letta-switch - Comprehensive configuration manager for Letta CLI (agents + models + memory blocks)

Made with ❤️ for the Claude Code community