All shelves / Mods / Usage
agent-usage-guard
By rbartoli
agent-usage-guard is a Claude Code usage mod by rbartoli.
Asks before a subagent starts, a heavy prompt is sent, or a tool loop runs on, from the 5-hour and weekly usage, and refuses when nobody can answer.
Holds a command
Install
The marketplace name is agent-usage-guard.
/plugin marketplace add rbartoli/agent-usage-guard /plugin install agent-usage-guard@agent-usage-guard
It runs inside the Claude Code process. The side panel is only what the author's README names. Read the repo before you install, or run claude plugin validate on the plugin folder.
- Version
- 1.1.1
- License
- MIT
- Repo stars
- 58
- Last change
- 2026-10-22
What it can reach
- Reads usage or context figures
- Holds a command
- Sees tool calls
Needs Claude Code 2.1.287 or later. Run /reload-plugins after installing, then /agent-guard to see what it sees. It asks in Claude Code's own question dialog, and an approval lifts that condition until it clears or times out. In claude -p, the Agent SDK, and dontAsk mode it refuses instead, and tells Claude why. New agents ask once a plan window is 80 percent full, and are refused at 95 percent, when each session is also told once to finish its step. They also ask when the 5-hour window rises 20 points in 10 minutes, past 4 agents at once or 12 starts in 10 minutes across the machine, or past 10M subagent tokens in 10 minutes. Subagents may not start their own agents. A prompt that would re-read 500k tokens of context asks to compact first, send anyway, or cancel. 20 tool calls in 10 minutes at 400k context ask, and so does a 150k-token session idle long enough for its cache to expire. After three identical failures of the same tool call, the identical retry is refused. Environment variables set every limit, and AGENT_GUARD=0 turns it off. /agent-guard allow, pause, resume, report, and help are the commands, and they never start a model turn. The author says it makes no network requests and starts no processes, and stores counts and coarse buckets, never prompt text, tool inputs, or model output. Journal days older than 90 days are deleted.
The plugin is the repository. The marketplace name is agent-usage-guard. Holding agents, prompts, and tool loops before the spend is why this page files it under usage. usage-budget-erikdarlingdata toasts when the 5-hour or 7-day window crosses a percent, and refuses a new subagent past 95 percent by default. budget-guard keeps a prompt from being sent while the 5-hour or weekly usage is at or over your limit. This one also caps agents across every session on the machine, heavy context, and retry loops, and asks before it refuses. The author's GIF runs a scripted local API in place of Claude, so its sessions and token counts are staged.
Demo

What it hooks into
session.startWhen a session startsclassic.SessionStartA Claude Code eventclassic.UserPromptSubmitA Claude Code eventclassic.PostToolUseA Claude Code eventclassic.PostCompactA Claude Code eventclassic.StopA Claude Code eventclassic.SubagentStartA Claude Code eventclassic.StopFailureA Claude Code eventsession.endWhen a session endssession.measureWhen usage is measuredturn.stepAt each step of a turnturn.completeWhen a turn endsprompt.submitWhen you send a promptagent.spawnWhen a subagent startstool.callAround a tool call, where it can hold onecommand.runWhen you run its slash command
Read from the on() calls in its hook modules. Open its source under Files to check what each one does.
Files
The author's README and source, 4 files. They load when you open them.
Facts
- Author
- rbartoli
- Category
- Usage
- Marketplace
- agent-usage-guard
- Version
- 1.1.1
- License
- MIT
- Repo stars
- 58
- Last change
- 2026-10-22
- Language
- TypeScript
- Files
- 45