Claude Code has two rate limits that can stop your work cold, with no warning. Both come from Anthropic's API infrastructure — not from your machine, not from the app. Here's exactly how they work.
| Limit | Window | What it counts | When it resets |
|---|---|---|---|
| Session cap | 5 hours | Total tokens in any rolling 5-hour window | Rolling — oldest tokens fall off continuously |
| Weekly cap | 7 days | Total tokens across all sessions in a rolling 7-day window | Rolling — oldest sessions fall off continuously |
Both are rolling windows, not reset-at-midnight counters. If you hit the session cap at 3pm, you can't just wait until midnight — you have to wait until the tokens from 5 hours ago fall off. The exact reset time depends on when you started the heavy usage.
Claude Code stops mid-task with a rate limit error. There's no soft warning, no "you're getting close" message. You find out when it's already too late to save the current task context.
The error message looks like:
Claude API rate limit exceeded. Please try again in N minutes.
At that point your options are:
Claude Code has a built-in /usage command that shows both meters:
/usage
# Session (5h): 23% — resets in ~3h 52m
# Weekly (7d): 67% — resets in ~2d 14h
But /usage is reactive — you have to remember to run it. If you're deep in a task and close to the limit, you'll likely forget.
/usage command. Claude Code receives them with every API response and renders them in its terminal status line. They're the authoritative numbers, not estimates.
Not all Claude Code usage is equal. These patterns consume tokens much faster than conversational use:
A session that would normally last all day can hit the 5-hour cap in 2-3 hours if you're doing heavy agentic work on a large codebase.
Headroom puts both meters in the macOS menu bar as a color-coded live percentage:
CC 23%·67% ← always visible, no click needed
Color logic:
The dropdown shows exact percentages, reset countdowns (e.g., "resets in 2h 14m"), your active model, session cost, and context window fill. You see it change as you work — so the limit stops being a surprise.
Headroom uses Claude Code's own statusLineHook mechanism. Claude Code writes a JSON file to ~/.claude/headroom-usage.json every time it updates — the same data source as /usage. Headroom reads that file. No API calls, no credentials needed.
cat ~/.claude/headroom-usage.json
# {"sessionUsagePct":23.1,"weeklyUsagePct":67.4,"contextUsagePct":41.0,...}
If you want to use this data in your own tooling — a shell prompt that shows session usage, a script that alerts at 80% — the JSON file is right there. See the hook docs for the full schema and recipes.
brew install --cask patwalls/tap/headroom