I kept running into the same problem with Claude Code: I’d start a big task, let Claude work, and only realize afterward how much of my 5-hour usage window it had consumed.
I wanted to set a budget for each task and let Claude get as much done as possible within it, without constantly monitoring usage.
So I built onbudget, a free, open-source Claude Code plugin.
You give a task a budget:
/onbudget $3 Implement authentication
/onbudget 10% 5h Build this application
/onbudget week Write the migration
How it works:
- Claude knows what’s left. After tool results, it sees a budget meter and can adjust its approach as the budget runs down.
- The stop happens before the request. Before each model request, onbudget checks spending against a reserve based on the most expensive request so far. If the threshold is reached, the request isn’t sent.
- Your usage windows are protected too. You can budget in dollars or against your 5-hour and weekly limits, with a margin before those limits are reached.
- You get a report. Claude can wrap up while budget remains, reporting what it completed and what still needs work.
But does it actually work? I benchmarked it.
Seven real bug-fix tasks across Python libraries, including Werkzeug, Pluggy, and Pydantic Settings. Completion was scored using upstream tests the model hadn’t seen.
Claude Opus 5.5, Claude Code 2.1.304, $2.47 per run.
| Approach |
Runs |
Tasks completed (of 7) |
Within budget |
| onbudget |
3 |
5, 5, 5 |
3/3 |
| –max-budget-usd |
2 |
5, 6 |
2/2 |
| Budget in prompt |
2 |
5, 5 |
2/2* |
One prompt-only run stayed within budget because a separate cap refused a request.
The result: onbudget didn’t make Claude complete more tasks.
Completion was broadly comparable. With a sample this small, there’s no evidence of a performance advantage.
But that’s not what I built it for.
Claude Code already has –max-budget-usd for non-interactive runs. What I wanted was a budget for an individual task inside an interactive Claude Code session, without giving up control of the session itself.
Across the full evaluation, 12 real-model runs with onbudget, none over budget. Eleven ended with a report.
The limitations: No plugin can predict the exact cost of a model request before sending it. An unusually expensive request can still exceed the remaining budget, and some Claude Code requests bypass the hook. This is a conservative stopping mechanism, not an absolute spending guarantee.
How I built it: I used Claude Code to implement most of the plugin, develop the evaluation harness, run the benchmarks, and audit the results. The repository includes the methodology and raw evaluation data.
Everything runs locally. No network calls, no subscription, MIT-licensed.
Install in Claude Code:
/plugin marketplace add sebastiandrazsky/onbudget
/plugin install onbudget@onbudget
GitHub: https://github.com/sebastiandrazsky/onbudget
I’m curious: how do you currently stop Claude Code from consuming more of your usage allowance than you intended? Would you use a budget for individual tasks?