If you're on a Pro or Max plan, the most annoying moment in Claude Code is the one where it stops mid-task because you hit the 5-hour limit. I wanted to see that coming: a small "82 %" somewhere, before it happens, not after.
The obvious place to look is hooks. VibeDesk already listens to every Claude Code hook event. But the limits aren't in there: no hook payload carries them.
They're in the statusline input.
Where the numbers are
Claude Code runs your statusLine command and pipes a JSON object into it on stdin. On Pro and Max plans that JSON has a rate_limits field:
{
"rate_limits": {
"five_hour": { "used_percentage": 82.4, "resets_at": 1796320800 },
"seven_day": { "used_percentage": 30, "resets_at": 1796745600 }
}
}
-
used_percentageis 0 to 100. -
resets_atis a Unix timestamp in seconds, not milliseconds. Pass it straight tonew Date()and you land in January 1970.
It's documented in the statusline docs, which is easy to miss if you only ever read the hooks reference.
A statusline that shows them
Save this as ~/.claude/limits-statusline.js:
// limits-statusline.js - show your Claude Code plan limits in the statusline
'use strict'
let input = ''
process.stdin.setEncoding('utf8')
process.stdin.on('data', (c) => (input += c))
process.stdin.on('end', () => {
try {
const r = JSON.parse(input).rate_limits || {}
const part = (label, w) => {
if (!w || typeof w.used_percentage !== 'number' || !w.resets_at) return null
const at = new Date(w.resets_at * 1000) // resets_at is in seconds
if (at <= new Date()) return null // window already over
let time = at.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
if (at - Date.now() > 24 * 3600 * 1000) time = at.toLocaleDateString([], { weekday: 'short' }) + ' ' + time
return `${label} ${Math.round(w.used_percentage)}% (resets ${time})`
}
const parts = [part('5h', r.five_hour), part('week', r.seven_day)].filter(Boolean)
process.stdout.write(parts.length ? parts.join(' ยท ') : '')
} catch {
// never break the statusline: print nothing
}
process.exit(0)
})
And point your settings at it:
{
"statusLine": {
"type": "command",
"command": "node ~/.claude/limits-statusline.js"
}
}
You get something like 5h 82% (resets 22:10) ยท week 30% (resets Sun 08:00) under the prompt.
On Windows, write the full path (node C:/Users/you/.claude/limits-statusline.js). Depending on which shell runs the command, ~ isn't expanded.
Four things that surprised me
1. It's empty at the start. The field only shows up after the first response in a session. A fresh session has no rate_limits yet, so the script has to be fine with printing nothing.
2. Windows can be missing. Sometimes only one of the two is there. And with an API key instead of a subscription there are no limits at all. Treat every field as optional.
3. An old window is still an old window. If you cache the last value (I do, to show it in the app between turns), check resets_at before you show it. A "95 %" from a window that ended an hour ago is worse than nothing.
4. If you set statusLine from a tool, you replace the user's own. VibeDesk starts each session with its own --settings file, and the statusLine in there overrides the one in the user's ~/.claude/settings.json. Done naively, that silently takes away the statusline of everyone who had one. So the app looks up the user's command first (project .claude/settings.local.json, then .claude/settings.json, then the user settings), runs it with the same JSON, and passes its output through.
Warn once, not every turn
The statusline runs often. If you turn the numbers into notifications, keep track of what you already said. I key each warning by window, reset time and level:
const id = `${key}|${resetsAt}|${level}` // e.g. "fiveHour|1796320800|hot"
if (seen.has(id)) return
seen.add(id)
So you get one note at 75 %, one at 90 %, and one "free again" after a window you were warned about has reset. A new window gets a new resets_at, so the next warning works without any cleanup.
What this doesn't cover
- I only see what Claude Code chooses to send. Whatever "used_percentage" is based on is up to Anthropic, and I can't check it.
- The exact moments the statusline runs aren't something I'd build timing on. I only use it as "the latest known value".
- This is Pro and Max only. On the API you'd look at token counts and cost instead.
Question
How do you deal with the 5-hour limit?
(This is how the limit chip in VibeDesk works, a free Windows desktop for Claude Code. When a session does hit the limit, it picks up again by itself after the reset.)
Top comments (1)
A run of up to 40 subagents hit the usage limit overnight, and everything paused from about 04:20 to 08:20. 30 of them were stopped, and after the reset each carried on from its own transcript with nothing lost. The agent list was off for a while: a few showed idle, but their files had changed within minutes, so they were still working. Afterwards I capped that job at 2 live agents, though that was for the load on my machine.