Skip to content

afa5e/claudeUtils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

claudeUtils

Claude Code utilities: auto-switching subscription proxy + system tray usage monitor.

Claude Code --> claudeUtils proxy (localhost:3456) --> api.anthropic.com
                    |
                    +-- account A rate-limited? --> try account B
                    +-- all base exhausted?     --> escalate to extra-usage tier
                    +-- all exhausted?          --> return 429 with reset time

The tray app sits in your system tray, shows live rate-limit usage, and manages the proxy -- start/stop, view logs, see active account. The proxy runs invisibly as a subprocess.

Quick Start

cd ~/ClaudeSwitcher
pip install -r requirements.txt

# Import your current subscription
node src/index.js add --from-credentials --label my-max

# Wire Claude Code to use the proxy
node src/index.js setup

# Launch the tray app (starts proxy automatically)
pythonw tray/tray_app.py

Auto-start on login

Create a shortcut to pythonw tray/tray_app.py and drop it in shell:startup.

Tray App

Right-click the tray icon for:

  • Show Usage -- popup with 5-hour, weekly, and Sonnet rate limit bars
  • Refresh Now -- re-scrape claude.ai for fresh usage data
  • Poll Frequency -- how often to auto-scrape (30s to 10m)
  • Proxy submenu:
    • Active account label (dynamic)
    • Start/Stop Proxy
    • Open Logs -- opens data/proxy.log in your editor

Left-click opens the usage popup. On quit, the proxy is stopped automatically.

Adding Accounts

Import from active Claude Code session:

node src/index.js add --from-credentials --label personal-max --priority 0

Add a pay-as-you-go API key:

node src/index.js add --type apikey --label backup-key --priority 2

Add as extra-usage tier (only used after all base accounts are exhausted):

node src/index.js add --from-credentials --label my-max-extra --priority 10 --extra

How the Proxy Works

  1. Claude Code sends a request to the proxy (via ANTHROPIC_BASE_URL)
  2. Proxy injects the active account's credentials and forwards to Anthropic
  3. If Anthropic returns 429 (rate limited):
    • Marks that account as rate-limited
    • Picks the next available account by priority
    • Retries the request -- Claude Code never sees the 429
  4. If all base accounts are rate-limited, auto-escalates to extra-usage tier
  5. If everything is exhausted, returns 429 with the earliest reset time

Responses stream through immediately (no buffering) -- SSE works correctly.

Tiers

Accounts have a tier (base or extra). The proxy exhausts all base-tier accounts before touching extra-tier ones. Burn through included quotas first, fall back to paid extra usage only when necessary.

node src/index.js tier my-max-extra extra

Proxy Commands

Command Description
start Start the proxy (default port 3456)
add --from-credentials Import current .credentials.json
add --type apikey Add an API key
list Show all accounts with status
status Proxy health, active account, rate limits
remove <label|id> Remove an account
priority <label|id> <n> Change priority (0 = tried first)
tier <label|id> <base|extra> Change account tier
enable / disable <label|id> Toggle an account
setup Wire Claude Code to use the proxy
teardown Disconnect Claude Code from proxy
bypass Emergency: disable proxy, restore direct connection
restore Re-enable proxy after bypass

All commands: node src/index.js <command>

Emergency Bypass

If the proxy breaks or causes issues, bypass it instantly:

node src/index.js bypass

# Or via PowerShell (works even if Node is broken)
powershell -File scripts/bypass.ps1

This removes ANTHROPIC_BASE_URL from Claude Code's settings. New sessions go straight to Anthropic. Reverse with node src/index.js restore or scripts/restore.ps1.

File Layout

src/                 # Node.js proxy
tray/                # Python tray app + usage monitor
  tray_app.py        # entry point (run with pythonw)
  proxy_manager.py   # manages proxy subprocess
  popup_window.py    # usage popup UI
  scraper.py         # claude.ai usage scraper
scripts/             # PowerShell bypass/restore
data/                # runtime data (gitignored)
  accounts.json      # credential store
  state.json         # rate-limit tracking
  proxy.log          # log file (rotates at 5 MB)

Requirements

  • Node.js >= 18 (proxy, zero npm dependencies)
  • Python >= 3.11 (tray app)
  • pip install -r requirements.txt

About

Auto-switching proxy for multiple Claude subscriptions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors