Skip to content

Latest commit

 

History

History
513 lines (339 loc) · 74 KB

usage.md

File metadata and controls

513 lines (339 loc) · 74 KB

Usage

Running the server, running Claude Code through it, and the full command reference.

Start the proxy server

teamclaude server

From a TTY this shows the interactive TUI: an account table with session/weekly quota bars and reset countdowns, a real-time activity log, and keyboard controls.

With accounts from two providers (Claude and Codex) and a terminal at least 127 columns wide, the account table is drawn as two panes side by side, one per provider, each titled with its provider. Each pane carries its own ► current-account marker, because each provider pool keeps its own cursor. The panes are used only when both can draw every quota bar their rows have, so a fleet with per-model bars, route columns or blocked-family tags needs a little more than 127 columns; a narrower terminal keeps the single list, with the provider named in the type column (and still one ► per provider). A row whose subscription has reported a weekly window and no 5-hour one (some Codex plans, and a Claude Ultra plan once Anthropic has lifted its 5-hour limit; see Accounts without a 5-hour window) draws the weekly bar alone, at the width of both cells, while the rows beside it keep Ses and Wk; a list made only of such rows drops the Ses column outright. On a terminal too narrow for two bars per row, where the other rows draw only Ses, such a row draws Wk in that one slot. An account that has not reported yet keeps both cells, and a row keeps them when its 5-hour window merely runs out.

It falls back to plain log output when stdout is not a TTY (e.g. running as a service). Pass --headless (or --no-tui) to force plain-log mode from a terminal — useful for backgrounding the proxy.

Running in a container

A container image is published to GHCR on every version bump (ghcr.io/karpeleslab/teamclaude, tagged latest, 1, 1.1 and the full version). It runs server --headless bound to 0.0.0.0 inside the container, so publish the port and bind-mount the config file:

docker run -d --name teamclaude -p 3456:3456 \
  -v ~/.config/teamclaude.json:/data/teamclaude.json \
  ghcr.io/karpeleslab/teamclaude:latest

docker exec -it teamclaude teamclaude login --token   # add accounts from inside
docker exec -it teamclaude teamclaude status

The entrypoint starts as root only long enough to match the runtime user to the owner of the mounted config (or of /data when the file does not exist yet), then drops privileges — so a file owned by your user stays writable without a chown. TEAMCLAUDE_UID (and optional TEAMCLAUDE_GID) override the detected owner. stderr is folded into stdout so docker logs shows one stream; set TEAMCLAUDE_SPLIT_STDERR=1 to keep them apart. Auto-update is disabled in the image; pull a new tag to upgrade.

The config is created on first start with a random proxy.apiKey. Anything reaching the proxy from outside the container is a non-loopback client and must present that key (see proxy.host); only teamclaude commands run via docker exec are exempt.

Build it yourself with docker build -t teamclaude . from a checkout.

Session titles in the activity log

Claude Code sends x-claude-code-session-id with each request, so every activity row belongs to a known session. With sessionTitles.enabled set, the row is labelled with that session's name:

 ⠋ 17:42:57  adv-review-rewrite POST /v1/messages (claude-opus-5) → claude@rikbrown.co.uk (1.9s...)
 ⠋ 17:42:57  emmy-merge         POST /v1/messages (claude-opus-5) → claude@rikbrown.co.uk (0.4s...)
 ⠋ 17:42:57                     POST /v1/messages?beta=true (claude-opus-5) → claude@rikbrown.co.uk (1.1s...)

The name comes from Claude Code's own files under ~/.claude/projects, in this order:

  1. <session-id>/custom-title.json, written by /rename.
  2. A custom-title record in the session transcript, which is the only copy for a session renamed before that file existed.
  3. An ai-title record, the title Claude Code generates. Most sessions have one without a rename.

A session with none of these keeps the first six hex characters of its id. So does a request that carries no session header: a bare SDK or API client reaches the proxy anonymously, and no file names it.

Each label is read once and re-read at most every 30 seconds, off the render path, so a /rename reaches the log without a restart and no frame waits on the disk. Only a session id shaped like a UUID is looked up, and a title is printed with its control characters removed, since both arrive from outside the proxy.

This is off by default: it reads the tail of every visible session's transcript, which is further than the proxy reaches for anything else unless asked. Press g → Session titles to turn the labels on and off while the proxy runs. Set sessionTitles.width to change the columns the label gets. See configuration.

Headless, you can re-sync accounts from the config without a restart by POSTing to the local control endpoint (the equivalent of pressing R in the TUI):

curl -X POST http://localhost:3456/teamclaude/reload

The switch threshold has a control endpoint of its own — the same change as teamclaude threshold 90, and what the browser dashboard's Switch at control sends:

curl -X POST http://localhost:3456/teamclaude/threshold \
  -H 'content-type: application/json' -d '{"percent": 90}'

It is a setting, not a nudge: the number is written to the config file (under its lock, so an edit the CLI or TUI made meanwhile survives) and the server reloads to apply it. The answer carries the stored ratio and, when one number replaced a per-bucket table, dropped names the buckets that went. Per-account accounts[].switchThreshold overrides are untouched. A request authenticated with a proxy.clientKeys entry is refused with 403 — a client key is a tenant of the proxy, not its operator; the shared proxy.apiKey and key-exempt loopback callers are allowed.

You usually don't need to call it directly. login, import, enable, disable, cordon, uncordon, priority, ends, route, threshold, distribute, probe and warmup notify a running server themselves.

Control-plane writes (reload, switch, session-pin, session-advice/decline, threshold, priority, disable, account-cordon, account-release) are refused when the request carries a browser Origin or a cross-site Sec-Fetch-Site. Loopback is exempt from the proxy API key so the CLI needs no configuration, but that exemption also covers any web page you happen to visit: a page can POST to 127.0.0.1 cross-origin without a preflight, and while it cannot read the reply, the write would still land. curl and the CLI send neither header and are unaffected. Reads (status) are not restricted — the same-origin policy already stops a page from seeing the response.

GET /teamclaude/quota is the compact read endpoint for status-line integrations. It returns tier-weighted fleet aggregates and the underlying per-account limits; see Fleet quota endpoint.

GET /teamclaude/session-advice?session=<id> answers which account one session is on and whether to move it, and POST /teamclaude/session-advice/decline holds that advice; see Session move advice. Both are refused for a client key.

Switching the account by hand has the same headless path — the equivalent of pressing s in the TUI and confirming with the default target selected:

teamclaude switch                 # list accounts, marking the current one
teamclaude switch me@example.com  # make that account the preferred one
teamclaude switch me@example.com --session   # move only the session this runs in

--session [<id>] moves one session instead of the fleet; see Move one running session. teamclaude switch --session [<id>] --to <account> does the same with the account last, and must be exactly that: the account is the last word, taken as given even when it starts with -, and the id, when given, is the one word between --session and --to. Anything else with --to, a word after the account included (an account name with spaces left unquoted), is an error and pins nothing. With no account, teamclaude switch --session prints that session's account, each account's weekly usage, any move advice and its reason, and when a move is recommended a move command: teamclaude switch --session <id> --to <account> line, the account as one shell word, to run exactly as printed (--json prints the raw session advice, without that line); teamclaude switch --session --stay declines the advice for cooldownMinutes; --stay with an account or --clear is a usage error.

Both forms need a running server: the choice is runtime state and is never written to the config, so there is nothing to apply on a later restart. The command wraps POST /teamclaude/switch with a {"account": "<name>"} body, and the account can be given as its display name, its bare email, its accountUuid, its orgUuid, or the fully qualified accountUuid/orgUuid — the last being the only form that tells apart one email that holds accounts in several orgs. The rotation index is deliberately not accepted — it is array position, so a script pinned to 1 would silently follow a different account after a removal.

As in the TUI, a manual choice takes precedence over the automatic rankings (priority, and preferSoonestWeeklyReset where it is on) while the account remains available. Model-route allowlists, quota thresholds and account caps still apply; switching does not authorize paid extra usage. Once rotation moves off the account (it filled up, was throttled or disabled), the preference is gone and the rankings apply again; a model-scoped diversion or another provider's traffic does not release it. With distributeSessions on, new conversations are placed within the best priority tier and do not read the manual choice, so a switch to an account that a higher-priority account outranks is reported as not taking effect. Among accounts of the top priority, eligible: true then means a new conversation can be placed there, not that it will be. The choice is runtime state and is not persisted. A switch onto an account that cannot take traffic at all is still recorded, exactly as in the TUI, but the command says so instead of reporting a clean success:

Switched to "me@example.com"
Warning: "me@example.com" is disabled, so requests will not route to it until that changes.

So a switch to an account with allowExtraUsage: true holds only while that account is under its switch threshold. Past it, rotation moves to any account that can serve normally, as it does without a switch. The target can still be picked by the exhausted-fleet fallback like any other account, and once rotation has moved away, a later automatic return to the account does not bring the earlier choice back.

With preferExtraUsage: true alongside allowExtraUsage: true on the target, the switch also keeps traffic on that subscription past its threshold, among the subscriptions the preference would use. It does not widen what may be spent: another subscription that can serve normally still goes first, paid credits still wait for included quota left on any subscription, and an API account with a strictly lower priority number still outranks it. Where one of those applies, the switch is reported as not taking effect and rotation proceeds as above. See Extra-usage fallback.

Taking an account out of rotation, or moving it in the priority order, has a headless path too — the web equivalent of teamclaude disable / enable and teamclaude priority --first / --last, and what the browser dashboard's buttons call:

curl -X POST http://localhost:3456/teamclaude/disable \
  -H 'content-type: application/json' -d '{"account": "me@example.com", "disabled": true}'
curl -X POST http://localhost:3456/teamclaude/priority \
  -H 'content-type: application/json' -d '{"account": "me@example.com", "place": "first"}'
curl -X POST http://localhost:3456/teamclaude/account-cordon \
  -H 'content-type: application/json' -d '{"account": "me@example.com", "cordoned": true}'

POST /teamclaude/priority takes {"account", "place": "first" | "last"} or {"account", "priority": <integer>}; POST /teamclaude/disable takes {"account", "disabled": true | false}. Both accept an optional "org" (name or uuid) for an email that holds accounts in several orgs — an ambiguous name is refused rather than guessed. Unlike switch, these are config writes: the change is saved to the config file under the same lock the TUI uses, and the server reloads itself afterwards, so it survives a restart. place is relative — first lands one below the lowest priority in the fleet, last one above the highest — and the reply carries the account as it now stands ({"ok": true, "name": ..., "priority": ...} or {"ok": true, "name": ..., "disabled": ...}), so a caller learns the number it did not choose. POST /teamclaude/account-cordon takes {"account", "cordoned": true | false} (see Cordoning one account) and answers the same way, plus remaining, the conversations still on the account, and inService, how many other accounts of its provider are neither disabled nor cordoned. An unknown or ambiguous account, or a priority that is not an integer, is a 400 with the reason; a write that landed but whose reload failed is a 500 that says so, since the file did change. A request authenticated with a proxy.clientKeys entry is refused with 403: a client key is for using the fleet, not for changing which accounts it contains. Use the shared proxy key, or call from the proxy's own machine.

Claude Code status line and Stop hook

Two commands read the JSON Claude Code passes on stdin and answer from the running server. Neither can fail Claude Code: stdin is read for at most a second and 256 KiB, each server read gives up after a second, and both exit 0. They take only the proxy port and key from the config, so a bad egress proxy setting does not stop them.

  • teamclaude statusline, for statusLine, prints one line: the session's account ((pinned) for a manual pin), each account's weekly usage, and the move the server advises, if any — on a | a 90% · b 25% | move to b, or pinned account unavailable, move to b when the session's requests are not forwarded to its pinned account (pinned-unavailable). Account names are printed on one line, control characters removed. Without the session's account it prints session unknown | fleet 40% | a 90% · b 25%; with no server, teamclaude offline. With sessionAdvice off it still shows the account and usage.
  • teamclaude stop-hook, for the Stop hook, prints a hook answer when the advice newly applies, and nothing otherwise or while sessionAdvice is off. An out-of-band move is announced once until the advice goes away; a change of destination alone is not announced again. A pinned-unavailable pin is announced once per pinned account, and again only after the pin has moved to another account that serves. Nothing is announced for router-moves, where the router moves the session itself. Suggested moves use the teamclaude switch --session --to <account> form, with the account as one shell word, single-quoted unless it is plain. The word is the name with control characters removed and runs of whitespace collapsed, so for a name that has either the printed command names the cleaned name, which matches no account unless one is called exactly that, and fails. The answer is {"systemMessage": "…"}; with sessionAdvice.ask on, an out-of-band move is {"decision": "block", "reason": "…"} instead, asking Claude to offer the user the move or --stay. A dead pin is never a block, since the turn Claude would continue goes to the same account.

The session id is stdin's session_id; when the proxy does not know it, $CLAUDE_CODE_SESSION_ID is tried. Whether either equals the x-claude-code-session-id header the proxy keys sessions by is not established. Once it has something to remember for a session, the Stop hook keeps a file for it, <session_id>.json holding {"outOfBand", "pinnedAnnounced"}, in teamclaude-advice/ under the OS temp directory, created mode 0700; on POSIX systems a directory with other permissions or another owner is not used. Files are left for the OS's temp cleanup. Both commands read with the proxy key, so they need the shared proxy.apiKey or a key-exempt loopback caller, not a client key.

Install the Claude Code surfaces

The status line, the Stop hook and the /switch skill are assets of this repository and are not wired up by installing the package. They read the session advice, so the server must have sessionAdvice on.

  1. Make teamclaude run this code: npm link in the clone, or node <clone>/src/index.js wherever the examples below say teamclaude.

  2. Link the skill. claude-code/ is not in the npm package (package.json files lists only src/), so link it from a clone:

    mkdir -p ~/.claude/skills
    ln -s <clone>/claude-code/skills/switch ~/.claude/skills/switch

    The skill is /switch, or /switch <account> to move the session without being asked.

  3. Add the status line and the Stop hook to ~/.claude/settings.json, merging with what is already there:

    {
      "statusLine": { "type": "command", "command": "teamclaude statusline" },
      "hooks": {
        "Stop": [
          { "hooks": [{ "type": "command", "command": "teamclaude stop-hook" }] }
        ]
      }
    }
  4. Turn the advice on in the teamclaude config. A move recommendation also needs expiryRouting; the pinned-account-unavailable warning does not.

    {
      "sessionAdvice": { "enabled": true },
      "expiryRouting": { "enabled": true }
    }

    Add "ask": true to sessionAdvice to have the Stop hook ask Claude to offer the move. See Session move advice.

The skill's frontmatter, $ARGUMENTS substitution, inline ! command and allowed-tools field, and the statusLine and Stop hook settings shapes, follow the Claude Code docs for skills, status line and hooks. The skill pre-approves only Bash(teamclaude switch --session *), and every command it runs starts that way, with the account last behind --to. /switch <account> takes everything after the command as one account name (Claude Code substitutes $ARGUMENTS as typed, and the skill single-quotes it), so a name with spaces needs no quotes, and an extra word makes a name that matches no account and fails. How Claude Code's permission matcher treats shell operators (;, &&, |, #, a substitution) inside a command that starts with that prefix is not verified here.

Checked in a real Claude Code session: the status line shows the session's own account and each account's usage; /switch shows the advice and asks, and "stay" is recorded; /switch <account> moves the session without a permission prompt, and the status line then marks it as pinned. Not yet checked there: the Stop hook's one-line notice at the end of a turn, accepting a recommended move from /switch, and the permission rule's handling of a command with a shell operator in it. To keep the permission prompt on every command, remove allowed-tools from the skill.

TUI keyboard shortcuts

Key Action
s Switch active account (←/→ picks the default account or a specific route)
d Enable/disable an account
l Sign an account in again (opens on the first account in error; not in attach mode). A panel shows the sign-in link, clickable and copied to the clipboard, and takes the pasted answer back, so it works over SSH — see Signing in again from the TUI
r Choose an OAuth Claude or Codex account, then read and spend a banked reset. Starts on the first account holding one; local TUI only
p Refresh quota on all accounts (one-shot probe of the zero-spend usage endpoint)
R Reload accounts from config
g Settings (threshold, quota probe, quota-bar contents, routing, add/remove/reorder/sort accounts, upstream and account proxies, sx.org)
q Quit

In selection mode, use j/k or the arrow keys to navigate, Enter to confirm, Esc to cancel.

In the Resets panel, only held grants are listed; spent grants are hidden. Each row shows the kind in bold, the number left, the limits it clears and its expiry. A held but blocked grant is dimmed, with its reason on the same line. The selected grant alone shows its upstream label below the row, dimmed, and its warnings in yellow. Dates and times are local; expiry is a date more than a day away (with the year only if it differs from this year), or a countdown within a day. An empty list says no banked resets. ↑/↓ or j/k choose a held grant, Enter shows the spend confirmation and warnings, and y/Y spends it. Any other key cancels the confirmation. Blocked grants cannot be spent; warnings do not block a manual spend. Opening uses a cached reading up to five minutes old without a request, and the header shows its age (as of 1m ago). Claude's quota probe fills this cache from its existing usage request; Codex caches its detail rows. Within the panel, r reads again after two minutes, or shows read 40s ago — wait 80s without a request. A 429 starts the two-minute wait again; upstream Retry-After can extend it. Failed reads keep earlier grants visible with stale, their original age and the error, plus retry in 90s when upstream gives a retry delay. Without a cached reading, only the error is shown. Grant ids and detail rows stay in memory, never config or saved quota. Esc/q closes the panel. Spending cannot be undone or cancelled once it starts.

The settings screen is a list, not a set of letter shortcuts: ↑/↓ move between rows, ←/→ change the value in place (threshold by 1%, probe by 30s, modes cycle), Enter opens a row that needs typing or a sub-screen, Esc goes back.

Reorder accounts opens the account list with the same two pairs of keys and one extra job for them: ↑/↓ pick the account, ←/→ move that account up and down the list, Enter or Esc goes back. Every move applies as you make it and is written a moment after the keys stop (or on leaving the screen), so there is nothing to confirm and nothing to cancel. An account moves among the accounts of its own provider: a mixed Claude and Codex fleet is drawn grouped by provider, so a move that would cross into the other group does nothing. This is the order the list is drawn in and nothing else — rotation order is priority, which the screen never touches. teamclaude attach draws the same order: each account in /teamclaude/status carries its displayOrder (null until it has been placed).

Sort accounts chooses what orders the list inside each provider group: arranged (your order, above), or the soonest reset of one window — session reset (five-hour), weekly reset, S7 reset or F7 reset — which puts the account whose window ends soonest at the top: the quota you lose first if nothing spends it. S7 and F7 read the all-models weekly on an account that has no Sonnet or Fable bucket of its own, since that is the window its Sonnet or Fable use counts against. Accounts with no reading for the window go last (for the session sort, that includes every account with no five-hour window open), and your arrangement breaks ties. A third-party backend sorts by its probed windows, with the monthly one standing in for a weekly reset the plan does not have. The reorder screen always shows the arranged order, because that is the order it edits. teamclaude attach reads the same accountSort from its own config file.

Run Claude Code through the proxy

teamclaude run

run probes the proxy first. If it's up, Claude Code is routed through it; if it's not running, run errors out rather than silently bypassing the proxy — which would spend your own quota with no rotation. Pass --auto-fallback to launch claude directly instead when the proxy is down:

teamclaude run --auto-fallback

Since 1.1.0, run defaults to MITM forward-proxy mode so even hardcoded api.anthropic.com endpoints are intercepted. For the previous base-URL-only behavior, pass --no-mitm — or set defaultClientMode: "base-url" in the config (the Client mode row on the TUI settings screen) to make that the default for run and env alike, with --mitm opting back in per launch:

teamclaude run --no-mitm

Arguments after -- go to claude:

teamclaude run -- --model opus

Claude Code still needs a login of its own. In both modes the client checks its local login (~/.claude/.credentials.json, or the Keychain on macOS) before it sends anything, and the proxy only sees a request once that check passes. The pool's accounts do not stand in for it: they are what the proxy uses upstream, and the two expire independently. The exception is a pool account holding this same login, imported with teamclaude import or read through importFrom: the two then share it, and whichever renews first ends the other's copy (see Import from Claude Code). So a claude that exits at once with Failed to authenticate: OAuth session expired and could not be refreshed is reporting its own login, not the pool — run claude auth login and launch again. run prints a hint to that effect when claude dies within seconds of launch and the local login is missing or past its expiry.

Setting the environment yourself

teamclaude env prints the same export lines run uses:

eval "$(teamclaude env)"           # MITM: HTTPS_PROXY + NODE_EXTRA_CA_CERTS
eval "$(teamclaude env --no-mitm)" # base-URL: ANTHROPIC_BASE_URL only
eval "$(teamclaude env --mitm)"    # MITM regardless of defaultClientMode
claude

Only the export lines go to stdout (so eval is safe); a short summary and any hints go to stderr. No ANTHROPIC_API_KEY is emitted — loopback clients are exempt from the proxy key gate, and setting it would drop Claude Code out of subscription mode. A remote (non-loopback) client must add the proxy key itself.

The proxy variables are shell-wide. In MITM mode the eval exports HTTPS_PROXY and friends, and every other tool in that shell — gh, git, a package manager — follows them to a listener that only speaks to the providers' hosts; in a sandboxed shell that can surface as a synthetic 403 from an unrelated command. If that is your shell, set defaultClientMode: "base-url" (the Client mode row on the TUI settings screen): env then emits ANTHROPIC_BASE_URL only and, re-evaluated, unsets the proxy variables an earlier MITM eval left pointing at this proxy, leaving a real corporate proxy alone. teamclaude run scopes the variables to the claude process either way.

Your own NO_PROXY is kept. run and env both set NO_PROXY=localhost,127.0.0.1,::1 and append whatever the launching shell already had. That matters for local development: a dev server on a name like app.test resolves to 127.0.0.1 through a local resolver, and a forward to loopback is refused, so a client that proxied it would get a 403 on every retry. export NO_PROXY=.test before the eval (or before run) and the launched client gets localhost,127.0.0.1,::1,.test. The one entry that is dropped is * — it would send api.anthropic.com around the proxy as well, silently ending rotation; use --no-mitm for a direct launch.

Using an agent multiplexer or a tool that spawns claude itself? Export this environment in the process that launches those claude instances — e.g. eval "$(teamclaude env)" in the shell you start the multiplexer from. Every spawned claude then gets the same routing (and MITM interception of hardcoded endpoints) without going through teamclaude run. The trade-off: run's proxy-up/down guard only applies when you launch via run, so start the server before the multiplexer.

Routing plain claude automatically

So you don't have to type teamclaude run every time, add a shell alias that sends plain claude through the proxy:

teamclaude alias              # print the alias for your shell
teamclaude alias --install    # or write it to your shell rc (--uninstall to remove)

This is an interactive-shell alias — it affects claude typed at a prompt, not claude spawned by editors or scripts. It's a thin passthrough to teamclaude run, which holds the proxy-up/down logic (so it errors when the proxy is down; add --auto-fallback to launch claude directly instead).

The Claude Code extension for VS Code starts claude itself in its chat panel, so neither the alias nor run reaches it there. It takes the proxy settings from its own setting instead: see VS Code extension. In terminal mode (claudeCode.useTerminal) on macOS and Linux, and on Windows in a Git Bash or WSL terminal, it types claude into an integrated terminal, where the alias does apply.

Command reference

teamclaude login             # Add an account via OAuth (--api for an API key)
teamclaude import            # Import credentials from Claude Code
teamclaude server            # Start the proxy (--headless for plain logs)
teamclaude run               # Run Claude Code through the proxy
teamclaude env               # Print export lines for routing claude yourself
teamclaude alias             # Print/install a `claude` alias that routes via the proxy
teamclaude accounts          # List accounts with subscription tier and token status
teamclaude status            # Show live proxy status (requires running server)
teamclaude attach            # Open the live dashboard against a running server
teamclaude dashboard         # Open the web dashboard in the browser (needs server)
teamclaude service install   # Run the proxy as a login service (uninstall/status/print)
teamclaude switch [name]     # Prefer an account; no name lists them (needs server)
teamclaude statusline        # Claude Code status line: account, usage, move advice
teamclaude stop-hook         # Claude Code Stop hook: notice when move advice applies
teamclaude remove <name>     # Remove an account (by name or email)
teamclaude disable <name>    # Temporarily exclude an account from rotation
teamclaude enable <name>     # Re-enable it (also clears a stuck error state)
teamclaude cordon <name>      # Send it no new conversations; the ones on it stay
teamclaude uncordon <name>    # Send it new conversations again
teamclaude release <name>     # Unpin the conversations on it; each is placed again on its next request
teamclaude priority <name> 1 # Set rotation priority (lower = preferred)
teamclaude ends <name> 2026-12-01 # The account stops being usable then: spend it first (--clear to unset)
teamclaude rename <name> <new> # Rename an account (and the routes that list it)
teamclaude route list        # Manage per-model routes (add/rm)
teamclaude threshold 90      # Utilization at which rotation leaves an account
teamclaude distribute on     # Spread new sessions across equal-priority accounts
teamclaude probe 300         # Enable background quota refresh (off by default)
teamclaude warmup 600        # Enable keep-warm (off by default, spends quota)
teamclaude warmup reset 15:30 --timezone Europe/Moscow
                             # Schedule warm-up for a daily target reset
teamclaude warmup rolling 15:30 --timezone Europe/Moscow
                             # Anchor resets at 15:30, then continue every 5h
teamclaude api <path>        # Call an API endpoint with account credentials
teamclaude callback login    # Sign in to callback.net: keep OAuth tokens in step across your installs
teamclaude callback status   # (also: sync, logout) — see docs/accounts.md
teamclaude update            # Check npm for a newer teamclaude and install it
teamclaude version           # Print the installed version
teamclaude help              # Show all commands

teamclaude status prints the same picture as the TUI, once, as text. Handy over SSH or in a script; --json for machine-readable output. The JSON's server.version is the version of the process answering — read once at startup, so right after teamclaude update it still names the old code until the restart, where the installed CLI's teamclaude version already names the new one; server.pid is that process's id, so a caller can tell which server answered on a port. Each account's shared windows carry the time upstream last stated them, beside the value: quota.unified5hSeenAt and quota.unified7dSeenAt, in epoch milliseconds, for Claude and Codex accounts alike. Only a response or probe that states that window's utilization moves its stamp; a reset time alone, a failed probe or a model-scoped weekly bucket does not. (A Codex subscription states its only 5-hour window inside a model-named family; that reading is the account's 5-hour value, so it moves the 5-hour stamp.) The stamps survive a restart, and a value restored from a state file written before they existed reads null until upstream states it again, so null means "age unknown", never "just now".

teamclaude attach opens the terminal dashboard itself against a server that is already running, which is how you get interactive control back when the proxy runs as a background service. It polls the same status endpoint every second and can do the two things the remote control exposes: s switches account, R reloads config. The browser dashboard adds the matching Reload config action plus a zero-spend Probe quotas action; settings editing and the request activity stream still stay in the server's own TUI because they need state that only that process has. When contact with the server drops, the header marker turns from ▲ to ▼ and what is on screen is the last snapshot, not the current state.

teamclaude service install registers the proxy as a user service that starts at login and restarts on its own — a LaunchAgent on macOS, a systemd --user unit on Linux (uninstall, status and print round it out; print writes the unit to stdout without touching anything). On macOS the LaunchAgent runs with ProcessType Standard: the Background class it used before carried a QoS clamp that starved the proxy under host contention (status timeouts, seconds of event-loop lag). The unit is only written at install time, so an existing install keeps whatever it was installed with until you re-run teamclaude service install. The service PATH includes ~/.local/bin when that directory exists, which is where the native Claude Code installer places claude. Keep-warm also checks that directory when claude is not on the service PATH, so an already-installed service finds the binary without another install.

Re-running teamclaude service install rewrites the unit and restarts the proxy on both platforms, so the proxy also picks up an updated install. Requests in flight are dropped. On macOS the install waits, up to 30 seconds, until launchd has finished removing the old agent before it loads the new one, and retries a load that launchd refuses with 5: Input/output error up to twice, after 1 and then 2 seconds. If the load still fails, the proxy is likely not running: once teamclaude service status reads not loaded, run teamclaude service install again.

teamclaude status output

Control routes under a second name

Every /teamclaude/… route the server exposes — status, quota, reload, switch, disable, account-cordon, account-release, priority, threshold, probe, drain, undrain, login/start, login/finish, login/cancel, dashboard and mcp — also answers at the same path under /teamrouter/…, with the same gates and the same replies. It is the first step of the rename to TeamRouter; scripts and dashboards written against /teamclaude/… keep working unchanged.

Cordoning one account

To take one of your accounts out of service without cutting the conversations running on it, cordon it first, and disable or remove it once it is empty:

teamclaude cordon me@example.com
teamclaude uncordon me@example.com
  • No new conversation goes to a cordoned account. Rotation, session distribution, the session-reset switch, a failover hop, the exhausted-fleet probe and the extra-usage fallback all pass it over, whatever its priority, as they pass over a disabled account. status reports it as unavailable: "cordoned", the last of the reasons, so a spent or failing account still says that instead.
  • A conversation already on it stays there: one whose last request the account served, which the proxy pins in every mode, keeps being sent to it until it goes idle for an hour, as a pinned conversation does under distributeSessions. The account's own state still moves it the way it moves any pinned conversation: out of quota, a stricter route, a better-priority account, or a rollover under expiryRouting.preempt. Requests and streams in flight run to their end. A request that names no conversation (no x-claude-code-session-id) is new work and goes elsewhere.
  • Pins already in place are left alone: a TC_ACCT process and a session pin keep being served. A new one is refused: teamclaude run with TC_ACCT naming a cordoned account does not start, teamclaude env warns, and POST /teamclaude/session-pin answers 409.
  • With every account that could serve a request disabled or cordoned, it is refused with the no_eligible_account answer, which says the accounts are cordoned.
  • The flag is "cordoned": true on the account's entry in the config file, written under the config lock and picked up by a reload, so it survives a restart. uncordon deletes it. The dashboard's cordon / uncordon button and POST /teamclaude/account-cordon write it the same way.
  • How many conversations are still on the account is cordonRemaining in /teamclaude/status, the cordoned · N left badge on its dashboard card, and the Cordoned line in teamclaude status: the conversations pinned to it in the last hour, or the requests open on it, when there are more of those. At 0 nothing has run there for an hour and nothing is open, so disabling or removing it ends nothing running.
  • Keep-warm and the banked-reset auto-redeem skip a cordoned account. The quota probe still reads it, and its token is renewed as usual.
  • Cordoning and disabling are separate flags: enabling a cordoned account leaves it cordoned.

A cordon is per account. Draining for maintenance below drains the whole proxy and is runtime state; the two are independent.

Releasing the conversations on an account

teamclaude release <name> (or POST /teamclaude/account-release with {"account": "<name>"}) deletes the pins on one account while leaving it in service, so each conversation on it is placed again on its next request by the normal ranking, which may put it straight back. It answers how many conversations it released. Use it to send running conversations toward an account whose weekly quota is about to expire without disabling the one they are on, which would take that account away from everyone. On a cordoned account it moves the conversations it would otherwise keep.

It needs a running server and writes nothing to the config, since pins live in the server. A session pin and a TC_ACCT pin are left alone, and requests in flight finish where they are. With session distribution off, every conversation rests on the current account anyway, so if that is this account traffic stays until you also run teamclaude switch <other>; the command says so.

Draining for maintenance

Before a restart, or while you work on the proxy's machine, drain it so the requests in flight finish instead of being cut:

curl -X POST http://localhost:3456/teamclaude/drain   -H "x-api-key: $KEY"
curl -X POST http://localhost:3456/teamclaude/undrain -H "x-api-key: $KEY"
  • While draining, a new request to the forwarded API routes gets 503 with a retry-after header and Connection: close. The body is {"type":"error","error":{"type":"overloaded_error","message":"…","details":{"error_code":"draining"}}}, so a client can retry once the proxy is back. Streams already open run to their end.
  • The control routes still answer while draining, so undrain works. GET /teamclaude/status carries drain: { draining, since, inFlight }, where since is when the drain began and inFlight is the number of requests still running.
  • Drain is runtime state. It is not written to the config, and a restart clears it. Only the shared proxy.apiKey and the operator's own loopback calls may drain or undrain; a proxy.clientKeys entry gets 403, scoped or not.
  • The count covers the requests the forwarding listener admits, including ones intercepted in MITM mode, until the proxy has finished with each one. It does not cover blind CONNECT tunnels, the WebSocket channel that Remote Control opens, or absolute-form forward-proxy requests. None of those is refused during a drain either, and all of them are cut when the process exits.
  • To have SIGTERM drain as well, set proxy.drainTimeoutSeconds (see Configuration). It is off by default, and SIGTERM then stops at once as it always has.
  • The service manager's own stop timeout caps the drain. teamclaude service install writes no ExitTimeOut into the LaunchAgent plist and no TimeoutStopSec into the systemd unit, so the platform defaults apply: launchd sends SIGKILL once its exit timeout has passed (man launchd.plist calls the default "system-defined"), and systemd once its DefaultTimeoutStopSec has passed (90 seconds unless the system changes it). A drain window longer than that is cut short by SIGKILL. Keep proxy.drainTimeoutSeconds below the timeout that applies to your service, or raise the manager's timeout yourself; the plist and unit are rewritten by teamclaude service install, so a hand edit to them does not survive a reinstall.

Status dashboard (browser)

GET /teamclaude/dashboard serves a self-contained HTML page rendering the same data as teamclaude status: per-account quota bars (session and weekly, plus one bar per model-scoped weekly bucket upstream reports), rotation state, and active sessions — refreshed every few seconds.

teamclaude dashboard opens this page in the system browser against a running server (it starts none; use teamclaude server or teamclaude service install for that). The page's Reload config and Probe quotas buttons mirror the corresponding TUI actions without spending message quota. The Theme button cycles system → light → dark; the choice is kept in the browser's localStorage, and "system" follows the browser's prefers-color-scheme.

With proxy.usageDimensions configured, each dimension gets its own sortable table. With proxy.sessionDetail on, a per-conversation table shows each conversation's session, client, project, serving accounts, and what it actually spent per weekly bucket — cache reads and cache creation included — filterable by project or client. A client session that fans out to subagents is one row per agent: the rows carry the same Session and are told apart by Conv, a short digest of the conversation each one is (see Session-aware routing). That table is off by default; see Configuration.

A Usage window control sits above the Clients table and governs it and every dimension table under it. Total is the lifetime counter those tables have always shown; Last 5h and Last 24h show only what was spent inside that window. The tables re-sort on whatever window is selected, so the busiest client of the last five hours is the top row rather than the busiest of all time. Last used stays the lifetime figure under every window, since it answers when a client was last seen at all, which a window cannot. The figures come from windows on each client and dimension entry in /teamclaude/status — a rolled-up { requests, connections, inputTokens, outputTokens } per window. The proxy produces them by tallying traffic into 15-minute slots and keeping only the slots the longest window needs, so a window covers its own length plus at most one slot, and the cost is set by the window rather than by uptime. The slots ride in the state file, so a restart resumes the windows instead of restarting them. A client or value with no traffic in any window carries no windows key at all rather than rows of zeros — the windows nest, so an empty longest window means every window is empty — which keeps the status payload close to its previous size on a dimension whose values are mostly stale. A consumer of /teamclaude/status should read an absent windows as zero in every window, and note that a proxy older than this feature omits it for the different reason that it has no windows to report. The control governs the Clients table and the dimension tables only: the Sessions table below them reports per weekly quota bucket, which is a different question and is unaffected by it. 5h is the shared quota window. There is deliberately no 7-day window: the weekly quota is a bucket with a reset instant rather than a rolling window, so an honest weekly figure is "since the reset", not "in the last 168 hours".

A warning banner sits at the top of the page and is empty unless something is wrong. It reports a conversation that has had several client requests in a row come back with nothing usable — the case that reads as zero tokens exactly like an idle one, and is otherwise invisible — plus an account that needs a person (a broken token or a disabled entry). A spent quota bucket on one account, a rate-limit back-off and an upstream refusal are not reported: those clear themselves, and a banner that is always on is one nobody reads. When every account is over its threshold or in a hold, conversations do start starving — and the banner says which of the two it is, rather than blaming the conversation. Overage spend is not reported either: it is a month-to-date figure, so it would be lit for most of the month; the account card and teamclaude status carry it with the amount. With proxy.sessionDetail off the banner still fires, but names neither the session nor the conversation.

A Routing table above the accounts shows, for Fable, Sonnet, and any configured route, which account rotation would pick for a new request of that family and how many accounts could serve it — the ones that cannot are struck through, which is the reason the family is elsewhere. A pinned route names its pin, and says so when the pin is not eligible right now. The last rows are everything without a route of its own, one per provider in the fleet ("Claude default", "Codex default"): each names the server's default target for that provider, which is that provider's current account unless it is blocked or outranked, in which case the row says why. A Claude and a Codex pool keep independent cursors, so the summary line and the current badge on each card are per provider too. Targets are the server's own answers (routes[].target, defaultTargets and currentAccounts in /teamclaude/status; the older single-valued defaultTarget and currentAccount are still emitted. currentIndexes is currentAccounts by position: an object keyed by provider whose value is the current account's zero-based index into the status accounts array, or null when nothing can serve that provider — a name alone is ambiguous when two accounts share one, and it is what the attached TUI uses to place each ►), not something the page derives from the quota bars; they describe a fresh request, not one a running conversation has already pinned elsewhere.

Each account card has a switch button that makes that account the current one (the same POST /teamclaude/switch the CLI uses). It is not a pin: the account stays current until rotation has a reason to leave it, and is not outranked by priority meanwhile. What happens to traffic already running depends on distributeSessions — with it on, a conversation pinned to another account keeps it until it goes idle, so the badge moves before the traffic does; with it off (the default), everything follows the switch on its next request. The page reports whether rotation will actually use the target: a disabled, errored, rate-limited, or over-threshold account is still switched to, but the page says so and why rather than reporting a bare "done".

A Switch at __ % control on the actions row sets the fleet-wide switch threshold, the utilization at which rotation leaves an account — the same setting as teamclaude threshold <1-100> and the TUI's settings screen, sent as POST /teamclaude/threshold with a {"percent": 1-100} body. Unlike the switch button this writes the config file and reloads, so it holds across a restart. One number replaces a per-bucket switchThreshold table, and the page says which buckets were dropped; per-account accounts[].switchThreshold overrides are untouched. The field follows changes made from the CLI, the TUI or another browser on the next poll, except while you are typing in it. A dashboard opened with a proxy.clientKeys key may not call it — the server answers 403, since a client key is a tenant of the proxy rather than its operator — so for such a key the page shows the number read-only, without the Set button.

Beside it, each card has an enable / disable button (POST /teamclaude/disable), a cordon / uncordon button (POST /teamclaude/account-cordon, see Cordoning one account) and, for an enabled account that is not cordoned, prioritize and deprioritize (POST /teamclaude/priority with place: "first" / "last"). A cordoned card carries a cordoned · N left badge with the conversations still on it, and the cordon's note says when no other account is left to take new conversations. Unlike switch, these write the config file and reload the server — the same as teamclaude disable, enable and priority --first / --last — so they persist across restarts. A disabled or cordoned account shows no prioritize or deprioritize: reordering an account that nothing will select for new work is a control that looks like it does something and does not. A disabled account keeps its cordon button, so it can be cordoned before it is enabled again. The result of any card button — switch, enable/disable, cordon/uncordon, prioritize, deprioritize — appears in a line directly above that card for a minute, so it is in view wherever the card sits on the page; a priority move reports the number the account landed on, since a relative move picks a number the operator did not type. Both are refused when the page holds a proxy.clientKeys key rather than the shared proxy key (see the endpoint notes above), so for such a key the page does not draw them. One line under the actions row says which client key the page is using, that account and settings changes need the proxy key, and has a Change key button back to the key box.

An Add account button on the actions row signs in to a Claude account from the page, for a server that runs with no terminal to run teamclaude login in. It sends POST /teamclaude/login/start, and the page then shows a link to the sign-in page, a field for the code that page shows once you have signed in, and Finish and Cancel. The link opens in a new tab and works from any device. Finish sends the pasted code with POST /teamclaude/login/finish: the server exchanges it, saves the account the way teamclaude login does (under the config lock, into the config file the running server reads) and reloads, and the page says which account was added, or updated when the proxy already held it. Its card appears on the next poll. A paste the server cannot use (part of a code, a code from another attempt, the sign-in link itself) is refused with the reason, and the field stays for another try. The server holds one such sign-in at a time, in memory only: starting another ends the one before it, a restart ends it, and it ends by itself after five minutes, after which Finish says it has expired and the page goes back to the button. It adds Claude logins only; a Codex login (teamclaude login --codex), a long-lived login and an API key are still added from the CLI. The button is not drawn for a proxy.clientKeys key.

The three routes behind it take the proxy key (or the loopback exemption), never a client key (403), and a POST from a web page on another origin is refused like every other control mutation. With no proxy.apiKey set they answer only requests from this machine, as the resets routes do.

  • POST /teamclaude/login/start takes no body and answers {"ok": true, "id": "<id>", "url": "<sign-in link>", "expiresAt": <ms epoch>}. The sign-in has no listener on the proxy's machine; the pasted code is the whole flow. Its PKCE verifier and state stay in the server's memory and are in no answer and no file.
  • POST /teamclaude/login/finish with {"id": "<id>", "code": "<pasted code>"} answers 200 with {"ok": true, "account": "<name>", "action": "added" | "updated"}. 400 is a paste that cannot be used, and 409 a finish already running for that id: both leave the sign-in waiting. 404 means no sign-in is waiting under that id (it expired, was replaced or cancelled, or has finished), and 502 that the token exchange or the save failed after the code was taken; either way that sign-in is over, so start another. A sign-in that added or updated an account is logged, and so is one that failed after its code was taken, without the code or the tokens.
  • POST /teamclaude/login/cancel with {"id": "<id>"} ends the sign-in waiting under that id and answers {"ok": true, "cancelled": true}, or "cancelled": false when none was.

A card whose badge counts a banked reset (1 reset credit, 1 Fable reset) also has a spend reset button. The click sends POST /teamclaude/resets/read for that account: one fresh read, or the server's last reading when it read less than two minutes ago, in which case the page says so and how long until a fresh read is allowed. Under the card the page then shows what the TUI's resets panel (r) shows: how old the reading is, whether the account is at a limit, any hold, and each grant with the resets it has left, the windows it clears and when it expires. A grant the server reports as blocked is listed with the reason and cannot be chosen. With one grant that can be spent the page goes straight to the confirmation; with several you choose one first. The confirmation names the account, the grant and the windows the spend clears (a Fable reset clears the Fable weekly and not the weekly limit the other models share), repeats the server's warnings about spending it now, and says that a spend cannot be undone. Only Spend it sends POST /teamclaude/resets/redeem with {"account", "grantId"}. The page never sends "force": true, so in the hour after a claim the server refuses another and the page shows its message. The result appears above the card: what was cleared and how many resets are left, or the server's reason. The button is not drawn for a proxy.clientKeys key. The routes are described under Reading and spending a reset over the control API.

The page knows which controls to hide from caller in /teamclaude/status: { "kind": "operator" | "client", "client": <client-key name or null>, "refused": [<paths>] }. refused lists the control endpoints this key would get a 403 from, read from the same table the server's check uses, so the page and the server cannot disagree; it is empty for the shared proxy key and for a key-less loopback caller.

http://localhost:3456/teamclaude/dashboard

The page is a static asset and loads without a key; the data does not — its script fetches /teamclaude/status first, and asks for the proxy key only if the server refuses the request without one. Loopback browsers are key-exempt as everywhere else, so on the proxy's own machine there is no prompt. A key that is entered is kept in the browser's localStorage, and a 401 after a key rotation brings the prompt back. On deployments that put the proxy behind TLS this works remotely too: https://your-proxy.example.com/teamclaude/dashboard.

MCP endpoint

The running server can expose its control plane to Claude Code (or any other MCP client) as tools, so an agent can check the fleet's quota, switch accounts, or change a rotation setting from inside a session. It is off until the config says otherwise:

{ "proxy": { "mcp": "read" } }

"read" serves get_status (the fleet at a glance: server version, current account, and for each account its priority, whether it is disabled, whether it is cordoned and how many conversations are left on it, whether rotation can use it and why not, sessions and known quota windows), get_quota and get_settings. "full" adds everything the CLI's management commands can do: switch_account, reload_config, probe_quota, set_account_enabled, set_account_cordoned, release_account_pins, set_account_priority, set_account_routing, remove_account, set_threshold, set_distribution, set_probe_interval, set_warmup, set_route, remove_route, set_blocked_models and set_client_mode. There is no tool for adding accounts or handling account credentials, and none for changing proxy.mcp itself. set_account_routing does take a proxy URL with its password, and the write log prints that URL masked. reload_config re-reads the file and reports how many accounts it added and how many it removed: an account whose entry is gone from the file is dropped from the running fleet (see accounts). A reload picks the proxy.mcp setting up, so the endpoint can be opened, narrowed or closed while the server runs.

Point Claude Code at it once; teamclaude run and teamclaude env already keep loopback out of the proxy variables, so the connection goes straight to the server and is key-exempt like every other loopback caller:

claude mcp add --transport http teamclaude http://localhost:3456/teamclaude/mcp

A client elsewhere on the network presents the proxy key the same way the CLI does: --header "x-api-key: tc-…".

The endpoint is one more /teamclaude/ route and is gated like the others: the proxy key or loopback, no cross-origin requests, and, for a caller admitted without a key, a Host header naming this machine. Three things follow from that. Every holder of any proxy key can read through it, but a named proxy.clientKeys key is served the "read" tools even when the setting is "full": the write tools — removing an account among them — answer only to the shared proxy.apiKey and to key-exempt loopback callers, so handing a client its own key never hands it the fleet. With no proxy key configured at all, the endpoint serves only callers on the proxy's own machine (a loopback peer, no X-Forwarded-For/X-Real-IP/Forwarded header, and proxy.trustLoopback not set to false) and answers 403 to everyone else; set proxy.apiKey to reach it over the network. And a browser-based MCP client cannot reach it, because it sends an Origin header and is refused as cross-origin; the endpoint is for clients that run as programs. Each write is logged by the server as one line naming the tool and the arguments.

It speaks both the stateless 2026-07-28 revision of the protocol and the handshake revisions before it, so a client on either works. Replies are plain JSON, never a stream.

CLIProxyAPI-compatible usage API

Some usage dashboards read a multi-account fleet through the management API of CLIProxyAPI rather than through each provider. The server can answer the part of that API those dashboards use, so the quota of every account in the pool shows up there. It is off until the config says otherwise:

{ "proxy": { "cliproxyApi": "read" } }

Point the dashboard's "CLI Proxy" source at the proxy (http://localhost:3456) and give it the proxy key as its management key. It sends the key as Authorization: Bearer <key> (X-Management-Key and x-api-key work too); proxy.apiKey and every proxy.clientKeys key are accepted, since the data is no more than /teamclaude/status already shows a key holder.

Two routes are served:

  • GET /v0/management/auth-files lists the Claude and Codex subscription accounts as { "observed_at", "files": [{ id, auth_index, name, provider, email, status, disabled }] }, in the fleet's own order. auth_index is the account's config entry id, and status is error for an account whose login was rejected. API-key and third-party backend accounts have no subscription usage and are not listed. CLIProxyAPI's query parameters work as they do there: name (an id or a name) and auth_index narrow the list, and page / page_size (default 50) page it, adding total, page, page_size and has_more; a paging value that is not a positive whole number is a 400.
  • POST /v0/management/api-call with { "auth_index", "method": "GET", "url" } answers two URLs: https://api.anthropic.com/api/oauth/usage for a Claude account and https://chatgpt.com/backend-api/wham/usage for a Codex one. The reply is CLIProxyAPI's envelope, { "status_code": 200, "header": {…}, "body": "<json>" }, with the body in the provider's own shape: five_hour, seven_day and weekly_scoped limits on a 0–100 scale with ISO-8601 reset times for Claude, rate_limit.primary_window / secondary_window with used_percent and epoch-second reset_at for Codex.

Unlike CLIProxyAPI, api-call relays nothing. The answer is built from the quota the server already tracks; no request goes upstream, no credential is read, and the request's header and data (including any $TOKEN$ placeholder) are ignored. Any other URL or method is refused with 403. Codex reset credits are not offered: their list and consume URLs, and POST /v0/management/reset-quota, answer 501, because spending a credit is irreversible. Press r on the local TUI main screen, then choose the account for a manual spend, or use the server's own autoRedeemResets policy for automatic spending.

The readings are as fresh as the server's: an account in use is read off every response, an idle one only by the quota probe, which is off by default. Turn the probe on for current numbers on idle accounts. Three cases are reported the way the provider would report them, so a dashboard can tell them apart:

  • A window the plan meters but that has no live reading — it reset since the last reading — is sent as the provider sends a window that has not started: { "utilization": 0, "resets_at": null } for Claude, used_percent: 0 with reset_at: null for Codex. That is what the server itself believes about the account; usage spent outside the proxy since the reset is not seen until the next reading.
  • A window the plan does not meter is null: seven_day on a Team seat, and the 5-hour window on a Codex plan without one (its weekly window is then the primary).
  • An account the server cannot vouch for answers a non-2xx status_code inside a 200 envelope, so the dashboard shows it as unreadable rather than idle: 503 for an account never read yet, 401 for one whose login was rejected (what the provider answers a dead token).

The gates are the ones every other route passes, plus the MCP endpoint's rule for a config with no proxy key at all: then only callers on the proxy's own machine are served, and everyone else gets 403. Every path under /v0/management/ is answered by the proxy itself, on or off, and never forwarded upstream; a WebSocket handshake there is refused with 404.

Usage history

/teamclaude/status keeps lifetime counters and 5-hour and 24-hour windows per client. For a longer look back, broken down by model and account as well, the server can keep a history in a local SQLite file. It is off until the config says otherwise:

{ "proxy": { "usageHistory": true } }

Each request forwarded to an account becomes one row: when, which consumer, model and account, the input, cache-read, cache-write and output tokens, and the status. A request the pool could not serve is a row too, with status 429 and the account (unknown). Calls that go straight to the client's own login (its identity and control-plane calls, token refreshes), plain forward-proxy traffic and WebSocket channels are not recorded, and neither are the telemetry batches the activity log hides (eventLogging). A GET that the scope-denial retry passes on to the client's login is, under the account (unknown) with no tokens. A consumer is a proxy.clientKeys name, so give each of your machines and integrations its own key to tell them apart. Traffic without a named key is booked as (shared) (proxy.apiKey), (local) (a key-exempt caller on the proxy's own machine) or (open) (a proxy with no key at all). Accounts are booked by name. Nothing of a request's content is stored.

GET /teamclaude/usage?window=5h|7d|30d answers with totals and the same measures per consumer (callers), per consumer and model (callerModels), per model (models) and per account (accounts): requests, tokens, input, cacheRead, cacheWrite, output, refusals (requests answered 429) and capped (requests refused by a weekly key limit). 5h is read from the raw rows; 7d and 30d from an hourly rollup, snapped to whole hours, with since and until saying what the window covers. Any other window is a 400. The route sits behind the same gates as /teamclaude/status.

The file sits beside the config, named after it: config.usage.db for config.json, and like the config it is readable by its owner only. Raw rows are kept 90 days and the hourly rollup 400 days, pruned once a day. History never fails or delays a request. A row that cannot be written, a locked file included, is logged and skipped. A file that cannot be opened at start turns history off, says so in the log, and the route then answers available: false; a file found corrupt at start is moved aside and a new one started instead. History needs node:sqlite: Node 22.13 or later, or 22.5 to 22.12 started with --experimental-sqlite. On an older Node the route answers available: false the same way.

Weekly spending limit per client key

A proxy.clientKeys entry can carry weeklyUsd, a limit on what that key may spend in a week. It is meant for one of your own agents that runs unattended: a loop that goes wrong stops at the figure instead of using up the week of every account.

{ "proxy": { "clientKeys": [{ "name": "nightly-agent", "key": "tc-…", "scope": "inference", "weeklyUsd": 200 }] } }

The spend is an estimate at API list prices, from the usage block of each reply the pool serves the key, priced with the same table as the prepaid-credit estimate at the model the account was sent (after its modelMap). A reply the table cannot price, such as an unknown model, Priority Tier or a Codex reply, is charged the highest rate the table has in each category, which can be many times its real list price, so such a key stops early; the log says so once per model and reason. A reply with no usage block costs nothing.

The week starts Monday 00:00 UTC. Each request to the pool is checked before an account is chosen: a key at or over its figure gets 403 with a permission_error naming the limit, the spend and the reset time. (Not 429, which Claude Code retries.) Requests already running when the key crosses the figure finish, so the spend can end above it by what they cost. Requests that do not go to the pool, such as the client's own login calls, and requests without a named key are not limited.

/teamclaude/status lists each key with a limit under clientLimits, with weeklyUsd, spentUsd, remainingUsd and resetsAt, or invalid: true for a figure that cannot be read (also reported in the log when the config is loaded). With usage history on, the usage route counts refused requests under capped.

The spend is kept in memory. With usage history on, a restart reads the current week back from the recorded rows. Rows written before this feature carry no cost, so the week of the upgrade starts low. Without usage history a restart starts the week from zero.

Auto-update

When TeamClaude is installed globally via npm, it self-updates in the background: it checks the npm registry at most once a day, and when a newer version is published it runs npm install -g @karpeleslab/teamclaude@latest and applies it on the next launch. The check runs after a teamclaude run session ends and when a headless server starts. In a headless server the install runs as a background child process, so the proxy keeps serving requests while npm works (a synchronous install used to stall it for the duration). A git checkout is never touched — update that with git pull. Run teamclaude update to update on demand.

Only an npm global install is updated in place. Any other copy gets a notice when a newer version is out. A pnpm global install is recognized: the notice names pnpm add -g @karpeleslab/teamclaude@latest, and teamclaude update prints that command instead of running npm, which would install a second copy and leave the one on your PATH as it was. Update a copy that another tool installed, such as Yarn or Bun, with that tool as well.

Disable it with TEAMCLAUDE_DISABLE_AUTOUPDATE=1 or "autoUpdate": false in the config.

Request logging

Log request/response details to a directory, one file per logged request:

teamclaude server --log-to /tmp/requests

Bodies are truncated past a size cap, and files older than the retention window are deleted — see logLevel, logMaxBodyBytes and logRetentionHours to widen or disable them. The first start after upgrading sweeps whatever in that directory is already older than the window.

--activity-log FILE appends the TUI activity lines to a file instead, and works in headless mode too.

A request line whose response reported token usage ends with its prompt-cache figures: cache r180k w3k in1k is tokens read from the cache, written to it, and sent uncached (k from 1000 up). By the share read from the cache, r / (r + w + in), the TUI paints it green at 0.90 or more (hit), yellow from 0.50 (partial) and red below (miss), and dims it when the request neither read nor wrote the cache. A miss also ends with MISS, so it can be found with grep in a log file, which has no colour. After a failover or a retry the figures are the last attempt's.

A request line whose response was a JSON error from the upstream names its type after the status: (404 thread_not_found, 0.3s). The name is error.details.error_code when the body has one, else error.type, kept only if it is a plain identifier (letters, digits, _, ., -) and cut to 32 characters; nothing else from the body is shown. Errors the proxy answers itself, non-JSON errors and bodies over 64 KiB are shown with the status alone.

Claude Code's telemetry (/api/event_logging/*) is high-volume activity-log noise and is hidden from the log by default; see eventLogging to block or show it instead.

Request correlation

A caller can name its own requests, so the proxy's log lines and activity can be matched to the caller's records.

  • The proxy reads x-request-id from the caller. It uses that value when it is one header value of 1 to 128 characters from letters, digits, ., _, : and -. Anything else (absent, too long, other characters, or repeated) is replaced by a generated UUID.
  • Every response from the proxy's forwarding listener carries the id as x-teamclaude-request-id, including refusals and streamed responses. An upstream's own x-request-id (Codex sends one) is passed through unchanged.
  • The id is for correlation only. It is not an identity, it is not used to deduplicate requests, and it never affects which account is chosen. The inbound x-request-id is still forwarded upstream as the caller sent it.
  • Each upstream attempt's request-log file starts with a header such as === REQUEST (account: live, retry: 1, attempt: 2, request: 1, caller: ticket.42) ===. request is the proxy's number for the request, attempt counts the upstream sends for it (a failover, a 429 retry and a stream-failure hop each add one), and caller is the caller's id. A hop that is answered with a 401 writes no file of its own, so the files show the attempt that answered.
  • The activity hooks (onRequestStart, onRequestEnd) carry callerRequestId, and onRequestEnd also carries attempts.

Tools built by others

These are separate projects with their own authors. They are listed because they build on TeamClaude's documented surfaces; nothing here is maintained, reviewed or released by this project, so read a tool's own source and permissions before you install it.

  • Runout Bar (macOS, MIT): a menu bar app that reads teamclaude status --json and draws one level bar per account, with the time the pool is projected to run out. It switches accounts and probes through the teamclaude CLI.

A tool like these should read teamclaude status --json or GET /teamclaude/status, and act through the CLI or the control routes. Those are the surfaces meant for other programs, and the rename to TeamRouter keeps their old names working through 2.x. The config file's layout and the modules under src/ are not an interface and change without notice.