ClaudeCodeMod

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.

In Claude Code
/plugin marketplace add rbartoli/agent-usage-guard
/plugin install agent-usage-guard@agent-usage-guard
Open the repo

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

The opening of the agent-usage-guard README, with the first scene of the author's recording: the guard asks before a prompt re-writes the expired cache of a 486k-token session, with Compact then send, Send anyway, and Cancel.
Screenshot of the author's GitHub page.

What it hooks into

  • session.startWhen a session starts
  • classic.SessionStartA Claude Code event
  • classic.UserPromptSubmitA Claude Code event
  • classic.PostToolUseA Claude Code event
  • classic.PostCompactA Claude Code event
  • classic.StopA Claude Code event
  • classic.SubagentStartA Claude Code event
  • classic.StopFailureA Claude Code event
  • session.endWhen a session ends
  • session.measureWhen usage is measured
  • turn.stepAt each step of a turn
  • turn.completeWhen a turn ends
  • prompt.submitWhen you send a prompt
  • agent.spawnWhen a subagent starts
  • tool.callAround a tool call, where it can hold one
  • command.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
Repo
rbartoli/agent-usage-guard
Version
1.1.1
License
MIT
Repo stars
58
Last change
2026-10-22
Language
TypeScript
Files
45

Other mods in Usage

optim-jevOqura-aiHas TypeSafe's Jev drop stale tool calls and their output when the session compacts, keeping the rest word for word, and draws a dashboard above the prompt.secondwindorchetronCompresses Bash output of 512 bytes or more through the local secondwind binary, keeps the full text one call away, and draws a pane of the net tokens saved.session-hudbradtraversyDraws a strip above the prompt with the git branch, warned on main, context used against a target you set, and weekly usage, and a Details pane of the rest.time-blamekaranb192Splits each turn's time between Claude, each tool, your approvals, and the rest, under the answer, and /blame opens a panel of the whole session's split.subagent-tunerKruhlikauHolds a commandPicks each subagent's model and effort by asking you in a pane, from a recommendation for the task, or from your saved default, with a band above the prompt.cockpitdrkokorevHolds a commandOpens a panel beside the transcript with context, rate limits, cost, subagents, tool calls, changed files, and tests, and asks before rm -rf or a force push.cache-refresherolddonkeyDraws a bar above the prompt with the time until the prompt cache expires and what a rebuild would cost, and can refresh the cache while you are away.context-alertnathanonnOpens a question dialog when the context window reaches 40 percent, offering to write a handoff doc and then compact, write one only, or compact now.stintdigital-stoic-orgDraws a band above the prompt with context fill, plan headroom, and the stint count, and /pit saves notes, clears, and starts the fresh context from them.orca-movemutlumehmetMoves a session to a twin account as one nears its usage limit: it runs /exit once the prompt box is empty, or shows a toast asking you to clear it.model-relaycablateOpens a panel above the prompt to switch this window to another model provider, routes subagents to providers, and fails over when Claude returns a 429.rtk-gainrtk-aiDraws what RTK saves while Claude works: a band above the prompt, the saving in the spinner, and a /rtk-gain pane where a viking breaks the saved tokens.
All 183 in Usage