A macOS maintenance tool written in Go that helps identify performance bottlenecks and safely clean long-lived system cruft.
- Performance-focused maintenance โ helps spot what is slowing down your Mac after long-term use
- Parallel execution โ independent tasks fan out as goroutines, results collected via channels
- Terminal progress UI โ live phase updates and per-task summary tables for clarity
- Safety-first โ three hard-coded constraints enforced at the
safeDelete()level, not just in comments
| Command | Purpose |
|---|---|
mac-cleanup overview |
System dashboard โ CPU, Memory, Swap, Disk, Launch Agents, Device Backups, Brew, Docker, top processes |
mac-cleanup safe |
Safe cleanup โ caches, logs, Xcode DerivedData, Time Machine thin, diagnostic reports |
mac-cleanup deep |
Deep cleanup โ safe + Docker prune + node_modules report + device backup report |
mac-cleanup brew |
Smart Homebrew upgrade โ risk-scored, dependency-aware |
mac-cleanup brew-analyze |
Homebrew package audit โ duplicates, stale versions, EOL/clashes |
mac-cleanup brew-full |
brew-analyze then brew upgrade in one run |
mac-cleanup apps |
List and cleanly uninstall non-App-Store applications |
mac-cleanup help |
Show detailed usage |
Running with no arguments shows the full help screen.
Prerequisites: Go 1.25+, macOS
git clone https://github.com/vianhanif/mac-cleanup-go
cd mac-cleanup-go
go build -o mac-cleanup .Then add an alias to your shell config (~/.zshrc, ~/.bashrc, etc.):
# mac-cleanup
alias mac-cleanup="/path/to/mac-cleanup-go/mac-cleanup"
# Optional short aliases per command
alias cleanup="mac-cleanup safe"
alias cleanup-deep="mac-cleanup deep"
alias cleanup-overview="mac-cleanup overview"
alias brew-upgrade="mac-cleanup brew"
alias brew-audit="mac-cleanup brew-analyze"Reload your shell:
source ~/.zshrcmac-cleanup <command>
Collects system metrics in parallel and renders three sections โ system stats, top home directories, and top processes by CPU.
Add --verbose for expanded diagnostics: top 10 by CPU, top 10 by memory (separate sort), PID + start time + running-for columns, and a zombie/stuck process detector. Strictly read-only โ no processes are killed.
mac-cleanup overview # compact view (top 5 by CPU)
mac-cleanup overview --verbose # full diagnostic view
๐ฅ System Dashboard
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โญโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ CPU โ โโโโโโโโโโ 58% โ
โ Memory โ โโโโโโโโโโ 40% โ
โ Disk / โ โโโโโโโโโโ 72% 89 GB used of 500 GB โ
โ Brew Outdated โ 4 packages โ
โ Docker โ running ยท 2.1 GB reclaimable โ
โ Swap โ 2.4 GB used of 8.0 GB โ
โ Launch Agents โ 14 item(s) ยท review in System Settings โ Login Items โ
โ Device Backups โ 28G ยท 3 backup(s) โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Hostname โ alvian-mbp โ
โ macOS Version โ 15.3.2 โ
โ System Uptime โ 3 days โ
โฐโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โโ Top Home Directories
โญโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโฎ
โ Path โ Size โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโค
โ ~/Library โ 48 GB โ
โ ~/Documents โ 12 GB โ
โฐโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโฏ
โโ Top Processes (by CPU)
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโโฎ
โ Process โ CPU % โ Memory โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโค
โ Xcode โ 42.1% โ 1.8 GB โ
โ Google Chrome Helper โ 18.3% โ 512 MB โ
โ coreaudiod โ 9.2% โ 48 MB โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโโฏ
With --verbose, the process section expands to three panels with PID, start time, and duration columns:
โโ Top Processes (by CPU) โ verbose
โญโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโฌโโโโโโโโโฌโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโฎ
โ PID โ PROCESS โ CPU % โ MEMORY โ STARTED โ RUNNING FOR โ
โโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโค
โ 280 โ com.manageengine.appctrl.driver โ 89.3% โ 11 MB โ Apr 8, 13:50 โ 1d 23h โ
โ 67261 โ WindowServer โ 16.8% โ 46 MB โ Apr 9, 16:16 โ 20h 46m โ
โ 162 โ trustd โ 10.1% โ 7 MB โ Apr 8, 13:50 โ 1d 23h โ
โ 68174 โ stable โ 4.5% โ 98 MB โ Today 08:26 โ 4h 35m โ
โ 68242 โ CursorUIViewService โ 3.7% โ 12 MB โ Today 08:26 โ 4h 35m โ
โ 68361 โ Lark โ 1.8% โ 86 MB โ Today 08:26 โ 4h 35m โ
โ 77424 โ Lark Helper (Renderer) โ 1.7% โ 228 MB โ Today 11:16 โ 1h 46m โ
โฐโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโดโโโโโโโโโดโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโฏ
โโ Top Processes (by Memory) โ verbose
โญโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโฌโโโโโโโโโฌโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโฎ
โ PID โ PROCESS โ CPU % โ MEMORY โ STARTED โ RUNNING FOR โ
โโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโค
โ 86502 โ Code Helper (Plugin) โ 0.1% โ 544 MB โ Today 12:30 โ 32m 27s โ
โ 86312 โ Code Helper (Renderer) โ 0.0% โ 426 MB โ Today 12:29 โ 33m 7s โ
โ 285 โ mds_stores โ 0.0% โ 322 MB โ Apr 8, 13:50 โ 1d 23h โ
โ 77424 โ Lark Helper (Renderer) โ 1.7% โ 228 MB โ Today 11:16 โ 1h 46m โ
โ 68173 โ Google Chrome โ 1.0% โ 169 MB โ Today 08:26 โ 4h 35m โ
โ 86308 โ Code โ 0.9% โ 148 MB โ Today 12:29 โ 33m 8s โ
โฐโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโดโโโโโโโโโดโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโฏ
โโ Zombie / Stuck Processes
โญโโโโโโโโฌโโโโโโโโโโโโฌโโโโโโโโโฌโโโโโโโโโฎ
โ PID โ PROCESS โ STATE โ MEMORY โ
โโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโค
โ 90463 โ <defunct> โ zombie โ 0 B โ
โฐโโโโโโโโดโโโโโโโโโโโโดโโโโโโโโโดโโโโโโโโโฏ
โน Zombie/stuck processes are not killed automatically.
โน Use Activity Monitor to investigate and force-quit if needed.
Cleans in parallel, then shows a summary table.
๐งน macOS Maintenance ยท safe
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Cleaning 4 / 5 [โโโโโโโโโโ] 2s
User Caches โ 843 MB freed 0.4s
User Logs โ 12 MB freed 0.1s
Xcode DerivedData โ 2.1 GB freed 0.2s
TM Snapshots โ thinned 1.8s
Diagnostic Reports โ 18 file(s) removed 0.1s
โโ Summary
โญโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโฎ
โ Task โ Status โ Result โ Time โ
โโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโค
โ User Caches โ โ โ 843 MB freed โ 0.4s โ
โ User Logs โ โ โ 12 MB freed โ 0.1s โ
โ Xcode DerivedData โ โ โ 2.1 GB freed โ 0.2s โ
โ TM Snapshots โ โ โ thinned โ 1.8s โ
โ Diagnostic Reports โ โ โ 18 file(s) removed โ 0.1s โ
โโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโค
โ Total โ 5/5 โ 2.96 GB freed โ โ
โฐโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโฏ
Phase 1 โ Analysis (parallel): for each outdated formula, runs brew info, brew deps, brew uses --installed, and checks brew list --pinned.
Risk scoring per package:
| Signal | Effect |
|---|---|
| 0 dependents (leaf) | risk 0 โ auto-upgrade |
| 1โ3 dependents | risk 1 โ auto-upgrade |
| 4+ dependents | risk 2 โ prompt |
Major version bump (1.x โ 2.x) |
+1 risk |
keg-only formula |
โ1 risk |
| In critical list or pinned | hard skip |
Phase 2 โ Upgrade: auto-risk packages run in parallel goroutines; prompted packages pause the progress bar and ask [y/N].
๐บ Smart Brew Upgrade
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
4 outdated packages found
Analysing packages 4 / 4 [โโโโโโโโโโ] 1s
jq 1.7.0 -> 1.7.1 leaf -> auto-upgrade
wget 1.24.5 -> 1.25.0 leaf -> auto-upgrade
libpng 1.6.43 -> 1.6.44 4 dependents - will prompt
node 20.0 -> 22.0 critical runtime - skipping
Upgrading 2 / 2 [โโโโโโโโโโ] 3s
jq -> 1.7.1 (0.4s)
wget -> 1.25.0 (0.8s)
! libpng has 4 dependent(s):
Dependents: cairo, ffmpeg, imagemagick, libvips
Version: 1.6.43 -> 1.6.44
Upgrade? [y/N]:
Runs three analysis passes in parallel:
- Duplicates โ same binary stem installed from multiple taps
- Multi-version โ stale
pkg@Nslots alongside a newer base formula - Clashes / EOL โ packages matched against a built-in EOL/shadowing rules table
Results are categorised into auto-removable, prompt, and informational, then offered for action.
๐ Brew Package Analysis
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Analysing 3 / 3 [โโโโโโโโโโ] 4s
Duplicates 0 issue(s) found
Multi-version slots 2 issue(s) found
Clashes / EOL 3 issue(s) found
โโ Analysis Results
โญโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ Package โ Issue โ Detail โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ MULTIPLE VERSIONS โ
โ node@18 โ โ auto-remove โ node 22 installed; node@18 is a stale slotโ
โ llvm@16 โ โ prompt โ required by: spirv-llvm-translator โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ CLASHES / EOL โ
โ openssl@1.1 โ โน inform โ openssl@1.1 EOL Sep 2023 โ openssl@3 โ
โ node@20 โ โน inform โ Node 20 LTS ends Apr 2026 โ
โ curl โ โน inform โ Homebrew curl shadows macOS curl in PATH โ
โฐโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โโ Recommended Actions
Auto-removable (no dependents):
[ ] node@18 brew uninstall node@18
Needs your decision:
[ ] llvm@16 required by: spirv-llvm-translator
Informational (no action taken):
[i] openssl@1.1 openssl@1.1 EOL Sep 2023 โ openssl@3
[i] node@20 Node 20 LTS ends Apr 2026
[i] curl Homebrew curl shadows macOS curl in PATH
Apply 1 auto-removable package(s)? [y/N]:
Scans /Applications, /Applications/Utilities/, and ~/Applications for apps that were not installed via the Apple App Store (detected by the absence of a _MASReceipt/receipt bundle). Displays a numbered list sorted alphabetically, lets you pick one or more to remove, confirms once, then deletes the .app bundle plus all associated support files.
Support file locations cleaned per app:
| Location | Matched by |
|---|---|
~/Library/Application Support/ |
Bundle ID or app name |
~/Library/Caches/ |
Bundle ID or app name |
~/Library/Logs/ |
Bundle ID or app name |
~/Library/Preferences/ |
<BundleID>.plist and variants |
~/Library/Containers/ |
Bundle ID |
~/Library/Group Containers/ |
dirs containing Bundle ID |
~/Library/Saved Application State/ |
<BundleID>.savedState |
~/Library/WebKit/ |
Bundle ID |
Flags:
| Flag | Effect |
|---|---|
| (none) | Interactive select + uninstall (sorted alphabetically) |
--list |
Print the app list only, no prompt |
--dry-run |
Show what would be removed without deleting |
--sort-size |
Sort listing by Total Size descending (largest first) |
๐ฆ App Uninstaller
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 42 non-App-Store app(s) found
โญโโโโโฌโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโฌโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ # โ Name โ Version โ Total Size โ Path โ
โโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 1 โ Alfred 5 โ 5.5 โ 252 MB โ /Applications/Alfred 5.app โ
โ 2 โ Bear โ 2.4.1 โ 19 MB โ /Applications/Bear.app โ
โ 3 โ Docker โ 4.40.0 โ 4.1 GB โ /Applications/Docker.app โ
โ 4 โ iTerm โ 3.5.10 โ 85 MB โ /Applications/iTerm.app โ
โ โฆ โ โฆ โ โฆ โ โฆ โ โฆ โ
โฐโโโโโดโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโดโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
Enter app number(s) to uninstall (e.g. 1,3,5 or all or q to quit)
> 1,4
! The following 2 app(s) will be permanently removed:
โ Alfred 5 (~252 MB)
/Applications/Alfred 5.app
โ iTerm (~85 MB)
/Applications/iTerm.app
Confirm uninstall? [y/N]: y
โโ App Uninstall Summary
โญโโโโโโโโโโโฌโโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโฌโโโโโโโโโฎ
โ App โ Status โ Expected โ Freed โ Time โ
โโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโค
โ Alfred 5 โ โ removed โ 252 MB โ 248 MB โ 0.31s โ
โ iTerm โ โ removed โ 85 MB โ 82 MB โ 0.12s โ
โโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโค
โ Total โ 2 app(s) โ 337 MB โ 330 MB โ โ
โฐโโโโโโโโโโโดโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโดโโโโโโโโโฏ
The Total Size column in the listing is computed at scan time (.app bundle + all support file locations) so you know what to expect before selecting anything. The summary's Expected vs Freed columns show the pre-deletion estimate against the actual bytes removed โ small differences are normal due to OS metadata or files released after process termination.
For --dry-run, Freed shows โ and only Expected is populated.
These are enforced in code at the safeDelete() level โ not just documentation.
LaunchAgents/, StartupItems/, and Fonts/ are in neverTouchPaths and can never be passed to safeDelete().
- Only paths in
allowedPathSuffixes(all under~/Library/) can be deleted - No
diskutil,fsck,kextcache, or SIP-protected path access tmutil thinlocalsnapshotsonly โ no snapshot deletion, nopurge- Docker pruned only when
docker infoconfirms it is running - Critical packages (
node,go,rust,openssl@3,gcc,zshโฆ) are never auto-upgraded
-
~/Library/Application Support/is inneverTouchPathsโ never touched -
Cache subdirectories excluded from the caches sweep:
com.google.Chrome com.google.Chrome.canary org.mozilla.firefox org.mozilla.nightly com.microsoft.edgemac com.microsoft.edgemac.Beta com.brave.Browser com.brave.Browser.beta com.operasoftware.Opera com.vivaldi.Vivaldi com.apple.Safari com.apple.SafariTechnologyPreview com.tinyspeck.slackmacgap com.apple.Spotlight com.apple.metadata com.apple.bird com.apple.akd com.apple.GSSFramework CloudKit com.apple.iCloudDrive
| Item | Rule |
|---|---|
~/Library/Application Support/ |
neverTouchPaths hard block |
~/Library/LaunchAgents/ |
neverTouchPaths hard block |
~/Library/Fonts/ |
neverTouchPaths hard block |
/System/, /usr/, /bin/โฆ |
neverTouchPaths hard block |
| Browser cache dirs | cacheExclusions list |
node_modules/ directories |
reported only in deep mode, never deleted |
| iOS/device backups | reported only in deep mode, never deleted |
| Pinned brew packages | brew list --pinned checked before any upgrade |
mac-cleanup-go/
โโโ main.go โ CLI entry point, signal handler, mode dispatch
โโโ config.go โ all safety constants (allowlist, blocklist, exclusions, EOL rules)
โโโ runner.go โ safeDelete(), runCmd(), bytesAt(), fmtBytes()
โโโ progress.go โ newPW(), phaseMonitor() โ animated progress bars
โโโ overview.go โ overview mode, parallel metric collectors
โโโ cleanup.go โ safe + deep modes, parallel task runner
โโโ brew.go โ smart upgrade: risk scoring, auto/prompt/skip
โโโ brew_analyze.go โ 3-pass package audit: duplicates, multi-version, clashes
โโโ apps.go โ non-App-Store app discovery, support-path resolution, uninstall
โโโ apps_prompt.go โ numbered list table, multi-select prompt, confirm dialog
โโโ summary.go โ rounded summary tables + help screen
โโโ go.mod
โโโ go.sum
Only one dependency: github.com/jedib0t/go-pretty/v6