hn.today

Show HN: agent-usage-guard – a Claude Code mod to protect your usage window

github.com21 points7 comments
Screenshot of Show HN: agent-usage-guard – a Claude Code mod to protect your usage window

agent-usage-guard is a Claude Code mod that prevents runaway consumption of a plan’s short-term usage window by intercepting expensive actions before they execute. It reads live plan usage, counts agents and token churn across every Claude Code session on the machine, and prompts you in Claude Code’s own dialog to approve or refuse risky events. Built after repeated lockouts from massive subagent spawning and rapid context churn, it runs locally with minimal privacy exposure (stores only counts and coarse buckets), fails open for most hook errors, and refuses only when it cannot judge an agent in time.

The mod enforces concrete, configurable rules: plan-window approvals start at 80% and refusals at 95%, rapid window rises trigger asks at 20 percentage points/10 minutes, concurrent agents across the machine default to 4, agents started/resumed per 10 minutes default to 12, and subagent token processing per 10 minutes defaults to 10M. Context guards add a 300k-token “keep bounded” note, ask before re-reading 500k tokens, and ask before rewriting a 150k-token cache idle for 1 hour. It also blocks subagent recursion beyond depth 1, refuses three identical failing tool retries, and pauses refused agent spawns for 10 minutes. When it asks, the dialog blocks until answered; unattended modes return refusals. Commands include /agent-guard status, allow, pause, resume, report and help. Installable from the Claude Code plugin marketplace v2.1.287+.

Read on github.com7 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in AI

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.