feat: track cost and enforce budget after mid-session subscription→API billing transition

Open 💬 1 comment Opened Jun 23, 2026 by Josef-Le

Problem

When a Claude Code session starts on a Claude Max subscription, /cost shows:

"You are currently using your subscription to power your Claude Code usage"

Claude Code does print a warning at the transition point when subscription quota is exhausted and billing switches to API (pay-per-token). However, two gaps remain after that warning:

Gap 1 — /cost doesn't track the API-billed portion

Once billing transitions mid-session, /cost continues to show subscription-mode output only. It does not accumulate a dollar figure for the API-billed tokens incurred after the transition. The only way to see those charges is to start a new session (pure-API sessions show full cost breakdowns).

Gap 2 — No budget ceiling for the API portion

There is no way to set a per-session spending cap that would stop (or warn again) when API charges within a single session exceed a threshold.

Reproduction

  1. Start a Claude Code session with a Claude Max subscription + API key configured
  2. Run a large agentic task that exhausts subscription quota mid-session
  3. Observe the transition warning printed by Claude Code ✅
  4. Run /cost — it does not show accumulated dollar amount for the API-billed portion ❌
  5. Continue the session; there is no secondary warning or hard stop if API charges grow ❌

Requested behavior

/cost live tracking after transition

Once billing mode transitions within a session, /cost should show the dollar amount accrued from the API-billed portion — the same breakdown that appears in a pure-API session.

Optional: budget ceiling

Support --session-budget <$N> flag or CLAUDE_SESSION_BUDGET=<N> env var to abort the session (with a clear message) if API charges within the session exceed the threshold.

Related

  • #38369 — /cost shows no token breakdown for subscription (related observability gap)
  • #45756 — cache tokens counting toward quota (related quota confusion)

Neither covers the specific issue of /cost not tracking the API-billed portion after the mid-session billing mode transition.

Environment

  • Claude Code: latest (2.x)
  • Platform: macOS (arm64)
  • Auth: Claude Max subscription + API key configured

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗