ccusage
Claude Code usage monitor. Fetches your real rate limit data from Anthropic's API and displays it in the Claude Code statusline.
Example output
ccusage command:
Plan: max_5x
Session 39% resets 1h26m
Week (all) 15% resets 143h26m
Week (Sonnet) 39% resets 65h26m
Extra usage $0.00 / $1000.00
Claude Code statusline (self-caching — refreshes from API when stale, no daemon needed):
~/projects/myapp [Opus 4.6] sess:39% 7d:15% son:39% | $1.37 | max_5x | reset:1h26m
Install
uv tool install ccusage
Then run:
# Check usage once
ccusage
# Run the daemon (keeps usage-limits.json updated)
ccusage daemon
Configure the statusline in ~/.claude/settings.json:
{
"statusLine": {
"type": "command",
"command": "ccusage statusline"
}
}
If Claude Code uses CLAUDE_CONFIG_DIR, ccusage reads credentials and writes
usage-limits.json in that directory instead.
Each refresh also saves a copy under usage-limits/<account uuid>.json, tagged with the logged-in account's UUID and email from Claude Code's .claude.json. If you switch between Claude accounts with /login, the account you logged out of keeps its last usage there. An idle account cannot use quota, so that snapshot stays accurate until its windows reset.
Commands
| Command | Description |
|---|---|
ccusage |
Show current usage (colored terminal output) |
ccusage json |
Print raw JSON |
ccusage daemon [-i SECS] |
Run in foreground, refresh every 5 min (customizable) |
ccusage statusline |
Claude Code statusline (self-caching, no daemon needed) |
ccusage install |
Print setup instructions |
How Claude Code rate limiting works
Discovered by inspecting Claude Code's bundled cli.js (v2.1.32).
Data sources
Claude Code gets rate limit data from two places:
-
/api/oauth/usageendpoint — Called by the/statusslash command. Returns utilization percentages and reset times for each rate limit bucket. Requires theanthropic-beta: oauth-2025-04-20header. -
Response headers on every API call — Every message response includes headers like:
anthropic-ratelimit-unified-{claim}-utilization(0-100 float)anthropic-ratelimit-unified-{claim}-reset(unix timestamp)anthropic-ratelimit-unified-status(allowed/allowed_warning/rejected)anthropic-ratelimit-unified-fallback(availablewhen fallback models are available)anthropic-ratelimit-unified-overage-status/overage-resetanthropic-ratelimit-unified-representative-claim
Rate limit types
| Type | Key in API response | Description |
|---|---|---|
five_hour |
five_hour |
Rolling 5-hour session window |
seven_day |
seven_day |
Rolling 7-day all-models window |
seven_day_sonnet |
seven_day_sonnet |
Rolling 7-day Sonnet-specific window |
seven_day_opus |
seven_day_opus |
Rolling 7-day Opus-specific window |
overage |
extra_usage |
Extra/overage usage (if enabled) |
The flat seven_day_* keys above are all null now — the live quota data
lives in a structured limits array, which ccusage reads. Each entry is
self-describing: kind (session / weekly_all / weekly_scoped),
percent, resets_at, and for scoped limits a scope.model.display_name.
Because the structured response does not include a session duration, ccusage
labels that limit Session and caches it under session rather than assuming
it is always five hours. Existing 5h cache files remain readable.
Model-scoped weekly windows (Opus, Sonnet, and a newly added Fable) are
keyed by their model name, so any new one is auto-detected and displayed with
no code change (e.g. scope.model.display_name: "Fable" → "Week (Fable)",
statusline fab:).
API response format
GET https://api.anthropic.com/api/oauth/usage
Authorization: Bearer <oauth_access_token>
anthropic-beta: oauth-2025-04-20
{
"five_hour": {
"utilization": 35.0,
"resets_at": "2026-02-06T22:00:00+00:00"
},
"seven_day": {
"utilization": 14.0,
"resets_at": "2026-02-12T20:00:00+00:00"
},
"seven_day_sonnet": {
"utilization": 39.0,
"resets_at": "2026-02-09T14:00:00+00:00"
},
"seven_day_opus": null,
"seven_day_oauth_apps": null,
"seven_day_cowork": null,
"iguana_necktie": null,
"extra_usage": {
"is_enabled": true,
"monthly_limit": 100000,
"used_credits": 0.0,
"utilization": null
}
}
Authentication
The OAuth token normally lives at ~/.claude/.credentials.json, or under
CLAUDE_CONFIG_DIR when that environment variable is set:
{
"claudeAiOauth": {
"accessToken": "sk-ant-oat01-...",
"refreshToken": "sk-ant-ort01-...",
"expiresAt": 1770412938485,
"subscriptionType": "team",
"rateLimitTier": "default_claude_max_5x"
}
}
The access token expires roughly hourly. When it's expired (or rejected with a 401/403), ccusage refreshes it itself using the refreshToken and writes the rotated credentials back to .credentials.json — the same flow Claude Code uses, so the two stay in sync and no active Claude Code session is needed.
Warning thresholds (from cli.js)
Claude Code shows inline warnings based on these thresholds:
five_hour: 90% utilization when 72% of window has passed
seven_day: 75% at 60%, 50% at 35%, 25% at 15%
Other endpoints found in cli.js
/api/oauth/profile— User profile/api/oauth/account/settings— Account settings/api/claude_code/policy_limits— Org policy limits (needsorganizationUuid)/api/organization/claude_code_first_token_date— Org onboarding date
Local files Claude Code uses
| File | Written by | Contains |
|---|---|---|
~/.claude/.credentials.json |
Claude Code | OAuth tokens, plan tier |
~/.claude/stats-cache.json |
Claude Code | Local usage stats (message counts, token counts per model) |
~/.claude/usage-limits.json |
ccusage daemon | Cached API usage data (this tool) |
~/.claude/usage-limits/<account uuid>.json |
ccusage daemon | Last usage seen for each Claude account (this tool) |
~/.claude/statsig/ |
Claude Code | Feature flags, experiment assignments |
Metadata
Release files for ccusage 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ccusage-0.2.0.tar.gz | 17.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ccusage-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.1 kB
Release files / ccusage-0.2.0.tar.gz
| Download URL | ccusage-0.2.0.tar.gz |
|---|---|
| Size | 17.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
72c6aa9e60c30a9f7e14e025f0eabf7a94a92dc77d10fd5a3d84a528e3878d24
|
|
BLAKE2b-256 checksum How to use checksums |
7a1c65141291beefe5baa6a6984d5ff727505fb91c489a8bcd3b3e00d77798d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / ccusage-0.2.0-py3-none-any.whl
| Download URL | ccusage-0.2.0-py3-none-any.whl |
|---|---|
| Size | 13.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bac4d0548f72e7de7bbfa6f0d960ec481161e44590e4fcf2c9a7cb156d7af4f5
|
|
BLAKE2b-256 checksum How to use checksums |
afa470faff56f5821283d1db5a6abeeaa2412fa733cbe4cc68973271f0e014e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|