Feature: expose rate limit utilization in statusLine JSON input
Summary
The statusLine command receives a rich JSON payload via stdin (session info, model, cost, context window tokens, etc.), but it does not include rate limit utilization data. The /usage command displays "Current session" and "Current week (all models)" percentages — I'd like to show the same info in my custom status line.
Current behavior
The statusLine JSON input includes:
{
"cost": { "total_cost_usd": ... },
"context_window": {
"used_percentage": 20,
"remaining_percentage": 80,
"total_input_tokens": ...,
"total_output_tokens": ...,
"current_usage": { ... }
},
"exceeds_200k_tokens": false
}
No rate limit / utilization fields are present.
Desired behavior
Add rate limit utilization to the statusLine JSON, mirroring what /usage shows:
{
"rate_limit": {
"five_hour": {
"utilization": 0.42,
"resets_at": 1741372800
},
"seven_day": {
"utilization": 0.15,
"resets_at": 1741737600
},
"seven_day_sonnet": {
"utilization": 0.08,
"resets_at": 1741737600
},
"status": "allowed"
}
}
Fields can be null/absent when data hasn't been received yet (before the first API call) or when running with an API key that doesn't return unified rate limit headers.
Why
- The data already exists in memory (parsed from
anthropic-ratelimit-unified-*response headers into theFGstate variable) - The statusLine builder function (
cyq()) just needs to read and include it - This lets users build status lines that show usage warnings without needing to open
/usagemanually - Particularly useful for team/enterprise users monitoring session and weekly budgets
Workarounds considered
- Querying the API externally: OAuth tokens return
"OAuth authentication is currently not supported"oncount_tokens, so there's no way to get the headers from outside the process - Reading from disk: The rate limit state is only held in memory, not persisted
- Parsing transcripts: Rate limit info is not written to session transcripts
None of these work — the data is only accessible inside the Claude Code process.
Environment
- Claude Code v2.1.71
- Subscription: Team (Claude Max 5x)
- Platform: Linux (Fedora 43)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗