-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Feature: API rate limit usage (5H/WK) in statusline #924
Copy link
Copy link
Open
Description
Summary
The current statusline shows context window usage, but not API rate limit utilization — the 5H and 7-day (weekly) percentages that determine when you get throttled on Claude Max.
I've been running a custom implementation of this for a few weeks and it's been really useful for pacing usage and knowing when limits reset.
What it looks like
▰ USE: 5H: 12% ↻10:59 │ WK: 6% ↻Thu 23:00 │ CTX:────────── 6%
- 5H: 5-hour rolling utilization percentage + reset time
- WK: 7-day rolling utilization percentage + reset day/time
- Reset times shown as local clock time (e.g., "10:59", "Thu 23:00")
- Color-coded green→yellow→orange→red based on utilization
How it works
- Extracts the OAuth access token from the macOS Keychain (
Claude Code-credentials) - Calls
https://api.anthropic.com/api/oauth/usagewith a 60-second cache TTL - Parses
five_hour.utilization,seven_day.utilization, and theirresets_attimestamps - Renders inline with the existing context bar
Considerations
- macOS-only for credential extraction (uses
security find-generic-password). Falls back gracefully on Linux — the usage line simply doesn't appear if no token is found. - The Keychain can return credentials as either raw JSON or hex-encoded data (varies by macOS version), so the token parser handles both formats.
- Adds ~200 lines to the statusline script (usage fetch/cache + rendering across all 4 display modes).
- Respects the existing
statusline.sections.usagetoggle in settings.json.
Next steps
Happy to submit a PR if there's interest. Wanted to gauge whether this fits the upstream vision before sending 200+ lines of new code.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels