Claude Code hook

Agent Usage Guard

Hook mod that pauses subagent fan-out, heavy prompts and retry loops before they burn quota.

93 stars 5 forksHooks Plugin marketplace Source

Install

Inside Claude Code
/plugin marketplace add rbartoli/agent-usage-guard
From source
git clone https://github.com/rbartoli/agent-usage-guard.git

From the README

agent-usage-guard
Stops Claude Code from spending your five-hour usage window in ten minutes.

agent-usage-guard is a Claude Code mod: it runs inside Claude Code and holds runaway spend before it happens. It reads your plan's live usage, and it holds subagent fan-out, heavy-context churn and retry loops.

  Recorded from Claude Code's interactive UI with the guard loaded. A scripted local API stands in for Claude, so the sessions and token counts are staged and no usage is spent. Every question on screen is the guard's own. Rebuild it from the Northstar fixture.

It acts before the spend, not after it: before an agent starts, a prompt is sent, or a tool call runs. Agent limits hold across every Claude Code session on your machine, and fan-out and heavy context are capped at any usage level, not only near the limit. When you are at the keyboard it asks you, in Claude Code's own question dialog. When nobody can answer, it refuses and tells Claude why, so the model can wait, batch the work, or stop. /agent-guard report shows what it did.

- Plan-aware. It reads the 5-hour and weekly percentages Claude Code reports, and keeps the end of the window for you.
- One answer covers a while. An approval lifts its condition until it clears or times out, so the same question does not come back call after call.
- Local and privacy-minimal. No network, no processes. It stores counts and coarse buckets, never prompt text, tool inputs or model output.
- Fails open. If one of its hooks fails, the event goes ahead: a broken guard never breaks your session. The one exception is an agent it could not judge, which is refused so that Claude starts it again.

Install

Run these commands inside Claude Code v2.1.287 or later:

Then run /agent-guard to see what it sees. Mods are on by default;…
Read the full README on GitHub

How hooks work

  • Hooks are shell commands Claude Code runs at fixed points: before or after a tool call, when you submit a prompt, when Claude stops, on notifications and at session start.
  • They are set in the hooks section of ~/.claude/settings.json (or .claude/settings.json for a project), or come bundled in a plugin.
  • A hook can block a tool call, add context, or run a formatter or test. Read the scripts before you install them: they run on your machine with your permissions.
Claude Code docs

Details

Type
Hooks
Language
TypeScript
License
MIT
Last updated
1 November 2026
Topics
ai-agentsclaude-codeclaude-code-modclaude-code-plugindeveloper-toolsguardrailsrate-limitingsubagentstypescriptusage-limits

FAQ

What is Agent Usage Guard?

Hook mod that pauses subagent fan-out, heavy prompts and retry loops before they burn quota. It is a hook for Claude Code, from rbartoli/agent-usage-guard on GitHub.

How do I install Agent Usage Guard?

Run /plugin marketplace add rbartoli/agent-usage-guard inside Claude Code, then follow the setup in the README.

Is Agent Usage Guard popular?

rbartoli/agent-usage-guard has 93 GitHub stars and 5 forks. It was last updated on 1 November 2026.

More hooks

Browse the most popular Claude Code mods, all hooks, or the skills and MCP server directories.