feat: expose rate limit data in statusline JSON
Problem
The statusline feature provides rich session data (context window, cost, model info) that can be used in tmux/terminal statuslines. However, rate limit information is not included, even though it's available internally from API response headers.
The /usage command shows rate limit data (remaining tokens, reset time) inside the TUI, but this data is only accessible within the running process — it's not persisted to disk or exposed to external scripts.
Current statusline JSON
{
"cost": { "total_cost_usd": 17.82 },
"context_window": { "used_percentage": 30, "remaining_percentage": 70 },
"model": { "id": "claude-opus-4-6" }
}
Requested addition
{
"rate_limit": {
"tokens_remaining": 150000,
"tokens_limit": 200000,
"used_percentage": 25,
"reset_at": "2026-02-16T18:00:00Z"
}
}
The data is already available from Anthropic API response headers (anthropic-ratelimit-tokens-remaining, anthropic-ratelimit-tokens-reset) — it just needs to be forwarded to the statusline output.
Use case
I have a custom tmux statusline that shows context usage, per-model cost breakdown (Opus/Sonnet/Haiku), and accumulated spending (day/week/month). Adding rate limit visibility would complete the picture — letting me know when I'm approaching limits without having to run /usage interactively.
Why external access matters
/usageonly works inside an interactive session- OAuth tokens don't work with the standard Messages API, so external scripts can't query rate limits independently
- Rate limit headers are not stored in debug logs, transcripts, or any cache file
- The statusline script is the natural place for this data since it already receives real-time session state
Environment
- Claude Code 2.1.42
- Max 5x plan
- Linux (tmux statusline via
statusline_commandsetting)
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗