Skip to content

feat(claude): expose saved usage-limit resets in CLI JSON #3895

Description

@materemias

Request

Expose Claude Code's saved usage-limit reset grants in codexbar usage --provider claude --source oauth --json, analogous to the existing Codex usage.codexResetCredits output. This would let CLI consumers display the remaining resets and earliest expiration without making a second authenticated request.

Data source and observed response

Claude Code 2.1.280 requests GET https://api.anthropic.com/api/oauth/usage?cedar_ember=1&skip_spend=1 with its OAuth bearer token, anthropic-beta: oauth-2025-04-20, and a Claude Code CLI User-Agent. The regular /api/oauth/usage response had cedar_ember: null for the account tested. The opt-in query returned a cedar_ember object. Requests with a generic/claude-code/<version> User-Agent returned eligible: false, ineligible_reason: "surface", and no grants; claude-cli/2.1.280 (external, cli) returned an eligible grant. Please check the appropriate supported client identity rather than assuming the normal usage fetch is enough.

Relevant fields, with account-specific values omitted:

{
  "cedar_ember": {
    "eligible": true,
    "grants": [
      {
        "id": "<grant id>",
        "label": "<description>",
        "resets_total": 1,
        "resets_left": 1,
        "starts_at": "<ISO timestamp>",
        "ends_at": "<ISO timestamp>",
        "clears": ["five_hour", "seven_day"],
        "paused": false,
        "usable_now": true,
        "use_requires_limit": false
      }
    ],
    "next_grant_id": "<grant id>"
  }
}

The grant count is resets_left (not simply the number of grants); ignore paused, not-yet-started, expired, and exhausted grants for an available count. usable_now/use_requires_limit describe whether redemption is currently allowed and should not be conflated with saved credits remaining. Expose expiry and the applicable clears windows where possible. Absent/ineligible grants should not be reported as available. This is a read-only request; no redemption action is needed.

Current gap

In CodexBar CLI 0.64.1, Claude OAuth JSON contains usage windows but no saved-reset grants, while Codex already includes codexResetCredits. The upstream OAuth response decoder currently omits cedar_ember: Sources/CodexBarCore/Providers/Claude/ClaudeOAuth/ClaudeOAuthUsageFetcher.swift. A KDE CLI consumer currently has to make this extra request itself to show Claude's saved resets. Reusing the existing OAuth credential and rate-limit handling in CodexBar would avoid duplicating authentication and HTTP behavior in each client.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal priority bug or improvement with limited blast radius.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🌊 off-meta tidepoolIssue quality rating does not apply to this item.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions