You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature Request: Expose subscription usage data via local file or API #21943
Provide a way for users and tools to programmatically access Claude Code Pro/Max subscription usage data (session and weekly quota percentages, reset times).
Problem
Currently, the only way to check subscription usage is via the /usage command, which:
Displays data in the terminal but doesn't expose it programmatically
Fetches from Anthropic's servers but doesn't cache locally
Cannot be invoked by external tools or scripts
This makes it impossible to build companion tools that help users:
Monitor usage in real-time
Get alerts before hitting limits
Track usage patterns over time
Plan sessions efficiently
Proposed Solution
One or more of the following:
Option A: Local cache file
Write usage data to a local file (e.g., ~/.claude/usage-cache.json) after each /usage call or periodically:
Alerts - Get notified before hitting session/weekly limits
Planning - Tools that help distribute usage across the week
Automation - Scripts that pause work when approaching limits
Current Workaround
Users must manually read /usage output and input numbers into external tools - this is error-prone and tedious.
Additional Context
The API already returns rate limit headers (anthropic-ratelimit-*) for per-minute limits. Extending this pattern to subscription quotas would be consistent and helpful.
Related: The existing stats-cache.json already tracks token usage but lacks quota context.
I maintain CodexBar, a macOS menu bar app that displays Claude Code usage. Currently, we face a significant UX problem that this feature would solve.
The Problem
On macOS, Claude Code stores OAuth credentials in the Keychain. Third-party apps like CodexBar need these credentials to fetch usage data from the API. However:
Keychain ACL resets on token refresh - When Claude CLI updates the token, the Access Control List is reset, revoking CodexBar's access
Users see repeated keychain prompts - Multiple times per day, users must enter their login password to allow CodexBar to access the credential
There's no workaround - On macOS, Claude Code doesn't write credentials to ~/.claude/.credentials.json (only Linux does)
See related issue #19456 which documents the keychain ACL problem.
Why Usage Cache Solves This
If Claude Code wrote usage data to a cache file:
Third-party tools would not need credential access at all
No keychain prompts ever
Claude Code (which owns the keychain item) fetches data and writes to cache
Third-party tools simply read the cache file
This is the cleanest architectural solution because:
No credential sharing between apps
No security concerns about token exposure
Follows the principle of least privilege
Benefits the entire ecosystem of third-party tools
+1 — this shouldn't have been marked as a duplicate. The core ask (expose subscription usage programmatically) is distinct from generic "analytics" requests. The data is already fetched for /usage — caching it locally or piping it into the statusline hook would be a small implementation with huge user impact. 8+ open issues requesting the same thing speaks for itself.
Reacted by Pablo Stafforini, Nikita Boguslavskii, Max and ntlimited
+1 — closed my duplicate #33215 in favor of this one.
Adding two desktop app / Cowork-specific angles not yet covered here:
1. Always-visible usage indicator in the menu bar icon
The Claude menu bar icon could visually represent usage as a fill level (like the macOS battery icon) — empty at 0%, full at 100%, with color shift (green → yellow → red). Tooltip on hover: "Session: 72% | Weekly: 45%". This gives at-a-glance awareness without opening the app.
2. MCP tool access for Cowork mode
In Cowork mode, Claude runs with MCP tools (Desktop Commander, Chrome, Gmail, GCal, scheduled tasks). Claude itself has zero visibility into its own token consumption or quota. Exposing usage via an internal MCP tool or query would let Claude:
Defer heavy tasks when quota is low ("You're at 85% — defer to next session?")
Skip scheduled tasks that would exceed remaining quota
Plan multi-step workflows against remaining capacity
This creates a local JSONL log at ~/.claude/usage.jsonl that you can query with jq, grep, or any script. Session summaries are saved to ~/.claude/usage-reports/. Not actual subscription usage, but gives you complete visibility into tool-level activity.
this is the gap between local-log tooling and server-truth quota, and it's been bugging me for months. ccusage and the monitor projects parse ~/.claude/projects/*.jsonl, which gives you token counts but not the rolling 5h or weekly window Anthropic actually enforces. /usage hits an internal endpoint (the same one claude.ai/settings/usage renders) and that's the only number that matches what gets you rate-limited. option B (--json) is the cleanest fix because the data already exists server-side, the CLI just needs to stop pretty-printing and start emitting structured output. without it everyone ends up scraping the terminal.
Here's yet another workaround to this https://github.com/hiinaspace/claude-quota . it runs an empty claude code session in screen, types in /usage, scrolls down and parses the bars into JSON on stdout. takes a bit to run since claude code startup is slow (~5 seconds) and is fragile to changes, but works in a pinch.
QuotaTempo maintainer here. This also affects users who are signed in to Claude Desktop and actively use its Code tab, but are not signed in to the standalone Claude Code CLI. Desktop local usage history provides a recent weekly utilization sample, yet no exact next reset timestamp. A previously cached CLI reset can be joined only until that known window expires; after rollover, a companion app cannot safely derive the next exact reset from Desktop history alone.
A supported, user-consented, read-only interface returning weekly and five-hour utilization, exact reset timestamps, observation time, and a non-secret account identity would solve this without scraping the TUI or reusing browser cookies/shared OAuth credentials. It should work for Desktop-only sessions and after a weekly rollover. Related investigation: Ishikawa-Hidekazu/quota-tempo#23
I'm building Quotzii, a native macOS menu bar app that helps Claude Code users monitor their session and weekly usage limits at a glance.
Currently, Quotzii relies on usage information exposed by Claude Code. This works well for my use case, but I'd prefer not to depend on undocumented or potentially unstable behavior.
Would Anthropic consider providing a documented, machine-readable interface for retrieving subscription usage limits and reset times?
This would make it much easier for developers to build reliable integrations and usage-monitoring tools for Claude Code users.
Activity
github-actions commentedon Jan 30, 2026
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
NSEvent commentedon Jan 31, 2026
Strong +1 for this feature request.
I maintain CodexBar, a macOS menu bar app that displays Claude Code usage. Currently, we face a significant UX problem that this feature would solve.
The Problem
On macOS, Claude Code stores OAuth credentials in the Keychain. Third-party apps like CodexBar need these credentials to fetch usage data from the API. However:
~/.claude/.credentials.json(only Linux does)See related issue #19456 which documents the keychain ACL problem.
Why Usage Cache Solves This
If Claude Code wrote usage data to a cache file:
This is the cleanest architectural solution because:
Proposed Cache Location
Minimal Viable Schema
{ "session": { "percentUsed": 42.5, "resetsAt": "2026-01-31T15:00:00Z" }, "weekly": { "percentUsed": 28.0, "resetsAt": "2026-02-05T00:00:00Z" }, "updatedAt": "2026-01-31T10:30:00Z" }Implementation Suggestion
Write/update the cache file whenever:
/usagecommandEven just option 1 would be valuable - users could run
/usageoccasionally and third-party tools would read the cached data.Affected Third-Party Tools
Would love to see this prioritized given the current keychain UX issues on macOS.
BareTread commentedon Feb 17, 2026
+1 — this shouldn't have been marked as a duplicate. The core ask (expose subscription usage programmatically) is distinct from generic "analytics" requests. The data is already fetched for
/usage— caching it locally or piping it into the statusline hook would be a small implementation with huge user impact. 8+ open issues requesting the same thing speaks for itself.seredniy commentedon Feb 18, 2026
+1 for this one. Or add ability to fetch that data via API
arjunsharma commentedon Feb 27, 2026
+1 - would also love to see this available to the data provided to the statusline tool - would love to track my session usage in my status line.
Add workflow to track anthropics/claude-code#21943
slopware commentedon Mar 5, 2026
this script works as a status line which includes quota data: https://github.com/slopware/claude-quota
BareTread commentedon Mar 6, 2026
thanks - I actually stole that logic and am using it right now - this will do for now until anthropic implements an official solution.
henrikblunck commentedon Mar 11, 2026
+1 — closed my duplicate #33215 in favor of this one.
Adding two desktop app / Cowork-specific angles not yet covered here:
1. Always-visible usage indicator in the menu bar icon
The Claude menu bar icon could visually represent usage as a fill level (like the macOS battery icon) — empty at 0%, full at 100%, with color shift (green → yellow → red). Tooltip on hover: "Session: 72% | Weekly: 45%". This gives at-a-glance awareness without opening the app.
2. MCP tool access for Cowork mode
In Cowork mode, Claude runs with MCP tools (Desktop Commander, Chrome, Gmail, GCal, scheduled tasks). Claude itself has zero visibility into its own token consumption or quota. Exposing usage via an internal MCP tool or query would let Claude:
yurukusa commentedon Mar 29, 2026
Until native usage data is exposed, a PostToolUse hook can track session-level usage and write it to a local file:
{ "hooks": { "PostToolUse": [{"hooks": [{"type": "command", "command": "bash ~/.claude/hooks/usage-tracker.sh"}]}], "Stop": [{"hooks": [{"type": "command", "command": "bash ~/.claude/hooks/usage-summary.sh"}]}] } }This creates a local JSONL log at
~/.claude/usage.jsonlthat you can query withjq,grep, or any script. Session summaries are saved to~/.claude/usage-reports/. Not actual subscription usage, but gives you complete visibility into tool-level activity.m13v commentedon Apr 28, 2026
this is the gap between local-log tooling and server-truth quota, and it's been bugging me for months. ccusage and the monitor projects parse ~/.claude/projects/*.jsonl, which gives you token counts but not the rolling 5h or weekly window Anthropic actually enforces. /usage hits an internal endpoint (the same one claude.ai/settings/usage renders) and that's the only number that matches what gets you rate-limited. option B (--json) is the cleanest fix because the data already exists server-side, the CLI just needs to stop pretty-printing and start emitting structured output. without it everyone ends up scraping the terminal.
hiinaspace commentedon Jul 3, 2026
Here's yet another workaround to this https://github.com/hiinaspace/claude-quota . it runs an empty claude code session in screen, types in
/usage, scrolls down and parses the bars into JSON on stdout. takes a bit to run since claude code startup is slow (~5 seconds) and is fragile to changes, but works in a pinch.CommanderTvis commentedon Sep 12, 2026
Just write
claude "/usage" -pand parse by your tool.ishikawa-h commentedon Sep 27, 2026
QuotaTempo maintainer here. This also affects users who are signed in to Claude Desktop and actively use its Code tab, but are not signed in to the standalone Claude Code CLI. Desktop local usage history provides a recent weekly utilization sample, yet no exact next reset timestamp. A previously cached CLI reset can be joined only until that known window expires; after rollover, a companion app cannot safely derive the next exact reset from Desktop history alone.
A supported, user-consented, read-only interface returning weekly and five-hour utilization, exact reset timestamps, observation time, and a non-secret account identity would solve this without scraping the TUI or reusing browser cookies/shared OAuth credentials. It should work for Desktop-only sessions and after a weekly rollover. Related investigation: Ishikawa-Hidekazu/quota-tempo#23
gerritvisserNL commentedon Oct 10, 2026
I'm building Quotzii, a native macOS menu bar app that helps Claude Code users monitor their session and weekly usage limits at a glance.
Currently, Quotzii relies on usage information exposed by Claude Code. This works well for my use case, but I'd prefer not to depend on undocumented or potentially unstable behavior.
Would Anthropic consider providing a documented, machine-readable interface for retrieving subscription usage limits and reset times?
This would make it much easier for developers to build reliable integrations and usage-monitoring tools for Claude Code users.
Thanks for considering this!