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 (statusLine in 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 on claude.ai/api/organizations/{org}/usage
  • Local files~/.claude/stats-cache.json has historical token counts but no quota limits or current consumption percentages

What would be useful

Any of these would unblock it:

  1. claude usage --json — CLI command that outputs current quota state as JSON (daily/weekly/plan usage and limits, percentages)
  2. Environment variable — e.g. $CLAUDE_USAGE_JSON injected into hook contexts
  3. Local file — Claude Code writes ~/.claude/usage.json with current quota state, updated after each API call
  4. 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

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗