Mac YOLO Safeguards

Claude Code or Codex freezing your Mac

You run a coding agent, leave it working, and come back to a Mac that barely moves: the cursor lags, windows take seconds to open, the fans are loud. This page covers the usual causes, how to tell which one you have, and what to do about each. You don't need to install anything to follow it.

The usual causes

1. Memory pressure and swap. Each agent session, each MCP server it starts, and each browser or simulator it opens takes memory. When RAM runs out, macOS moves memory to the disk (swap). A Mac that is writing to swap is slow. A Mac that is constantly reading it back is nearly frozen. On November 3, mine froze while Activity Monitor still showed 71% of memory free, because it was reading 155 to 400 pages a second back from swap. How much swap is used matters less than how fast it is being read.

2. A runaway process. One process uses a whole CPU core or more, or keeps starting copies of itself. On May 26, an agent booted an iPhone simulator that kept forking until my load average hit 307 and the Mac stopped responding. On November 1, a looping command wrapper piled up about 390 processes.

3. Leftover MCP servers. Every session starts its own copy of each MCP server. Some outlive the session. There is a separate page on finding and stopping them.

4. A nearly full disk. Swap files live on your startup disk. When the disk is almost full, memory trouble gets worse. Agent logs and caches can fill it quietly: see where they pile up.

5. Something that isn't the agent. Spotlight indexing a freshly cloned repo, Photos analysing your library, or security software scanning files can all pin the CPU. Check before you blame the agent.

Check in Activity Monitor

Open Activity Monitor (Spotlight, then type its name).

Check in Terminal

Top 10 processes by CPU (PID, CPU percent, memory in KB, how long it has run, program):

ps -Ao pid,%cpu,rss,etime,comm -r | head -11

Top 10 by memory (swap -r for -m):

ps -Ao pid,%cpu,rss,etime,comm -m | head -11

Swap in use, and how tight memory is:

sysctl vm.swapusage
memory_pressure | tail -2
uptime

The last number group in uptime is the load average over 1, 5 and 15 minutes. A load well above your number of CPU cores means more work is queued than the Mac can run.

Watch swap reads and writes live, one row per second:

vm_stat -c 5 1

Ignore the first row (it is the total since boot). In the later rows, the swapins and swapouts columns are pages moved in that second. Numbers in the hundreds or thousands on every row mean the Mac is thrashing. Zeros mean swap is not your problem right now.

How many processes are running, and how many look like MCP servers:

ps -ax | wc -l
ps -axo command | grep -ci '[m]cp'

A few hundred processes is normal. Over a thousand, or dozens of MCP lines, points to leftovers.

Free disk space:

df -h /

What to do

  1. Close agent sessions you aren't using. Each one holds memory and starts its own MCP servers. This is the biggest single fix.
  2. Stop a runaway by PID. Take the PID from the ps output, and make sure it is an agent child or helper, not part of macOS or an app you're using. Then:
    kill PID
    This asks the process to exit cleanly. Wait ten seconds. Only if it is still there, use kill -9 PID, which ends it at once and gives it no chance to save anything.
  3. Stop leftover MCP servers. Use the PPID 1 check.
  4. Free disk space. Aim to keep at least 10% of the disk free. See the disk cleanup page.
  5. Run fewer things in parallel. Three agents with ten MCP servers each is thirty processes before any work starts. Turn off MCP servers you don't use in each tool's config.
  6. Don't kill by name. pkill node or killall node also ends the live sessions and servers you want to keep, and anything else running on Node.

If the Mac is already too slow to use, hold the power button only as a last resort. Unsaved work is lost.

Let the Mac do it

The free Mac YOLO Safeguards menu bar app shows CPU, GPU, memory, swap and disk with the biggest users named, so you can tell a runaway agent from Spotlight at a glance. It stops leftover MCP servers and helpers when you click. It ends processes, so read what it can end before you click.

Pro Guard, $29 once, checks once a minute while the app is open, and acts without a click when memory runs short or less than 10 GB of disk is free. Full refund within 30 days.

Download for Mac (free)