claude-quota

Claude Code statusline plugin · Node.js · MIT

Know you will run out before you run out.

Claude Code tells you about a quota when you hit it. claude-quota reads the same usage API the /usage page reads and keeps every bucket in the statusline while you work: the 5-hour session, the 7-day window, Sonnet and Opus, extra usage — and an arrow that says whether you will make it to the reset.

5quota windows in view: 5h, 7d, Sonnet, Opus, extra
3 → 1lines, sized to the terminal
0fetches on the hot path
Three-line statusline: model and context on the first line, the 5-hour and Sonnet quotas on the second, the 7-day quota and extra usage on the third

A percentage alone does not say whether you are in trouble; 60 % used with 80 % of the window gone is fine, 60 % used with 20 % gone is not. The pace arrow does that arithmetic for you, on every refresh.

Pace, not just percentage

↗145% is where you land at reset at the current rate. Over 100 % means the quota runs out first. The clock glyph ○◔◑◕● shows how much of the window has elapsed.

Every bucket

The 5-hour session, the 7-day all-models window, the 7-day Sonnet and Opus windows, and extra usage with spent, pace, projected and the monthly limit.

Colour carries the warning

Numbers stay small; the bar cells, the arrow and the money turn yellow and red on their own thresholds, and the cells the quota will never reach go grey.

Fits any terminal

Measured in columns, never wraps. Three lines on a normal terminal, two on a short one, model │ ctx% │ 5h% │ 7d% on one.

A live dashboard

Every render also writes an HTML dashboard beside its cache — one card per window with a pace gauge — and links it from line 1 on terminals with OSC 8 links.

Nothing new to trust

The token is the one Claude Code already holds, read from the Keychain. Every file written is 0600, dashboard strings are HTML-escaped, and the cache refuses files with broader permissions.

How a render runs

Claude Code runs the plugin as a subprocess on every statusline refresh.

The HTML dashboard: one card per window with quota, elapsed time, a pace gauge and the reset time
The dashboard: the statusline's figures, one card per window, polled every five seconds.
  1. Context arrives on stdin

    Model, effort, context window and cwd, as JSON — the same payload every statusline command gets.

  2. The token is read

    From the macOS Keychain, or from ~/.claude/.credentials.json elsewhere if it is 0600 and yours. The same credential Claude Code uses; no login of its own.

  3. Usage is fetched or served from cache

    GET api.anthropic.com/api/oauth/usage, cached for two minutes. From 90 seconds a background refresh starts, so a long session never shows stale numbers and never fetches on the hot path.

  4. One to three lines

    Rendered to stdout, sized to the terminal; the reset timer, then pace and projection, then the bar are dropped in that order until the line fits. The dashboard is rewritten beside the cache.

Install

Node.js 18 or newer, and a Pro or Max subscription: the usage API has nothing for API-key logins, so only the model and context line renders there.

From npm

npm install -g @mmdemirbas/claude-quota

Then point the statusline at it in ~/.claude/settings.json:

settings.json

{
  "statusLine": {
    "type": "command",
    "command": "claude-quota"
  }
}

If you use claude-hud, disable it first so the two do not share the line.

What you see

Each segment of the statusline and what it means.

SegmentMeaning
sonnet highModel family and effort level
ctx:██░░░░░░░░ 23%Context window: a 10-cell bar and the percentage
dashboardAn OSC 8 hyperlink to the HTML dashboard; plain text where links are unsupported
lakelab git:(main*)Project directory and branch; * means a dirty working tree
max 5xPlan name and multiplier
5h: 7d: snt: ops:The 5-hour session, the 7-day all-models window, the 7-day Sonnet and Opus windows
█████░░░░░ 31%Used share of the window
↗145% → 90% ↘ 74%Pace: the projected share at the end of the window; over 100 % means the quota runs out before it resets
◔3h56mTime until reset; the glyph is how much of the window has elapsed
⟳18:00Local time of the last successful fetch
●$: / ○$:Extra usage on or off
$0 ↘ $0 /$5Extra usage spent · pace · projected · monthly limit

Security model

The plugin reads a credential and writes files in your home directory, so each surface has a rule.

SurfaceRuleWhy
Credential sourceKeychain first; ~/.claude/.credentials.json as the fallback, refused unless 0600 and owned by youA token planted by another local user is never used
Cache filesdata.js, credit-grant.js, .profile-cache.json, dashboard.html under ~/.claude/plugins/claude-quota/, mode 0600; broader modes are refusedA second local user cannot feed the dashboard
Dashboard outputEvery externally sourced string is HTML-escapedA tampered API response cannot run script in the page
HTTPSSystem trust store, TLS 1.2 minimum, no certificate pinAnthropic rotates the leaf without a published pin set; a hardcoded pin would become an outage
StderrOne warning line for HTTP 401/403 and rejected files; rate limits and expiry stay silentCLAUDE_QUOTA_SILENT=1 disables all warnings