claude-code-quota
Displays your Claude Code OAuth quota (5-hour session % and weekly %) live in
your terminal status line, with no daemon process required.
Sonnet 4.6 | main | ctx:42% | 5h:68% ~1h12m | 7d:31% ~4d2h
If your plan includes a model- or surface-scoped limit (a separate allowance
from the 5h and weekly buckets), it gets its own segment — and only appears
when you actually have one:
Opus 5 | main | ctx:42% | 5h:60% ~48m | 7d:59% ~1d2h | Fable:90%⚠

Works on Windows 11 (PowerShell — no extra dependencies) and
Linux / WSL2 (bash + jq).
Install as a Claude Code plugin
The repo is its own plugin marketplace. Inside Claude Code:
/plugin marketplace add aweussom/claude-code-quota
/plugin install claude-code-quota@aweussom
This gives you the /quota skill immediately. Claude Code plugins cannot
configure the status line itself (that lives in your own settings.json), so
after installing, ask Claude to "set up my quota statusline" — the skill
walks it through running the installer — or run install.ps1 / install.sh
yourself as described below.
Based on the work in:
How it works
On every status line refresh Claude Code emits, the library:
- Checks the age of a local cache file (
~/.claude/quota-data.json)
- If fresh enough — returns immediately (no network call)
- If stale — fires a background refresh (non-blocking), returns the previous
frame's data immediately; the next frame gets fresh data
- On the very first call (no cache) — blocks briefly for the initial fetch
The TTL is controlled by the caller:
- 60 seconds while an active session is running (transcript recently written)
- 5 minutes while idle
The caller's TTL is a floor, not the final word. After a failed fetch the library
tapers its own retries — 60s, 120s, 240s, 480s, capped at 15 minutes — keyed on
the consecutive_failures counter in the cache. Without this, a rate-limited or
briefly unreachable endpoint gets retried on every refresh, which turns a short
outage into a long one.
Several Claude Code sessions share one cache file, so both are concurrency-safe:
the cache is written to a temp file and renamed (readers see the old or new file,
never a half-written one), and the fetch lock is created with O_EXCL /
FileMode::CreateNew so simultaneous sessions can't all launch a fetch at once.
A lock is treated as abandoned once it exceeds 120 seconds, since PIDs get
recycled and a reused PID would otherwise look like a fetch in flight forever.
When a fetch fails
Failures are never silent — the reason is written to the cache and exposed to
your statusline script:
- Old data still available → the percentage keeps showing with a
⚠
appended (stale marker). Run /quota to see the full error.
- Old data available but its window has since reset → the percentage is
dropped and the segment shows
?⚠. The stored figure describes a window that
has already been spent, so it is no longer reported as fact. See
Unknown vs. missing.
- No data at all (first fetch failed, e.g. missing OAuth token) → the
error result field carries a human-readable reason, and the bundled
statusline shows it in red, e.g. quota: Cannot read OAuth token.
- Unreadable cache file →
error says so and suggests deleting
~/.claude/quota-data.json to reset.
Sessions that do not spend Anthropic quota
ollama launch claude --model glm-5.3-flash:cloud runs Claude Code against
the local Ollama daemon. No Anthropic quota is spent, but the status line
still showed the Anthropic numbers. Real numbers, just about the wrong
account.
The library now decides from ANTHROPIC_BASE_URL, not from the model ID. A
gateway can serve claude-* names from anywhere.
Under Ollama it reads https://ollama.com/api/balance with your
OLLAMA_API_KEY and shows that account's windows instead:
glm-5.3-flash:cloud | main | ctx:17% | 5h:1% ~3h39m | 7d:26% ~4d12h
Ollama reports what is left; the status line shows percent used, same as for
Anthropic. No scoped segment because Ollama has no per-model allowances. Once
an included window is spent, the purchased balance appears, since that is when
requests start costing money:
glm-5.3-flash:cloud | main | ctx:17% | 5h:100% | 7d:26% ~4d12h | $0.73
Point ANTHROPIC_BASE_URL at any other gateway and you get no quota segments
at all. The Anthropic figures are provably wrong for that session and there is
nothing to replace them with, so the segments are left out rather than filled
with a guess.