check-usage
node .claude/skills/check-usage/check-usage.js
Prints a single JSON object to stdout.
If the PreToolUse usage-limit hook is installed in this project, checking is already automatic (every 10 minutes, after a task has run 30 minutes). Do not poll this on a timer as well -- each check makes a real API call upstream.
Response
| Field | Meaning |
|---|---|
band |
ok, warn, grace, stop, or unknown |
shouldStop |
true only for stop |
degraded |
true when the reading is unavailable OR only partly understood -- unknown, not safe |
reason |
One-line summary including any caveats |
windows |
Every limit window reported, each with utilization (0-1), percent, resetsAt |
highest |
The window closest to its limit -- this drives the verdict |
grace |
When banded grace: which window, when it resets, how long until then |
unreadableWindows |
Windows whose utilization could not be parsed; non-empty means the verdict is partial |
ignoredWindows |
Windows skipped because their status marks them inapplicable |
configIssues |
Threshold/env problems; non-empty means defaults were substituted |
How to act on it
ok-- continue normally.warn(>=80%) -- finish the current step; do not begin a large new one. Consider a checkpoint viasave-progress. Advisory only.grace-- past the stop threshold, but the limiting window resets within 10 minutes. Keep working. Do not halt and do not checkpoint for this. Avoid starting a large step until aftergrace.resetsAt.stop(>=90% with no imminent reset, or >=98% regardless) -- halt. Write up the work so far and a concrete resume plan, save both withsave-progress, then stop and tell the user how to resume.unknown/degraded: true-- keep working. Never treat a missing reading as a reason to stop, and never assume usage is low. Mention it to the user once.
Notes
- Exit code is always 0 when the check ran. A non-zero exit means the script itself broke.
- All limit windows are read generically, so a separate Opus weekly cap is picked up without a code change.
- Thresholds are set as fractions (
0.9, not90) viaUSAGE_LIMIT_STOP_AT,USAGE_LIMIT_WARN_AT,USAGE_LIMIT_HARD_STOP_AT, andUSAGE_LIMIT_RESET_GRACE_MS. An out-of-range value falls back to the default and is reported inconfigIssuesrather than silently disabling the check.