Credentials Manager for Claude Code — multi-token OAuth rotation and autonomous runner
Project description
Credentials Manager for Claude Code
Manages multiple Claude Code OAuth tokens across subscriptions, auto-rotates on
rate limit without losing session context, and tracks per-credential usage via
hooks. Includes an interactive TUI and a drop-in autonomous runner (claude-auto).
Prerequisites
- Python 3.11+
- uv — https://docs.astral.sh/uv/getting-started/installation/
- Claude Code CLI —
npm install -g @anthropic-ai/claude-code(theclaudebinary must be on PATH — the Agent SDK calls it as a subprocess)
Install
uv tool install cc-credentials-manager
Or directly from GitHub:
uv tool install git+https://github.com/Kydoimos97/cc-credentials-manager.git
This puts two binaries on PATH: cc-creds and claude-auto.
Setup
Step 1 — generate a long-lived token for each Claude subscription:
claude auth login # authenticate with your Claude account
claude setup-token # prints a sk-ant-oat... token valid for 1 year
Step 2 — register it:
cc-creds add <token> --label "account-name"
The token is verified against the API immediately. The first credential added becomes active automatically.
Step 3 — install session tracking hooks:
cc-creds install-hook
Registers Stop, StopFailure, and UserPromptSubmit hooks in
~/.claude/settings.json. Creates the file if it does not exist yet.
That's it. Use claude normally — all sessions are tracked automatically.
The active credential is stored on disk in ~/.cc-creds/. claude-auto reads it
at startup and passes the token explicitly to each run — no global environment
injection, so interactive claude sessions are never affected.
Commands
Credential management
cc-creds open the interactive TUI (Credentials, Stats, Usage tabs)
cc-creds add <token> [--label NAME] register and verify a new credential
cc-creds list list all credentials with live API status
cc-creds status show auth mode and active label (no API call)
cc-creds status --verify re-verify token against API, show full status
cc-creds status --json machine-readable JSON output for scripts/statusline
cc-creds status --label print just the active label — safe for hooks/scripts
cc-creds set-active <label-or-id> switch active credential
cc-creds remove <label-or-id> remove a credential (scrubs token from registry and settings.json if active)
cc-creds deactivate clear active credential, return to full OAuth session
cc-creds rotate advance to next available credential
cc-creds install-hook register session tracking hooks in ~/.claude/settings.json
TUI keybindings (Credentials tab):
a add new credential (opens token + label form)
d delete selected credential
enter set selected as active
r rotate to next available credential
i install session tracking hooks
v verify selected credential against the API
q quit
Autonomous runner
claude-auto "prompt" run a prompt non-interactively
claude-auto -p "prompt" same, -p flag for muscle memory
claude-auto -f prompt.txt read prompt from file
claude-auto --cwd /path/to/project set working directory (default: cwd)
claude-auto --resume <session-id> resume a specific session
Automatically picks the active credential, rotates on rate limit, and resumes the same session with the new token.
How it works
Credential store — ~/.cc-creds/
credentials.json registered tokens with labels and expiry
cred-status.json per-credential status: available / limited / admin_disabled
active.key currently active credential ID (absent when deactivated)
sessions.jsonl session registry with cost and token data
env shell env file written on non-Windows (source from .bashrc/.zshrc)
Auth modes
cc-creds supports two modes which can be switched at any time without restarting your session:
OAuth2-Full (default) — claude uses your real OAuth session with full scope.
Remote Control, billing, and all Claude Code features work normally. This is the
default when no credential is active.
LLT-Limited — a long-lived token is active. Claude Code uses that token for API calls, which means usage comes from the associated subscription quota. Some features that require the full OAuth session (e.g. Remote Control) are unavailable.
Switch modes:
cc-creds set-active <label> # activate an LLT — persists to user env vars
cc-creds deactivate # return to OAuth2-Full — clears user env vars
set-active writes the token to the Windows user environment (HKCU\Environment)
so new terminals and Claude Code sessions inherit it. deactivate removes it.
Neither touches settings.json — that would break interactive sessions.
claude-auto always reads the active credential from disk and passes the token
explicitly per run, regardless of what is in the shell environment.
Session tracking
Hooks registered by install-hook fire on every session:
UserPromptSubmit— registers the session, records rolling cost/token dataStop— finalises status tosuccess, records final cost/tokensStopFailure— detects rate limits, rotates to next credential automatically
Cost and token data comes from $CCODE_HOME/states/sessions/ when the CCODE_HOME
environment variable is set and points to your Claude Code data directory. Without
it, the Stop hook falls back to parsing the Claude transcript JSONL directly —
this path is less accurate and does not report rolling cost during active sessions
(UserPromptSubmit). Set CCODE_HOME for reliable tracking.
Rate limit rotation
When a rate limit is hit mid-session, claude-auto:
- Catches the
RateLimitEventorProcessErrorfrom the SDK - Marks the current credential as limited with the reset time when available (parsed from session state or assistant text; may be absent if not reported)
- Rotates to the next available credential
- Resumes the same session with
ClaudeAgentOptions(resume=session_id)
Interactive claude sessions are handled by the StopFailure hook — Claude
rotates the active credential and the next session starts with the fresh token.
Testing rotation
# Force-skip credential 1 (in-memory only, no store write):
CC_CREDS_FORCE_LIMIT_1=1 claude-auto "hello"
# Exhaust all credentials:
CC_CREDS_FORCE_LIMIT_1=1 CC_CREDS_FORCE_LIMIT_2=1 claude-auto "hello"
Debug logging
CC_CREDS_DEBUG=1 cc-creds status
CC_CREDS_DEBUG=1 cc-creds list
CC_CREDS_DEBUG=1 claude-auto "hello"
Outputs structured Rich logs to stderr: API calls with full response headers, SDK message stream, rotation decisions, session registration.
Statusline integration
If you use a Claude Code statusline script, cc-creds status --json returns:
{"mode": "LLT-Limited", "label": "account-name"}
{"mode": "OAuth2-Full", "label": null}
Use this to display the current auth mode in your statusline.
Troubleshooting
Hooks not firing or showing errors
Check that cc-creds install-hook ran successfully and that ~/.claude/settings.json
contains entries under hooks.Stop, hooks.StopFailure, and hooks.UserPromptSubmit.
Hook payloads are JSON objects sent via stdin — the hook-event handler expects
session_id, type, and cwd fields. If Claude Code changes its hook payload
schema, the handler will silently skip unrecognised payloads.
cc-creds list shows "unknown" status after a network error
Status checks that fail due to network errors (timeout, DNS failure) are retried after 5 minutes. A credential in "unknown" state is treated as available for rotation — it will be re-verified the next time rotation tries to use it.
Credential removed but old token still active in a new terminal
cc-creds remove scrubs the token from HKCU\Environment and settings.json
when the removed credential was active. Open a new terminal after removing an
active credential to pick up the cleared environment.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cc_credentials_manager-0.1.5.tar.gz.
File metadata
- Download URL: cc_credentials_manager-0.1.5.tar.gz
- Upload date:
- Size: 26.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8068f444a17227f7b11aeec490c9c40daa8183afb1cb8a45da7caddbecd3a024
|
|
| MD5 |
5071e086319997a856efa40ca01ff99e
|
|
| BLAKE2b-256 |
d3d15af9fce3c7b539f2d57406577cd2399bced26c65a7142f33adbcfdcecb20
|
Provenance
The following attestation bundles were made for cc_credentials_manager-0.1.5.tar.gz:
Publisher:
ci.yml on Kydoimos97/cc-credentials-manager
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cc_credentials_manager-0.1.5.tar.gz -
Subject digest:
8068f444a17227f7b11aeec490c9c40daa8183afb1cb8a45da7caddbecd3a024 - Sigstore transparency entry: 1793307290
- Sigstore integration time:
-
Permalink:
Kydoimos97/cc-credentials-manager@d9f4fcf9ce4d7b62c5b25fc9b0ccfc3cdd255242 -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/Kydoimos97
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@d9f4fcf9ce4d7b62c5b25fc9b0ccfc3cdd255242 -
Trigger Event:
push
-
Statement type:
File details
Details for the file cc_credentials_manager-0.1.5-py3-none-any.whl.
File metadata
- Download URL: cc_credentials_manager-0.1.5-py3-none-any.whl
- Upload date:
- Size: 32.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5e80a8e6250e41cef0f7ebc93857c4bf9277257252c34ab6f579768b1f28e47
|
|
| MD5 |
a787ee8bea83ea0b7e1e24f4d3cb55d2
|
|
| BLAKE2b-256 |
d1517ed69bf831a46622f59653f8c7ed0b08eeba4623eb1f932d4943731979e7
|
Provenance
The following attestation bundles were made for cc_credentials_manager-0.1.5-py3-none-any.whl:
Publisher:
ci.yml on Kydoimos97/cc-credentials-manager
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cc_credentials_manager-0.1.5-py3-none-any.whl -
Subject digest:
d5e80a8e6250e41cef0f7ebc93857c4bf9277257252c34ab6f579768b1f28e47 - Sigstore transparency entry: 1793307453
- Sigstore integration time:
-
Permalink:
Kydoimos97/cc-credentials-manager@d9f4fcf9ce4d7b62c5b25fc9b0ccfc3cdd255242 -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/Kydoimos97
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@d9f4fcf9ce4d7b62c5b25fc9b0ccfc3cdd255242 -
Trigger Event:
push
-
Statement type: