On-demand macOS performance cleanup CLI. Pure bash, no dependencies.
Diagnose RAM/swap/load, kill stale dev servers, clear regenerable caches.
Built for developers whose Mac is slow because they have 47 Chrome tabs,
6 zombie next dev processes, and 5 GB of cache nobody asked for.
curl -sL https://raw.githubusercontent.com/Blockchainpreneur/mac-perf/main/mac-perf.sh \
-o /usr/local/bin/mac-perf && chmod +x /usr/local/bin/mac-perfOr clone and symlink:
git clone https://github.com/Blockchainpreneur/mac-perf.git
ln -s "$PWD/mac-perf/mac-perf.sh" /usr/local/bin/mac-perfmac-perf # report (default — no kills, no deletions)
mac-perf clean # safe cleanup, asks confirmation
mac-perf clean --yes # safe cleanup, no prompt
mac-perf aggressive -y # also kill hot dev servers + sudo purgeDiagnoses your machine. Reports:
- Uptime, load average, available RAM, swap usage, process counts
- Stale dev servers —
next dev/vite/webpack/nodemonrunning >2h - Hot dev servers — same, but using >50% CPU
- Orphans —
git fsmonitor,caffeinatereparented to PID 1 - Duplicate workers — keeps newest 2 per pattern (MCP servers, devtools)
- Cleanable caches — Chrome, npm, bun, Xcode, logs, etc. (above threshold)
- Recommendations — reboot if uptime >14d, warn on swap thrashing
- Kills only stale dev servers (>2h elapsed)
- Kills orphans + duplicate workers
- Clears caches that auto-regenerate (npm, bun, ~/.cache, Logs)
- Skips Chrome Service Worker cache if Chrome is running (would log you out)
- Asks confirmation per destructive step unless
--yes
- Everything in
cleanplus: - Kills hot dev servers (>50% CPU regardless of age)
- Clears Chrome SW cache even if Chrome is running
- Runs
sudo purgeto force-release inactive memory (requiresNOPASSWDfor/usr/sbin/purge)
╔══════════════════════════════════════════════════════════╗
║ MAC-PERF REPORT ║
╚══════════════════════════════════════════════════════════╝
▸ System
Uptime: 53 days
Load avg: 11.77
Avail RAM: 1.1G
Swap used: 12.9G / 13.3G
Procs: 513 (node:27, chrome:57)
▸ Stale dev servers (>2h elapsed)
PID 96702 9942m next-server (v16.2.2)
PID 28038 1656m next dev --port 3001
▸ Cleanable caches
chrome-cache 1.5G
chrome-sw 2.0G
npm-cache 880M
bun-cache 1.2G
user-cache 332M
logs 74M
───────────────────────
TOTAL 5.9G
▸ Recommendations
⚠ Reboot recommended (uptime 53d, swap accumulates)
⚠ Swap thrashing (97%)
⚠ Process count high (513)
You probably should. But until then, this script reliably reclaims 3-5 GB of disk and 500 MB-1 GB of RAM on a typical developer machine. The biggest single fix it can't do is reboot — swap doesn't release until you restart.
- Default mode (
report) never kills or deletes anything. cleanmode asks confirmation per step unless--yes.- Won't touch dev servers <2h old in safe mode (preserves active work).
- Won't clear Chrome SW cache if Chrome is running unless
aggressive. - All caches cleared are auto-regenerable (no data loss).
- All
killoperations send SIGTERM first, then SIGKILL only if the process refuses.
| Env var | Default | Purpose |
|---|---|---|
MAC_PERF_LOG |
~/.mac-perf.log |
Log file path |
MAC_PERF_PAGE_SIZE |
16384 |
Set to 4096 on Intel Macs |
The script is idempotent and safe to cron. Example LaunchAgent
(~/Library/LaunchAgents/com.user.mac-perf.plist):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key><string>com.user.mac-perf</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/mac-perf</string>
<string>clean</string>
<string>--yes</string>
<string>--quiet</string>
</array>
<key>StartInterval</key><integer>1800</integer>
<key>RunAtLoad</key><false/>
</dict>
</plist>Load it with launchctl load ~/Library/LaunchAgents/com.user.mac-perf.plist.
MIT — see LICENSE.