Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
By indahl-aiv1.0.0MITIn 1 marketplace
Refuse an agent's tool calls once its session has used the budget you set, in raw tokens or in dollars at your own prices. Counts the session and its subagents, warns once near the limit, and enforces the stricter of your project and home budgets. A refusal, not a kill switch.
Run automatically on Claude Code events. Claude doesn't decide.
1 critical · 2 cautions to review before installing
A hook runs before every tool call and can block or approve it
A hook runs when Claude uses the Bash tool
A hook runs when Claude writes or edits files
Static checks of hooks, mods, MCP servers and commands. Not a security audit.
1 marketplace, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
indahl-spend-cap
Agents run up cost quietly: a loop that retries, a subagent fan-out, a long unattended run. This Claude Code plugin adds a hook that runs before every tool call. It reads the session's own transcript and its subagents' transcripts, adds up the tokens recorded there, and refuses the tool call once the session is over the budget you set. The agent is told why and asked to stop and report what is done.
What it does and does not do. It refuses tool calls. It does not stop the session. It checks before each tool call, so the call already in flight (a long build, a subagent), any refused retries and the final report all run past the cap. It guards against a runaway loop, not against an agent that edits the budget file to keep going.
.claude/spend-cap.json or ~/.claude/spend-cap.json, with the stricter file winning.report command that prints the totals for one session.Create a budget file, then work as usual:
{ "max_tokens": 5000000, "warn_at": 0.8 }
Save it as .claude/spend-cap.json in the project. With no budget file, the hook does nothing.
Put a file at .claude/spend-cap.json in the project, at ~/.claude/spend-cap.json for every project, or both. When both exist, both are enforced, so the stricter one wins and a project's file can never loosen your own cap.
{ "max_tokens": 5000000, "warn_at": 0.8 }
max_tokens counts raw tokens: input, output, cache writes and cache reads, unweighted. Cache reads often dominate. In one long session we measured 1.28 billion raw tokens, of which almost all were cache reads. To count cache reads at a lower weight, set it yourself:
{ "max_tokens": 200000000, "cache_read_weight": 0.1 }
Cache reads bill at about a tenth of input on Anthropic's list today. Check your own provider. For a cost cap, give your own prices per million tokens. None are built in, because prices change:
{ "max_usd": 20, "prices_per_mtok": { "input": 5, "output": 25, "cache_write": 6.25, "cache_read": 0.5 } }
One price set applies to every model in the session, so a cheaper subagent model is counted at the same prices.
A budget file that cannot be read, or one with a limit missing the numbers it needs, refuses tool calls until it is fixed or deleted. A person who wrote a cap believes it is on. With no budget file at all, the hook does nothing.
warn_at share is first passed (80 percent by default), one warning goes to you and to the agent, with all four token classes. Seen live on 14 Nov 2026 (Claude Code 2.1.325): the agent quoted the warning back word for word.python3 scripts/spend_cap.py report <transcript.jsonl> prints the totals for one session.python3 scripts/spend_cap.py selftest runs 21 planted cases.INDAHL_SPEND_CAP_LOG=/path/to/file to log, for each tool call, what the hook was handed and what it decided.Built from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.
npx claudepluginhub indahl-ai/claude-plugins --plugin indahl-spend-capPlugins from other owners that cover similar ground