Loading page content
Predicts the runaway-loop bill before it lands. Plug in your worst-case agent loop assumptions. The calc rolls forward, multiplies tokens by iterations, applies your caching hit-rate, and tells you when you blow the budget.
A per-task budget hook at 1,838,000 tokens covers this scenario with a 25% margin. Drop this into .claude/settings.json:
{
"hooks": {
"PreToolUse": [
{
"matcher": ".*",
"hooks": [
{ "type": "command", "command": ".claude/hooks/budget-guard.sh 1838000" }
]
}
]
}
}