Skip to content

nikzdevz/ClaudeAPISwitchCLI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ClaudeAPISwitchCLI

A small Node.js CLI for saving multiple Claude-related API keys locally and switching the active key across Claude Code config files.

Recommended Setup

This project is meant to be installed with the included Windows setup script:

setup-apikey.bat

That batch file is the main setup path for this repository. It installs dependencies, installs the CLI globally, and adds the required npm global path to the system PATH so the apikey command works from any terminal.

How To Install

  1. Download or clone the repository.
  2. Right-click setup-apikey.bat and run it.
  3. If Windows asks for permission, allow it.
  4. Restart your terminal after setup finishes.

After that, use:

apikey

What It Does

  • Stores named API keys in a local JSON file under %APPDATA%\apikey\keys.json
  • Switches the active key in:
    • ~/.claude/settings.json via env.ANTHROPIC_AUTH_TOKEN
    • ~/.claude.json via mcpServers.OpusMax.env.OPUSMAX_API_KEY
  • Provides interactive commands for adding, listing, switching, removing, and checking the current key

Project Structure

  • src/index.js: CLI entrypoint and interactive command flow
  • src/store.js: local key storage and CRUD operations
  • src/config.js: reads and updates Claude config files
  • setup-apikey.bat: Windows-focused setup helper for global installation

Quick Analysis

This project is intentionally small and easy to follow. The design is straightforward:

  1. store.js persists named keys to a JSON file in the user's profile.
  2. config.js reads and rewrites the Claude config files synchronously.
  3. index.js exposes the user-facing commands and prompts.

Strengths

  • Clear separation between CLI flow, storage, and config mutation
  • Very small surface area, so maintenance is simple
  • Interactive UX is easy for non-technical users

Current Risks / Limitations

  • Keys are stored in plain text on disk
  • The current command prints the full active key instead of masking it
  • The config update paths are hard-coded to the current Claude file layout
  • There are no automated tests yet
  • The setup script is Windows-specific

Usage

Example Commands

apikey add work sk-ant-...
apikey list
apikey switch
apikey current
apikey remove work

Notes

  • setup-apikey.bat is the intended installation method for this repo.
  • The setup script is Windows-specific.
  • The script installs the CLI globally and updates the environment so apikey can be run directly.

Publishing Notes

This repository excludes node_modules and keeps the project source, setup script, and continuity notes needed for future handoff.

License

MIT

About

CLI tool to manage and switch Claude API keys across Claude Code config files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors