An agent that runs on its own stops when the task is done, not when your budget is. That’s fine for a quick question, but it’s a different story for a refactoring job in CI or a scheduled run overnight. So, the question becomes: how do you put a ceiling on a Claude Code session? Remark: Strictly speaking you can’t set a token limit. Claude Code caps on spend (tokens × price), so that’s what we’ll use. The naive approach Just run it and see what happens: claude -p "Run the test suite, fix the failing tests in src/ and commit the fix" There is no limit by default. Claude keeps going until it thinks it’s finished, and you find out the cost afterwards. Two flags can help Claude Code has two flags that act as a safety net in print mode ( -p ): claude -p "Run the test suite, fix the failing tests in src/ and commit the fix" \ --max-budget-usd 3.00 \ --max-turns 30 --max-budget-usd stops the run once the estimated spend on API calls reaches the...
Planning and implementing are not the same kind of work. Planning needs a strong reasoning model that explores the codebase and weighs options. Implementing a clear, approved plan is mostly mechanical, and a cheaper, faster model can handle that. Picking one model for everything is not a good idea. You either overpay for the build, or you underpay for the plan. A colleague recently pointed out that JetBrains AI can split this, and it turns out Copilot can do something similar. Let’s look at both. Plan and build in VS Code The Plan agent in VS Code has its own model setting. Two settings matter: { "chat.planAgent.defaultModel": "<planning model>", "github.copilot.chat.implementAgent.model": "<implementation model>" } chat.planAgent.defaultModel is the model used by the Plan agent. github.copilot.chat.implementAgent.model is the model used when you click Start Implementation . Prefer to do it by hand in a Copil...