Feature request: expose /usage quota data programmatically
Summary
The /usage dialog in Claude Code shows session and weekly quota usage as percentages:
Current session
█████████████████ 34% used
Resets 11pm (America/Chicago)
Current week (all models)
█████████ 18% used
Resets Mar 20, 12pm (America/Chicago)
This data is not available programmatically. It would be very useful to expose it via CLI or JSON output.
Use case
I want to display remaining usage in the statusline (the statusLine setting in settings.json). The statusline runs a shell script and can show arbitrary text, but there's no way to read the quota percentages that /usage already knows about.
Proposed solution
Any of these would work:
- CLI flag:
claude usage --jsonoutputting something like:
``json``
{
"session": { "used_pct": 34, "resets_at": "2026-03-14T23:00:00-05:00" },
"week": { "used_pct": 18, "resets_at": "2026-03-20T12:00:00-05:00" }
}
- Environment variable injected into statusline/hook commands (e.g.,
$CLAUDE_SESSION_USAGE_PCT,$CLAUDE_WEEKLY_USAGE_PCT)
- Local file written by Claude Code (e.g.,
~/.claude/usage.json) updated after each API call
Current workarounds
- API response headers (
anthropic-ratelimit-*-remaining) show per-minute rate limits, not session/weekly quotas - OpenTelemetry metrics require infrastructure setup and don't map to the same percentages
/costshows session token counts but not quota remaining
None of these provide the data that /usage already displays.
Environment
- Claude Code on Linux (Enterprise plan)
- Using the
statusLinefeature with a custom shell script
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗