Claude Code usage monitor — fetches rate limits from Anthropic's API
Project description
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 (5h) 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] 5h: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"
}
}
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) |
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 lives at ~/.claude/.credentials.json:
{
"claudeAiOauth": {
"accessToken": "sk-ant-oat01-...",
"refreshToken": "sk-ant-ort01-...",
"expiresAt": 1770412938485,
"subscriptionType": "team",
"rateLimitTier": "default_claude_max_5x"
}
}
The access token expires roughly hourly. Claude Code refreshes it automatically — as long as you have an active Claude Code session, the token stays valid for ccusage to read.
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/statsig/ |
Claude Code | Feature flags, experiment assignments |
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 ccusage-0.1.1.tar.gz.
File metadata
- Download URL: ccusage-0.1.1.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1b7f1c2452a64906b17cba978a05e833d42e3011307acf0ceb28daf0a9fe147
|
|
| MD5 |
8bd92772cd628688e67b11ed03fad585
|
|
| BLAKE2b-256 |
b1f06c5e4407c3f9f2311da897f07447a2d6b5278ba9defde7428f78c0f6432c
|
Provenance
The following attestation bundles were made for ccusage-0.1.1.tar.gz:
Publisher:
publish.yml on wakamex/ccusage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ccusage-0.1.1.tar.gz -
Subject digest:
c1b7f1c2452a64906b17cba978a05e833d42e3011307acf0ceb28daf0a9fe147 - Sigstore transparency entry: 1058402363
- Sigstore integration time:
-
Permalink:
wakamex/ccusage@bfdd8f06ca76e3db18da980cf5685356f96b27e2 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/wakamex
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bfdd8f06ca76e3db18da980cf5685356f96b27e2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ccusage-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ccusage-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc9c33dfe199483ea27c0d2afb10be5b46dce5708070fb6c58bfce057af5fb85
|
|
| MD5 |
bc20431ddc7b24b0c53c287b50010ec5
|
|
| BLAKE2b-256 |
5bff8ecbf1af946d66ea6f45f4eed1305114a5ecc5564ae9e791ee3674f2896f
|
Provenance
The following attestation bundles were made for ccusage-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on wakamex/ccusage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ccusage-0.1.1-py3-none-any.whl -
Subject digest:
bc9c33dfe199483ea27c0d2afb10be5b46dce5708070fb6c58bfce057af5fb85 - Sigstore transparency entry: 1058402371
- Sigstore integration time:
-
Permalink:
wakamex/ccusage@bfdd8f06ca76e3db18da980cf5685356f96b27e2 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/wakamex
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bfdd8f06ca76e3db18da980cf5685356f96b27e2 -
Trigger Event:
release
-
Statement type: