Mac cleanup command builder

Tick what you want to check. You get read-only Terminal commands that measure each folder, plus the documented cleanup command for that category and our verdict on whether it’s safe. Nothing leaves your browser.

1. Pick categories
2. Copy and paste into Terminal
# App caches [Safe]
du -sh ~/"Library/Caches" 2>/dev/null
open ~/Library/Caches

# Developer package caches [Safe]
du -sh ~/"Library/Caches/Homebrew" ~/".npm/_cacache" ~/"Library/Caches/Yarn" ~/".yarn/berry/cache" ~/"Library/Caches/pnpm" ~/"Library/pnpm/store" ~/".bun/install/cache" ~/"Library/Caches/deno" ~/"Library/Caches/pip" ~/"Library/Caches/pypoetry" ~/".cache/uv" ~/".cache/pip" ~/"miniconda3/pkgs" ~/"anaconda3/pkgs" ~/"opt/miniconda3/pkgs" ~/"opt/anaconda3/pkgs" ~/".conda/pkgs" ~/".gradle/caches" ~/".m2/repository" ~/".cargo/registry" ~/"go/pkg/mod" ~/"Library/Caches/go-build" ~/"Library/Caches/org.swift.swiftpm" ~/"Library/Caches/CocoaPods" ~/"Library/Caches/org.carthage.CarthageKit" ~/".pub-cache" ~/".cache/node-gyp" ~/"Library/Caches/ms-playwright" ~/".cache/puppeteer" 2>/dev/null
# Documented cleanup (changes files; remove the leading # to run):
# brew cleanup && npm cache clean --force

# Logs [Safe]
du -sh ~/"Library/Logs" 2>/dev/null
open ~/Library/Logs
CategoryOur verdictDocumented command
App cachesSafeopen ~/Library/Caches
Read-only.
Developer package cachesSafebrew cleanup && npm cache clean --force
Changes files. Commented out in the script.
LogsSafeopen ~/Library/Logs
Read-only.

Runs in zsh or bash. Sizes from du -h are binary (G = GiB).

Rather not paste commands?

Tidy Mac measures these for you, sorts each item into Safe to clear, Worth a look or Kept, and moves only what you choose to the Trash, with Undo. $9.99 once, 2 Macs.

How it works

Each category comes from Tidy Mac’s storage library: its real folder paths, our safety verdict, and the one command the library documents for it. For every ticked category the builder writes a du -sh line with the paths quoted (spaces are safe) and ~ left outside the quotes so it still expands to your home folder.

Documented commands that only look (such as open, ls or ollama list) are included as they are. Commands that change files (such as rm, brew cleanup or docker system prune) are commented out with #. To learn more first, read how to check disk space in Terminal.

Questions

Are these commands safe to run?

Every du -sh line only measures; it never changes a file. Documented cleanup commands that do change files are commented out with #, so pasting the whole script is read-only. Remove the # only after reading the linked page for that category.

Why does du say “Operation not permitted” or show nothing?

A folder that doesn’t exist on your Mac is skipped silently (2>/dev/null). macOS protects some folders, such as Mail and Messages: give Terminal Full Disk Access in System Settings › Privacy & Security, then run the command again.

Where do these paths and commands come from?

From Tidy Mac’s storage library, written and checked by the Tidy Mac team. Nothing is invented for this page; each category links to its full explanation in the storage library.

Why is du’s number different from Finder’s?

du -h counts in binary units (1G = 1,073,741,824 bytes) while Finder uses decimal GB (1,000,000,000 bytes). Convert with the storage unit converter.

Related