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

@baizor/cc-switch

v0.1.14

Published

Manage multiple Claude Code subscription OAuth tokens from a TypeScript CLI.

Readme

cc-switch

npm version Publish to npm license Node.js

Animated cc-switch terminal dashboard showing token rotation and quota telemetry

cc-switch is a TypeScript CLI for managing multiple Claude Code subscription OAuth tokens.

It uses only official Claude Code status-line telemetry. The collector records rate_limits snapshots when Claude Code passes them to a status-line command; it does not call undocumented quota endpoints.

Install

npm install -g @baizor/cc-switch

Quick Start

  1. Generate a Claude Code OAuth token:
claude setup-token

Approve the browser prompt, then copy the token printed in the terminal.

  1. Add the subscription to cc-switch:
cc-switch add subscription

Paste the token when prompted. Repeat claude setup-token and cc-switch add subscription for each Claude subscription account you want to manage.

  1. Install the Claude Code status-line collector:
cc-switch install status-line

This lets cc-switch receive official Claude Code rate_limits telemetry. Restart Claude Code, or send one prompt in a trusted workspace, so Claude Code emits fresh status-line data.

  1. Install the background monitor service:
cc-switch install service

On Windows, run this from an Administrator PowerShell if Task Scheduler reports Access is denied.

  1. Check setup:
cc-switch doctor status-line
cc-switch service status
  1. Open the dashboard:
cc-switch

The dashboard should show your active subscription, stored telemetry, reset time, service status, and switch decision.

Commands

cc-switch
cc-switch config
cc-switch add subscription
cc-switch remove subscription 1
cc-switch list subscriptions
cc-switch status
cc-switch switch 0
cc-switch install service
cc-switch uninstall service
cc-switch service status
cc-switch install status-line

Configuration

By default, configuration is stored at ~/.cc-switch/.env and state at ~/.cc-switch/state.json.

Important .env keys:

CC_SWITCH_TOKENS=["token-one","token-two"]
CC_SWITCH_TOKEN_LABELS=["Work","Personal"]
CC_SWITCH_POLL_SECONDS=60
CC_SWITCH_FIVE_HOUR_MIN_LEFT_PERCENT=10
CC_SWITCH_WEEKLY_MIN_LEFT_PERCENT=10
CC_SWITCH_SWITCHING_MODE=env
CC_SWITCH_LOG_LEVEL=info
CC_SWITCH_SERVICE_AUTOSTART=true
CC_SWITCH_STATE_PATH=
CC_SWITCH_CREDENTIALS_PATH=

env mode writes the active token into cc-switch managed environment files and uses setx on Windows for new shells. credentials-file mode is experimental and writes a guarded JSON credentials file only when explicitly enabled.

A claude setup-token token carries no refresh token, and CLAUDE_CODE_OAUTH_TOKEN takes priority over ~/.claude/.credentials.json. So when a token added to env mode expires, every new Claude Code session fails with 401 OAuth access token has expired and /login does not help while the variable is still set: it overrides the freshly refreshed credentials file. Recover by clearing the user-level variable, then either issue a new token with claude setup-token or use credentials-file mode, which switches refreshable credentials.

[Environment]::SetEnvironmentVariable('CLAUDE_CODE_OAUTH_TOKEN', $null, 'User')

Experimental Ongoing-Session Switching

CLAUDE_CODE_OAUTH_TOKEN is the documented switching path, but already-running Claude Code sessions may not reload environment variables. For experiments, credentials-file mode can switch the full Claude Code /login profile stored in ~/.claude/.credentials.json.

For each subscription:

claude auth login
cc-switch import credentials 0

Repeat with the matching subscription index after logging Claude Code into each account. Then set CC_SWITCH_SWITCHING_MODE=credentials-file in cc-switch config.

This stores the full claudeAiOauth object, including refresh tokens when present, inside ~/.cc-switch/state.json. Keep that file private. This mode edits an undocumented Claude Code implementation file and may require restarting Claude Code if the running process keeps credentials in memory.

Status-Line Collector

Quota telemetry reaches cc-switch only through the Claude Code status line, so the collector installs itself when the dashboard starts and when the background service is installed. The dashboard menu carries an explicit entry too, and the header shows whether Claude Code currently runs the collector - read from settings.json, not from a cached flag.

cc-switch install status-line
cc-switch uninstall status-line

Installing wraps an existing Claude Code statusLine command if one is present and forwards its output unchanged while recording official rate_limits snapshots. Re-running the install collapses an earlier collector instead of nesting a second one inside it. Uninstalling puts the wrapped command back.

Verify the integration:

cc-switch doctor status-line

Restart Claude Code, or send one prompt in a trusted Claude Code workspace, so Claude Code emits fresh status-line telemetry. rate_limits appears only for Claude.ai Pro/Max subscribers after the first API response.

Background Service

Install the per-user monitor:

cc-switch install service

Check it:

cc-switch service status

Remove it:

cc-switch uninstall service

On Windows, Task Scheduler may require an elevated PowerShell. If install reports Access is denied, open PowerShell as Administrator and rerun:

cc-switch install service

The service does not fetch Claude Code quota data by itself. It watches the telemetry stored by the status-line collector and switches when configured thresholds are crossed.

Publishing

This package is configured for npm Trusted Publishing through .github/workflows/publish.yml.

On npmjs.com, configure the trusted publisher for @baizor/cc-switch with:

  • Publisher: GitHub Actions
  • Organization or user: IvanMurzak
  • Repository: Claude-Subscription-Switcher
  • Workflow filename: publish.yml
  • Allowed action: npm publish

For the first manual publish, run npm publish --access public from a local npm login. Do not enable local provenance for this first publish; provenance is generated by the GitHub Actions trusted publisher after npm is configured.

After the trusted publisher is configured, publish by running the Publish to npm workflow manually from GitHub Actions. When npm publish succeeds, the workflow creates a matching GitHub Release named v<package.json version> with GitHub-generated release notes.

You can also publish by creating a GitHub Release first. In that case, the release tag must match the package version, for example v0.1.4.