Index

Clean macOS using Mole

A guide to installing and using Mole, a free macOS cleaner tool.

Mole — Mac Maintenance from the Terminal

Mole is a free, open-source command-line utility for macOS that combines the core features of CleanMyMac, AppCleaner, DaisyDisk, and iStat Menus into a single lightweight tool. No subscriptions, no background daemons, no upsells — just a single mo command.

Installation

Install using Homebrew

brew install mole

Commands Overview

All commands use the mo alias.

Command What it does
mo Interactive menu — pick a command visually
mo clean Deep-clean caches, logs, browser junk, temp files
mo uninstall Fully remove apps, including hidden leftovers
mo optimize Rebuild system databases, clear swap, reset services
mo analyze Interactive disk explorer — find what's eating space
mo status Live system dashboard: CPU, RAM, disk, health score
mo purge Clean up old/unused project directories
mo installer Find and remove large installer files (.dmg, .pkg)

Usage

Clean caches and junk files

mo clean

This is the core command. It scans for app caches, system logs, browser leftovers, Xcode derived data, Node modules, and more. On a typical dev machine it can surface 10–40 GB of reclaimable space.

Always preview first with --dry-run:

mo clean --dry-run

This shows exactly what would be deleted without touching anything. Recommended before your first run.

Protect specific paths from deletion:

mo clean --whitelist ~/path/to/keep

Uninstall apps cleanly

mo uninstall

macOS's built-in app deletion leaves behind launch agents, preferences, caches, and other remnants scattered across the system. mo uninstall finds and removes all of them. Navigate the interactive list with arrow keys and select apps to fully purge.

Optimize the system

mo optimize

Runs maintenance tasks macOS doesn't handle automatically: rebuilds Spotlight indexes, resets network services, clears diagnostic logs, cleans swap files, and refreshes system databases.

Analyze disk usage

mo analyze

An interactive, text-based disk explorer similar to DaisyDisk. Navigate with arrow keys, drill into folders, open items in Finder (O), or delete files directly ().

To scan a specific path:

mo analyze ~/Downloads

Check system status

mo status

A live dashboard showing CPU load, RAM pressure, disk usage, temperature, and I/O activity. Mole calculates a 0–100 health score so you can spot bottlenecks at a glance.

Safety Notes

The maintain Command (zshrc)

You can wire mo clean together with a full Homebrew update cycle into a single shell function. Add this to your ~/.zshrc:

maintain() {
  sudo -v || return 1

  sudo mo clean || return 1
  brew update || return 1
  brew upgrade || return 1
  brew upgrade --cask --greedy          # casks that self-update but brew ignores
  brew cleanup -s                        # -s also clears the download cache
  brew autoremove
  brew doctor                            # surface issues (non-fatal)

  command -v pipx >/dev/null && pipx upgrade-all   # CLI tools via pipx (safe)
  command -v mas  >/dev/null && mas upgrade        # Mac App Store apps

  softwareupdate -l                      # list macOS/security updates (add -i -a to install)
}
. "$HOME/.local/bin/env"

Then reload your shell:

source ~/.zshrc

Now just run:

maintain

What each step does

Step Purpose
sudo -v Refreshes sudo credentials upfront so no mid-run password prompts interrupt the flow
sudo mo clean Deep-cleans caches, logs, and junk files system-wide (sudo gives it access to protected paths)
brew update Fetches the latest formula/cask definitions from Homebrew
brew upgrade Upgrades all outdated packages and casks
brew cleanup Removes old versions of installed formulae and stale downloads
brew autoremove Uninstalls dependencies that are no longer needed by any installed package
. "$HOME/.local/bin/env" Re-sources your local env file so any PATH or env changes from upgraded tools take effect in the current shell

The || return 1 guards on the first three steps mean the function stops immediately if any critical step fails — it won't try to run brew upgrade if brew update errored out, for example.

Running on a schedule (optional)

To run maintain automatically every Sunday at 2 AM, first find the mo binary path:

command -v mo

Then add a cron entry (crontab -e), replacing the path as needed:

0 2 * * 0 /opt/homebrew/bin/mo clean > /dev/null 2>&1

For the full maintain function in cron, put it in a standalone script and call that instead, since cron doesn't load your .zshrc.

Updating Mole

brew upgrade mole

Resources

Last updated: 13-07-2026 at 12:51