← sources

My Mac kept freezing while Claude Code agents ran, so I built a plugin that makes heavy jobs wait their turn

source: reddit (reddit:ClaudeAI)published 2026-10-14 13:53ingested 2026-10-15 02:37

retained text

I run a lot of Claude Code sessions on a 16 GB MacBook. In one week it fell over three times. The last time, I blamed the session I was typing in. It was only running a few curl calls.

The real cause was in another window. An agent had started two background subagents to re-render frames of a Remotion video at the same time. Every frame started a fresh headless Chrome with a 4 GB GPU memory budget, and two of those Chrome processes never exited. Add 11 open sessions with 44 MCP server processes, and swap hit 5.4 of 7 GB with a load average of 26 on 10 cores.

No agent checks whether the machine has room before it starts a render or a build, so I built swarm-brake, a set of Claude Code hooks that do.

What it does

Before every shell command, a PreToolUse hook classifies it. Light commands (ls, git, grep) pass in about 16 ms. Heavy ones (Remotion, ffmpeg, headless Chrome, Playwright, Xcode and npm builds, Docker builds) check free memory, memory pressure, load per core and how many heavy jobs are already running across all sessions. If there's room, the job runs at lower priority. If not, it waits up to 90 s, then tells the agent why it was blocked so it can wait or run things one at a time. When a session or subagent stops, it kills headless Chrome left behind by renders. It also logs every heavy job, so after a hang `swarm-brake report --at '2026-10-14 10:55'`shows which session started what.

Try it, in Claude Code:

    /plugin marketplace add antivirusakash/swarm-brake 
    /plugin install swarm-brake@swarm-brake

Repo: [https://github.com/antivirusakash/swarm-brake](https://github.com/antivirusakash/swarm-brake)

document fetched 2026-10-15 00:23 · canonical https://reddit.com/r/ClaudeAI/comments/1x5rtjq/my_mac_kept_freezing_while_claude_code_agents_ran