Expose usage/quota data via CLI and hooks
Resolved 💬 3 comments Opened Apr 15, 2026 by bwthomas Closed Apr 19, 2026
Summary
There's no way to programmatically access usage quota data (daily/weekly/plan limits and current consumption) from outside the interactive Claude Code session. This makes it impossible to build status lines, hooks, or monitoring that shows usage percentages.
What I tried
- Status line (
statusLinein settings.json) — runs a shell command, but there's no CLI flag or local file with quota data to read - Stop hook with curl — the OAuth token from keychain (
claude-code-oauth) gets blocked by Cloudflare's challenge page onclaude.ai/api/organizations/{org}/usage - Local files —
~/.claude/stats-cache.jsonhas historical token counts but no quota limits or current consumption percentages
What would be useful
Any of these would unblock it:
claude usage --json— CLI command that outputs current quota state as JSON (daily/weekly/plan usage and limits, percentages)- Environment variable — e.g.
$CLAUDE_USAGE_JSONinjected into hook contexts - Local file — Claude Code writes
~/.claude/usage.jsonwith current quota state, updated after each API call - Response headers — If
x-ratelimit-*headers are available, expose them to hooks via stdin JSON
Use case
As a Max plan user, I want an unobtrusive status line showing percentage usage against daily, weekly, and plan caps — updated after each query. This would help me pace usage and avoid surprises. A Stop hook that reads a local file or calls claude usage --json would be ~100ms overhead per query.
Environment
- Claude Code on macOS
- Max plan (claude.ai billing, not Console)
- OAuth authentication via keychain
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗