Expose rate-limit utilization (used_percentage) in headless contexts — stream-json, --output-format json, or a usage subcommand

Open 💬 0 comments Opened Jul 13, 2026 by planBe

Claude Code's statusLine receives rich rate-limit data on stdin (rate_limits.five_hour/seven_day.used_percentage + resets_at — statusline docs, v2.1.207). Headless surfaces get only a subset: stream-json emits rate_limit_event with status/resetsAt/rateLimitType but no utilization percentage, --output-format json results carry cost/tokens but no rate-limit fields, /usage in -p mode prints behavioral attribution without the percentages, and the OTEL metrics are token-based. (All verified empirically on 2.1.207 and against current docs.)

The use case: apps built on the sanctioned headless pattern (claude -p --resume … --output-format stream-json) — per-turn processes on the user's own subscription — want to show the user their own plan utilization so they can pace themselves. Today that number can only be captured by side-effect from an interactive statusLine render; a user working entirely through a headless integration watches their meter go stale while they burn quota. For subscription users, honest self-pacing against the weekly limit is the whole game.

Any one of these would close it:

  1. Include used_percentage alongside resetsAt in the existing stream-json rate_limit_event (smallest change — the event already exists per turn).
  2. Add rate-limit fields to the --output-format json result envelope.
  3. A claude usage --json (or claude rate-limits) subcommand printing the same object the statusLine receives.

Thanks — the stream-json surface has otherwise been a pleasure to build on.

View original on GitHub ↗