Claude Code Tray 的直線預測顯示 Claude 週限額會在星期五凌晨 4 時耗盡
A straight line says you'll hit your weekly Claude limit at 4 a.m. on a Friday
作者 Alexandre Oliveira 開發 Windows 系統列應用程式 Claude Code Tray,以用量速率預測 Claude Code 週限額耗盡時間,並在預計會超限時把圖示轉紅。
Claude Code on a subscription has two limits: a 5-hour session and a weekly cap. The session one is easy to feel. The weekly one sneaks up on you: no single session tells you where the week is going, and by the time /usage says 90% it's Wednesday and you still have two days of work left.
I wanted the answer without asking for it, so I built a small Windows tray app, Claude Code Tray, that draws the usage as the icon itself and turns it red when the current pace would reach 100% before the window resets.
Drawing a percentage is the easy part. Deciding when to go red is not. Here are four things I learned getting the forecast right.
1. The two windows need different math
For the 5-hour session, the app keeps a short rolling history of readings and fits a least-squares slope through them. It reacts within 5 to 10 minutes, which is what you want from a window that short.
I tried the same slope on the week, and it cried wolf after every heavy afternoon. A burst of work looks like a disaster when you extrapolate it across seven days.
So the week uses a different rule. It compares your usage with the share an even, constant burn would have spent by now, elapsed ÷ 7 days, and only goes red when you're above that line. The projected time to 100% is a rule of three from your average pace since the window started:
time to 100% = elapsed × (100 − used) ÷ used
It needs no history, it's right from the first reading, and a short burst doesn't trip it.
2. A straight line ends your week at a time nothing runs
Even pace is fine for a yes/no warning. As a forecast, it's wrong. Spread the remaining quota evenly over the clock and "you run out here" can land at 3:59 on a Friday morning, when nothing of yours is running.
The Statistics window does something else. It measures when you are usually active, by day of week and hour, from the timestamps in your local Claude Code transcripts. Then it spends the remaining quota along that shape: flat through the stretches you're normally idle (shaded and labelled usually idle), sloped through your working hours. The point where it crosses 100% is the afternoon you'd actually run out.
It's a habit, not a schedule, so the wording hedges: "around 13:45".
3. Thin data should look thin
With a few days of history, an activity profile is mostly noise, and a staircase drawn from noise looks more confident than a straight line. So below about three weeks of history the chart falls back to the straight average-pace line. It gets more specific as it learns, not before.
4. A warning is more useful with a way out
"You'll run out on Thursday" is true and not very helpful. When the shaped projection says you'll run out early, the sentence under the chart names the earliest hour you could stop and resume at and still finish the week under the limit:
Stop now and pick it back up around Jul 30, 13:00, and you'd close the week at about 97%.
Only hours you normally work are offered. If no resume time would actually save the week, it gives no advice rather than a made-up one.
Where the number comes from
The app reads the OAuth token Claude Code already stores on your machine and makes a minimal API call on each poll, only to read the rate-limit headers. Those headers count usage from claude.ai and other machines too, since it's the same limit.
That is a gray area under Anthropic's terms. It isn't the case they prohibit (it runs locally, for your own account), but it isn't "ordinary use of Claude Code" either. The README quotes the terms so you can decide for yourself, and the refresh interval is configurable.
How I built it
With Claude Code, from the first commit in June. I decided what to build, reviewed every change and tested it on my machine. The repo keeps an AGENTS.md and a few project skills so each session starts from the same conventions, and the UI is covered by automated Windows UI tests.
Try it
Windows only for now: the icon is drawn with GDI+ at the exact size the tray asks for.
winget install alegauss.ClaudeCodeTray
Or the per-user installer from the releases, no admin rights. Free and open source (Apache 2.0), no paid tier, unofficial and not affiliated with Anthropic: github.com/alegauss/claude-tray
If you're on a Max plan and watch the weekly limit more than the session, I'd like to know: does the even-pace rule match how your week actually goes?
來源:DEV Community · dev.to

