[FEATURE] Expose /usage and /context data in statusLine JSON
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
## Summary
Add subscription usage quota and context window metrics to the statusLine JSON input.
## Current Behavior
The statusLine script only receives:
cost.total_cost_usd(API cost - not useful for subscription users)- No context window free space percentage
## Requested Data
- Usage/Quota info (like
/usagecommand):
- Messages remaining
- Plan limits
- Reset time
- Context window info (like
/contextcommand):
- Free space percentage
- Tokens used vs available
## Use Case
Subscription users want to monitor their remaining quota at a glance,
and all users benefit from seeing real context utilization.
Proposed Solution
Extend the statusLine JSON input with two new objects:
```json
{
"usage": {
"messages_remaining": 45,
"messages_limit": 50,
"reset_at": "2025-11-28T00:00:00Z",
"plan": "pro"
},
"context": {
"used_tokens": 78000,
"max_tokens": 200000,
"free_percent": 61.0
}
}
This data is already computed internally for /usage and /context commands,
so exposing it to statusLine should require minimal additional logic.
Alternative Solutions
_No response_
Priority
High - Significant impact on productivity
Feature Category
Configuration and settings
Use Case Example
_No response_
Additional Context
_No response_
Showing cached comments. Read the full discussion on GitHub ↗
10 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
I think it's not a duplicate : it create a request for both feature, the should expose more data
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
Additional Context: Why
remaining_percentageDoesn't Match the Red WarningI've done deep research into Claude Code's source (
cli.jsv2.1.7, verified in v2.1.9) and found a critical limitation that affects anyone trying to predict when the context warning/auto-compact will trigger.The Discrepancy
The statusline's
remaining_percentageand the red warning banner use different token calculations:| Display | Tokens Counted | Denominator |
|---------|----------------|-------------|
| Statusline (
remaining_percentage) | INPUT only | 200,000 || Red Warning Banner | INPUT + OUTPUT | ~123,000 (auto-compact limit) |
Source Code Evidence
Statusline calculation (
Tw7) - INPUT only:Warning calculation (
uSA) - INPUT + OUTPUT:Why This Matters
In a code-generation-heavy session:
Result: The red warning appears while statusline still shows 90% remaining. Users are blindsided because output tokens aren't visible.
Current Workaround Limitations
The statusline JSON exposes:
total_output_tokens- session-cumulative (doesn't reset on/compact)remaining_percentage- per-conversation, but INPUT-onlyNeither allows exact replication of the warning calculation.
Proposed Addition
Add per-conversation output tokens to the statusline JSON:
The data already exists internally (via
HKA()→uSA()), it just needs to be exposed.This would allow statusline scripts to accurately predict when
/compactwill be forced, rather than being surprised when the warning appears at "90% remaining."?
Enthusiastically +1'ing this — this is the single biggest gap in the statusLine API right now.
I've built a custom statusLine script that squeezes every bit of available data out of the JSON payload (context window %, session tokens, cumulative tokens, model name, cost). I've pushed the current API to its absolute limit — and hit the wall hard when I tried to add quota visibility.
Why this matters so much
For Max/Pro subscribers, the most critical operational question is: "How many messages do I have left before I hit the rate limit?" — and today there is literally zero way to answer this programmatically. We get a surprise wall mid-task. That's not just inconvenient — it's actively destructive when you're deep in a multi-agent workflow (GSD, agent teams, etc.) where a sudden rate limit can cascade-fail an entire orchestration chain.
What I tried (and why it can't work today)
/usageoutput — Not available outside the REPL; no file, no env var, no hook.statusLinecalls to a file and computing rolling totals. But this gives me approximate self-tracked usage, not actual Anthropic quota data. It drifts, it doesn't know about other sessions, and it can't tell me the reset window.Proposed JSON extension (building on OP's excellent spec)
The
contextobject is actually already partially available (context_window.used_percentageexists in the current JSON), butquotais completely missing. Even a minimal version — justmessages_remainingandreset_at— would be transformative.The community signal is clear
There are 11+ open issues requesting this same data in various forms (#9617, #13585, #15844, #18243, #22428, #22731, #25891, #26108, #26219, and more). This isn't a niche request — it's the most consistently requested statusLine enhancement across the entire issue tracker.
Would love to see this prioritized. The data already exists internally (the
/usagecommand computes it) — exposing it tostatusLinewould unlock an entire ecosystem of custom dashboards, auto-pause scripts, and workflow-aware quota management.I have done some workarounds based on cozempic and claude mem... aparently this is not a good business to Anthopic
https://github.com/cassiodias/rekall-hook/
@min-hinthar re: "zero way to answer this programmatically" -- there's actually a workaround now via the OAuth usage API. I built claude-lens that queries this endpoint in the background and shows 5h/7d remaining percentages plus a pace delta (whether you're burning faster or slower than expected given time remaining in the window). Async refresh with 5min TTL so the statusline never blocks.
~150 lines of Bash + jq, no runtime dependencies. Not a replacement for native support -- would love to see @renchris's proposed
quotaobject in the JSON -- but it works today.I'm trying to do some of the my side project and get myself into the same issue.
The most extreme case — line 118, a 4,807-character gap analysis document:
Why This Happens?
My guts said claude code writes JSONL records in real time as the API streams. The usage object is populated from the API response metadata which arrives before the full output stream completes. By the time the complete text content is flushed into the record's content array, the usage.output_tokens value has already been written — capturing only what had been counted at that early moment. Claude Team should take it more seriously as IT WILL HAVE BIG IMPACT on any feature depends on usage metrics.
Built a partial workaround for the quota side of this while a proper statusLine solution ships.
A local proxy intercepts Claude Code's API traffic and captures the \^Gnthropic-ratelimit-unified-*\ response headers on every inference call, writing a one-line snapshot to \~/.claude/usage-status.md\. Pair it with a \UserPromptSubmit\ hook and the current 5h/7d utilisation gets injected into every prompt automatically — same effect as having it in the statusLine JSON, just via a different route.
https://github.com/InertiaUK/claude-quota-proxy