Say four Claude Code agents run on one laptop. One starts cargo test while the other three already build. Four heavy jobs at once can slow the machine to a crawl, and you cannot watch every command the agents run.
The fix
agentgc is a CLI that I built. Its Claude Code hook queues heavy commands. Install it:
agentgc hook install # dry run: prints the target file and the JSON agentgc hook install --apply # merges the hook into .claude/settings.json # then restart Claude Code A rule in CLAUDE.md is only advice. A hook makes Claude Code follow it.
The hook watches the Bash tool. It rewrites a plain heavy command, such as cargo test or npm run build, to agentgc run -- cargo test. By default, a quarter of the logical cores (at least one) run heavy work at once. The rest wait for a free slot, in no fixed order.
A second hook, session-start, tells each new session to use agentgc run -- for heavy commands.
Safe by default
The hook asks for approval before it rewrites a command. Claude Code shows the new command, and you approve it. --allow skips that question. Add it only if you accept every rewrite.
The hook rewrites plain single commands only. Commands with shell syntax, such as pipes, &&, redirects, quotes or globs, stay as they are. Before it changes the file, hook install copies your .claude/settings.json to settings.json.agentgc.bak.
The release notes say the tests pass on Windows, Linux and macOS in GitHub Actions. They also say the full flow was run end to end by hand on Windows only. The binaries are not code signed, so Windows SmartScreen or macOS Gatekeeper can warn on the first start.
New in 0.3.0
-
agentgc task review NAMEshows what a task changed before you finish it. It only reads. -
agentgc doctorlists hard-coded ports and database names in the files that git tracks. It only reads. -
agentgc run --min-intervalwaits a set number of seconds between the starts of two queued commands. -
db.disconnectinagentgc.task.tomlruns your command before the database drop intask done. -
agentgc worktrees --depsestimates how much a shared dependency store would save.
Repo: https://github.com/JohnWayneeee/agentgc. Release notes: https://github.com/JohnWayneeee/agentgc/releases/tag/v0.3.0