feat(statusline): show 5h/7d rate-limit usage with reset times#2550
Draft
tjcouch-sil wants to merge 2 commits into
Draft
feat(statusline): show 5h/7d rate-limit usage with reset times#2550tjcouch-sil wants to merge 2 commits into
tjcouch-sil wants to merge 2 commits into
Conversation
Append Claude.ai Pro/Max rate-limit usage to the right of the branch in the status line: "5h N% (HHMM) | 7d N% (D MMM HHMM)". Reset times render in the machine's local time zone (24-hour). The segment degrades gracefully when rate_limits is absent (API-key auth or before the first API response) and per-window when a window or its percentage is missing. Set statusLine.refreshInterval to 60 so the reset-time clocks update while the session is idle. True right-alignment isn't possible: Claude Code doesn't pass terminal width and stdout is a pipe (no tty), so $COLUMNS / tput cols are unreliable. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
tjcouch-sil
marked this pull request as draft
July 14, 2026 13:36
… WSL2) Replace the per-session rate-limit read with a cross-session harvest: every session writes the account-wide 5h/7d usage it observes to a shared file and displays the freshest value across all sessions, so the figure updates ~every minute (with refreshInterval) even while this session is idle. Freshness is resolved by later resets_at, then higher percentage; stale readings (>5 min) are flagged with "*". The shared file resolves to the SAME physical file from native Windows and WSL2 (Windows-side home via /mnt/c), and to the normal per-home file on macOS and plain Linux. An optional CLAUDE_USAGE_SHARED_FILE env var overrides the location. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Augments the status line to show Claude.ai Pro/Max rate-limit usage to the right of the branch:
5h N% (HHMM)— 5-hour rolling window, reset time in local 24-hour time.7d N% (D MMM HHMM)— weekly window, reset time as day / 3-char month / local 24-hour time.How
jq, nodate— portable, and Node handles the local time zone).|. True right-alignment isn't possible: Claude Code doesn't pass terminal width to the status line and stdout is a pipe (no tty), so$COLUMNS/tput colsare unreliable.statusLine.refreshIntervalset to60so the(HHMM)reset clocks tick while the session is idle..claude/settings.jsonThis PR edits
.claude/settings.json(to addrefreshInterval: 60), which this repo intentionally deny-lists for agent edits (Edit(.claude/settings.json)/Write(...)). That guardrail targets silent agent edits to permission/hook config; this is a reviewed, benign status-line change and doesn't alter permissions or hooks. Flagging it explicitly so the change gets a deliberate look. If you'd prefer to keep that file untouched, drop the one-linerefreshIntervaladdition and the status line still works — the reset clocks just refresh on activity rather than every 60s.Degradation (verified with mock input)
rate_limitsabsent (API-key auth, or before the first API response) → segment omitted; line ends at the branch.used_percentagenull → only the available window shows.resets_at→ percentage shown without the(…).Note:
rate_limitsis only provided by Claude Code for Claude.ai Pro/Max subscribers, so contributors on API-key auth simply won't see the segment. Reset times render in each user's own local zone.🤖 Generated with Claude Code
This change is