
10분 만에 394개의 서브에이전트가 Claude Code에서 나를 잠그게 했고, 그래서 먼저 물어보는 mod를 만들었다
Claude Code mod인 agent-usage-guard. 동시 서브에이전트와 에이전트 시작을 제한하고, 플랜 윈도우 할당량을 사용하기 전에 프롬프트하며, 동일한 재시도 루프를 거부합니다. 무료 MIT, 플러그인 마켓플레이스를 통해 설치.

이 mod 소개
10분 동안 394개의 서브에이전트 호출(341개 동시)과 8400만 컨텍스트 토큰을 생성하여 사용 잠금을 트리거한 세션 후에 구축되었습니다. 이 mod는 인프로세스 훅으로 실행됩니다: 모든 로컬 Claude Code 세션에서 에이전트를 동시 4개, 10분당 12회 시작으로 제한하고, 서브에이전트가 자체 에이전트를 생성하는 것을 차단하며, 5시간 또는 주간 플랜 윈도우의 80%에서 새 에이전트를 시작하기 전에 묻고, 95%에서 거부하며, 50만 토큰을 초과하는 과도한 재읽기 전에 프롬프트하고, 프롬프트 캐시 만료 후 과도한 세션을 재개할 때 프롬프트하며, 연속 3회 동일 실패 후 동일한 재시도를 거부합니다. 승인은 조건이 해제될 때까지 지속됩니다. claude -p에서는 프롬프트하는 대신 이유와 함께 거부합니다. /agent-guard report는 활동을 표시합니다. TypeScript, 의존성 없음, 86개 테스트, 네트워크 호출 없음.
설치
설치 방법은 원본 출처를 확인하세요.
원문 / README
One afternoon I gave Claude Code a research prompt at max effort. It made 394 subagent calls, 341 of them running at once, and pushed 84M context tokens through the API in ten minutes. Then "Claude usage limit reached": locked out until the window reset. Sixty days of my logs held 12 lockouts like it. So I built agent-usage-guard, a Claude Code mod (mods are the in-process hooks Claude Code added in 2.1.287). It acts before the spend, not after: Agents: 4 running at once and 12 starts per 10 minutes, counted across every Claude Code session on your machine. Subagents can't start their own. Plan window: from 80% of your 5-hour or weekly window, new agents ask first; from 95% they're refused. Heavy context: a prompt that would re-read 500k+ tokens asks to compact first, send anyway, or cancel. A heavy session resumed after its prompt cache expired asks too. Loops: after three identical failures in a row, the identical retry is refused. It asks in Claude Code's own question dialog, and one approval covers the condition until it clears, so the same question doesn't come back call after call. In claude -p it refuses with a reason instead, so Claude can wait, batch the work or stop. /agent-guard report shows what it did. The video is Claude Code's real UI running against a scripted local API: the sessions and token counts are staged, and no usage was spent recording it. How I built it: with Claude Code, in TypeScript with no dependencies; 86 tests run in Claude Code's own mod test kit. Its first version was plain hooks, which I ran for 75 days: my largest agent burst fell from 365 starts in ten minutes to 27. It hasn't cut my lockouts yet. Those come from many main sessions running in parallel, which is what I'm working on next. Free, MIT, no network calls. Install in Claude Code 2.1.287+: /plugin marketplace add rbartoli/agent-usage-guard /plugin install agent-usage-guard@agent-usage-guard /reload-plugins https://github.com/rbartoli/agent-usage-guard Which default would you change first? submitted by /u/rbartoli [link] [comments]

