Skip to content

Feature: API rate limit usage (5H/WK) in statusline #924

@nbost130

Description

@nbost130

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

  1. Extracts the OAuth access token from the macOS Keychain (Claude Code-credentials)
  2. Calls https://api.anthropic.com/api/oauth/usage with a 60-second cache TTL
  3. Parses five_hour.utilization, seven_day.utilization, and their resets_at timestamps
  4. 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.usage toggle 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions