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
The single loudest unserved ask across every voice-of-customer source is a live "how close am I to the wall" view with a forecast: how much of my plan is left, and when will I hit the limit at this pace. Users describe it viscerally ("my lizard brain wants to hoard it"; weekly limits "gone in one or two days"), and the structural reason no one has built it is that no vendor exposes an official quota API for consumer plans. A local tool that already reads the session logs and the live rate-limit surfaces is the only thing that can physically see the signal, and see it across vendors in one place.
CodeBurn is already most of the way there without having named the target:
src/plan-usage.ts models plan periods, per-provider utilization, and a month-end projection (projectMonthEnd, PlanStatus = under | near | over).
src/budget.ts has run-rate projection (projected = spent * totalDays / elapsedDays) and the guard hooks enforce caps in-session.
What's missing is the synthesis: a single quota model per plan, a burn-rate forecast against the plan window (not just the calendar month), pre-flight cost awareness, and one clear surface that answers "am I about to run out." This epic scopes that, decoupled so pieces can land independently.
No scraping of undocumented endpoints beyond the ones the official clients already call with the same auth we already hold.
No hard enforcement of vendor quotas (we cannot block a vendor request); this is visibility and pre-flight nudging. Guard already owns local-cost enforcement.
Proposed scope, decoupled parts
Part 1 — Quota model (src/quota.ts, foundation, no UI)
A provider-agnostic model of a plan's quota state: for each active window (5h, weekly, monthly, credit-based), the limit, the amount used, the reset time, and a pace (used / elapsed-fraction-of-window). Fed by two sources that already exist: derived-from-local-tokens (works offline, all providers) and live-quota-endpoint (Claude/Codex, authoritative when present). Live wins when available; local is the always-on fallback. Pure and testable, mirroring plan-usage.ts. Depends on nothing.
Part 2 — Burn-rate forecast (extends Part 1 + budget.ts math)
Given the window model and recent burn rate, project the exhaustion time: "at this pace you hit your weekly limit Thursday ~3pm" and "projected to end the window at 140%." Reuse the run-rate approach in budget.ts but anchor to the plan window boundaries from Part 1, not the calendar month. Honest about confidence with sparse data (same discipline as the outlier/young-project work). Depends on Part 1.
A first-class quota statusline (research flagged this as a parity gap with ccusage's ecosystem) showing remaining + forecast, distinct from guard --statusline which is cost caps.
codeburn plan / a codeburn quota view surfacing the same model in the TUI and --json. Depends on Parts 1 and 2. UI-only; each surface can land separately.
Part 4 — Pre-flight cost awareness (optional, opt-in)
Before an expensive turn, an ambient signal of what it will cost against the remaining window ("~40 credits, 3% of your month"). Delivered through the existing MCP server or a hook, never a blocking gate. Depends on Part 1; can follow the surfaces.
Part 5 — Invoice reconciliation (trust, separable)
An opt-in mode that reconciles CodeBurn's parsed spend against official billed spend where an API exists (Anthropic cost API, OpenRouter key endpoint, Claude Code OTEL) and flags drift. Directly answers "are these numbers even right." Strictly opt-in and network-gated, off by default, honoring the local-first promise. Independent of the rest; grouped here because it is the trust half of quota confidence.
Dependency order
Part 1 first. Parts 2 and 5 in parallel after (5 is fully independent and can start anytime). Part 3 after Part 2. Part 4 last. Each part is its own PR; UI surfaces in Part 3 are independently shippable.
Before Part 2's forecast ships to users, it must be validated against real historical windows: replay a month of local sessions, compute the forecast at each day, and check it against what actually happened at the window boundary. A forecast that is confidently wrong is worse than none, so the same reproduce-and-measure bar the acting layer used applies here.
Motivation
The single loudest unserved ask across every voice-of-customer source is a live "how close am I to the wall" view with a forecast: how much of my plan is left, and when will I hit the limit at this pace. Users describe it viscerally ("my lizard brain wants to hoard it"; weekly limits "gone in one or two days"), and the structural reason no one has built it is that no vendor exposes an official quota API for consumer plans. A local tool that already reads the session logs and the live rate-limit surfaces is the only thing that can physically see the signal, and see it across vendors in one place.
CodeBurn is already most of the way there without having named the target:
src/plan-usage.tsmodels plan periods, per-provider utilization, and a month-end projection (projectMonthEnd,PlanStatus = under | near | over).src/budget.tshas run-rate projection (projected = spent * totalDays / elapsedDays) and the guard hooks enforce caps in-session.ClaudeSubscriptionService(api/oauth/usage) andCodexSubscriptionService(wham/usage), with menubar: honor Retry-After on Claude quota 429s, back off failed refreshes #702 handling 429s and menubar: surface Codex limit-reset credits (count and next expiry) in the Plan tab #724 surfacing Codex limit-reset credits.What's missing is the synthesis: a single quota model per plan, a burn-rate forecast against the plan window (not just the calendar month), pre-flight cost awareness, and one clear surface that answers "am I about to run out." This epic scopes that, decoupled so pieces can land independently.
Non-goals (this epic)
Proposed scope, decoupled parts
Part 1 — Quota model (
src/quota.ts, foundation, no UI)A provider-agnostic model of a plan's quota state: for each active window (5h, weekly, monthly, credit-based), the limit, the amount used, the reset time, and a
pace(used / elapsed-fraction-of-window). Fed by two sources that already exist: derived-from-local-tokens (works offline, all providers) and live-quota-endpoint (Claude/Codex, authoritative when present). Live wins when available; local is the always-on fallback. Pure and testable, mirroringplan-usage.ts. Depends on nothing.Part 2 — Burn-rate forecast (extends Part 1 +
budget.tsmath)Given the window model and recent burn rate, project the exhaustion time: "at this pace you hit your weekly limit Thursday ~3pm" and "projected to end the window at 140%." Reuse the run-rate approach in
budget.tsbut anchor to the plan window boundaries from Part 1, not the calendar month. Honest about confidence with sparse data (same discipline as the outlier/young-project work). Depends on Part 1.Part 3 — Surfaces (menubar + statusline + CLI + web)
guard --statuslinewhich is cost caps.codeburn plan/ acodeburn quotaview surfacing the same model in the TUI and--json.Depends on Parts 1 and 2. UI-only; each surface can land separately.
Part 4 — Pre-flight cost awareness (optional, opt-in)
Before an expensive turn, an ambient signal of what it will cost against the remaining window ("~40 credits, 3% of your month"). Delivered through the existing MCP server or a hook, never a blocking gate. Depends on Part 1; can follow the surfaces.
Part 5 — Invoice reconciliation (trust, separable)
An opt-in mode that reconciles CodeBurn's parsed spend against official billed spend where an API exists (Anthropic cost API, OpenRouter key endpoint, Claude Code OTEL) and flags drift. Directly answers "are these numbers even right." Strictly opt-in and network-gated, off by default, honoring the local-first promise. Independent of the rest; grouped here because it is the trust half of quota confidence.
Dependency order
Part 1 first. Parts 2 and 5 in parallel after (5 is fully independent and can start anytime). Part 3 after Part 2. Part 4 last. Each part is its own PR; UI surfaces in Part 3 are independently shippable.
Evidence gate (per the epic-#602 discipline)
Before Part 2's forecast ships to users, it must be validated against real historical windows: replay a month of local sessions, compute the forecast at each day, and check it against what actually happened at the window boundary. A forecast that is confidently wrong is worse than none, so the same reproduce-and-measure bar the acting layer used applies here.
Already shipped toward this
Contributions welcome on any decoupled part. Comment to claim one; design discussion on the model shape (Part 1) is the most useful place to start.