Skip to content

Reclaiming Gigabytes on macOS from the Terminal: Modern CLI Cleanup Tools and a Safe Workflow

A practical, battle-tested guide to modern macOS CLI cleanup tools (mole, dua-cli, kondo, fclones), native APFS and dev commands, pros and cons, and a safe workflow that reclaims 50–100+ GB without touching active work.

Reclaiming Gigabytes on macOS from the Terminal: Modern CLI Cleanup Tools and a Safe Workflow

If you develop on a 512 GB Apple Silicon Mac, you already know the moment: your SSD quietly creeps past 90% full, macOS Settings points vaguely at 180 GB of “System Data”, and Finder refuses to tell you what is actually eating your disk.

Commercial GUI cleaners like CleanMyMac try to solve this with subscriptions, background daemons, and opaque “Smart Scan” buttons. On a developer machine, that is usually the worst way to clean a disk—you either miss the real multi-gigabyte culprits (Xcode simulators, Docker build caches, Python uv wheels, AI coding agent transcripts, duplicate SDKs) or accidentally wipe something you needed.

Over the last couple of years, a strong wave of fast, open-source Rust and Go terminal tools has made macOS cleanup transparent, scriptable, and safe. This guide covers:

  • Three macOS storage gotchas to understand before deleting anything
  • A minimal 4-tool CLI stack (mole, dua-cli, kondo, fclones) with pros, cons, and exact commands
  • Other recent tools worth knowing in the 2025–2026 ecosystem
  • Native macOS and dev-ecosystem commands that third-party cleaners routinely miss
  • A safe 4-phase cleanup workflow that took a 494 GB Mac Mini SSD from 46 GB free to 143 GB free (+97 GB) in under 15 minutes

Before You Delete Anything: 3 macOS Storage Gotchas

Before running any cleaner, keep three macOS-specific behaviors in mind. Missing any of these leads to confusing numbers or risky guesses.

1. Apparent size vs. physical disk blocks (the CloudStorage trap)

If you scan ~/Library with a tool configured to measure apparent file size (such as dua -A), folders like ~/Library/CloudStorage (Dropbox, iCloud Drive, Google Drive) can report 800+ GB even on a 512 GB SSD.

That happens because cloud-evicted (“dataless”) files have a large logical size in metadata while occupying 0 physical blocks on disk. Always measure physical allocated blocks (the default in dua without -A, or du -sh) when hunting for real disk usage.

2. APFS free space vs. df -h

macOS runs on APFS containers where multiple volumes (Macintosh HD, Data, Preboot, Recovery, VM) share one storage pool. For the ground truth on how full your internal SSD really is, check the APFS container directly:

df -h /
diskutil apfs list disk3 | head -n 12

(Replace disk3 with your root APFS container if diskutil apfs list shows a different container ID.)

3. Terminal Full Disk Access

Modern macOS sandboxes terminal apps. Without Full Disk Access (System Settings → Privacy & Security → Full Disk Access), CLI scanners will silently skip ~/.Trash and several protected ~/Library directories, under-reporting what is actually on disk.


Rather than installing a dozen overlapping cleaners, four zero-dependency Homebrew tools cover nearly every cleanup scenario cleanly. Together, they weigh only ~24 MB and pull in zero extra dependencies:

brew install mole dua-cli kondo fclones

Here is what each tool does best, along with its honest pros and cons.


1. mole (mo) — Modern All-in-One macOS Cleaner & Uninstaller

GitHub: tw93/Mole | Command: mo

mole is the standout recent open-source terminal toolkit for macOS, combining cache cleanup, smart app uninstallation, leftover installer detection, disk exploration, and system maintenance in a single CLI/TUI.

Key commands:

# Preview caches, logs, and orphaned leftovers from uninstalled apps
mo clean --dry-run

# Interactive menu (clean, uninstall, analyze, optimize, status)
mo

# Find and remove forgotten .dmg / .pkg installers
mo installer --dry-run

# Completely uninstall an app along with ~/Library preferences & LaunchAgents
mo uninstall

# Preview stripping Intel (x86_64) slices from Universal apps on Apple Silicon
mo slim --dry-run

Pros:

  • Purpose-built for macOS: understands ~/Library caches, logs, browser caches, SwiftPM, npm/uv/Go/Docker caches, and orphaned app remnants.
  • First-class --dry-run support across subcommands and whitelist management (mo clean --whitelist).
  • Fast, clean, open-source replacement for CleanMyMac + AppCleaner.

Cons & gotchas:

  • Can stall on massive tiny-file caches: In real-world testing, mo clean --dry-run hung for several minutes scanning a 3.2 GB ~/.dartServer directory packed with hundreds of thousands of tiny Dart analysis files.
  • Needs Full Disk Access (and sudo -v for system caches) for a complete preview.
  • Some subcommands like mo installer --dry-run open an interactive TUI even with --dry-run, which is great interactively but awkward in non-interactive scripts.

2. dua (dua-cli) — Fastest Interactive Disk Space Hunter

Written in: Rust | Command: dua

When you want to know where the gigabytes actually went—especially inside dotfolders (~/.cache, ~/.claude, ~/.codex, ~/.local, ~/.android) that general cleaners never check—dua is unbeatable. It walks APFS in parallel and includes an interactive TUI (dua i) that deletes marked folders in parallel much faster than rm -rf.

Key commands:

# Interactive TUI on your home folder (stays on the internal SSD)
dua i --stay-on-filesystem ~

# Drill directly into ~/Library or Xcode data
dua i ~/Library
dua i ~/Library/Developer

# Non-interactive physical size check on dotfolders
dua --stay-on-filesystem ~/.cache/* ~/.local/share/*

Pros:

  • Blazingly fast parallel scanning on Apple Silicon NVMe SSDs.
  • Defaults to physical disk usage (won’t be fooled by cloud-evicted files unless you pass -A).
  • Interactive mark-and-delete mode (d to mark, Ctrl+d to delete) makes clearing multi-gigabyte folders effortless.

Cons & gotchas:

  • It is a disk analyzer, not a smart cleaner—it won’t tell you whether a folder is safe to delete.
  • Easy to misread if you accidentally pass -A (apparent size) on folders containing iCloud/Dropbox placeholders.

3. kondo — Multi-Language Project Build Artifact Sweeper

Written in: Rust | Command: kondo

If you work across dozens of repositories, stale node_modules/, Cargo target/, Python .venv/, Flutter .dart_tool/ & build/, Swift .build/, and Gradle build directories quietly pile up tens of gigabytes. kondo knows the exact artifact folders for over a dozen languages and sweeps them safely without touching your source code.

Key commands:

# Dry-run across your dev folder (100% read-only)
kondo -n -s ~/dev

# Only target projects untouched for more than 14 days (dry-run)
kondo -n -s -o 14d ~/dev

# Interactive cleanup for projects untouched for 30+ days
kondo -s -o 30d ~/dev

Pros:

  • Supports Node/JS, Rust (Cargo), Python, Swift, Dart/Flutter (Pub), Gradle, Maven, Go/CMake, Unity, .NET, and more out of the box.
  • The -o (--older) age filter lets you leave active projects alone while sweeping abandoned ones.
  • Safe by default: interactively prompts per project unless you pass -a.

Cons & gotchas:

  • Only cleans inside recognized project directories—it does not touch global caches (~/Library/Caches, ~/.cache/uv, Xcode DerivedData, or Docker).
  • Passing -I with non-existent paths or scanning ~ directly can trip over restricted system folders; point it directly at your code directories (~/dev, /Volumes/External/dev).

4. fclones — Zero-Loss APFS Duplicate Deduplication

Written in: Rust | Command: fclones

fclones is a multi-stage parallel duplicate finder with a superpower on macOS: APFS copy-on-write (CoW) cloning.

Instead of forcing you to decide which duplicate file to delete, fclones dedupe points identical files to the same underlying APFS disk blocks. Both file paths stay intact, editing either copy later transparently forks the blocks, and you immediately reclaim 100% of the duplicate disk space.

Key commands:

# Read-only scan for duplicate files >= 1 MB (staying on one filesystem)
fclones group --min 1M --one-fs ~/Downloads ~/Desktop ~/Documents

# Reclaim space with zero-loss APFS copy-on-write clones
fclones group --min 1M --one-fs ~/Downloads | fclones dedupe

# Preview what dedupe would do without modifying anything
fclones group --min 1M --one-fs ~/Downloads | fclones dedupe --dry-run

Pros:

  • Reclaims space without deleting any files or breaking folder structures (ideal for archived course materials, audio assets, or duplicated project exports).
  • Multi-stage filtering (size → partial hash → full hash) scans thousands of files in under a second.

Cons & gotchas:

  • Only finds exact byte-for-byte duplicates—not resized or visually similar photos/videos.
  • Avoid running it across cloud-synced placeholder folders (~/Library/CloudStorage) unless you want cloud clients hydrating remote files.

Other Notable macOS CLI Cleanup Tools (2025–2026)

If your workflow leans toward a specific niche, several other active open-source tools are worth knowing:

ToolBest ForProsCons
TidyMyMac (viniciussouzao/tidymymac)Go TUI targeting macOS “System Data”Dry-run by default; hardcoded safety exclusions; covers Xcode, Docker, Time Machine snapshots, and iOS backupsOverlaps heavily with mole
Pearcleaner (brew install --cask pearcleaner)App uninstallation & orphaned ~/Library remnantsArguably the cleanest open-source app remnant hunter; offers both a native macOS GUI and CLIFocused on apps/remnants rather than general dev caches
MacWash (toolka/MacWash)Modern JS/Python/Rust dev caches + macOS DB maintenanceKnows bun, uv, pnpm, docker, plus LaunchServices & Mail/Messages SQLite compactionNewer project; review dry-runs carefully
sektioneins/mac-cleanupSafe Trash-first Go/Bubble Tea TUIModern rewrite of classic mac-cleanup scripts; moves items to Trash instead of rm -rfLess comprehensive for Xcode/Docker than dedicated commands
czkawka (czkawka_cli)Visually similar images/videos, broken symlinks, empty foldersFast Rust Swiss-army knife for media & filesystem hygieneHomebrew caveat: brew install czkawka pulls in GTK4, FFmpeg, Cairo, x264, and x265 (hundreds of MB of dependencies)
rustdupeInteractive duplicate TUI with persistent hash cacheBLAKE3 hashing, instant rescans, handles macOS NFD/NFC Unicode filenames cleanlyRequires cargo install; no APFS CoW cloning like fclones
gdu / dustAlternatives to duagdu feels familiar to ncdu users; dust gives a quick tree chart in one shotdua i is generally faster for interactive bulk deletion
cargo-reclaimRust developers tired of cold rebuildsTrims stale target/ artifacts while preserving incremental compile cacheRust-only

Native Commands Most Cleaners Miss (Where the Real 100 GB Hides)

General-purpose cleaners rarely reclaim more than 5–15 GB on a developer Mac. The massive wins—50 to 150+ GB—almost always live inside Xcode, Docker, package caches, AI agent session logs, duplicate SDKs, and APFS snapshots.

1. Xcode DerivedData, DeviceSupport, and Shutdown Simulators

On a Mac doing iOS, macOS, or Flutter work, ~/Library/Developer routinely balloons past 60–80 GB.

Inspect first (read-only):

# See where Xcode space is going
dua --stay-on-filesystem ~/Library/Developer/* ~/Library/Developer/Xcode/*

# List all simulator devices and their state
xcrun simctl list devices

# List installed simulator runtimes (iOS, tvOS, watchOS)
xcrun simctl list runtimes

Clean safely:

# 1. Clear Xcode DerivedData (100% rebuildable; often 15–30+ GB)
rm -rf ~/Library/Developer/Xcode/DerivedData/*

# 2. Delete unavailable (old runtime) simulators
xcrun simctl delete unavailable

# 3. Delete ALL currently shutdown simulators (keeps any Booted simulator untouched)
xcrun simctl list devices | grep "(Shutdown)" \
  | grep -oE '[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}' \
  | xargs -n1 xcrun simctl delete

Pros: Instant 20–60+ GB win; Xcode recreates DerivedData and new simulators automatically whenever needed.
Cons: First build after wiping DerivedData takes longer; deleting a simulator wipes apps/data installed inside that simulator.


2. Docker & OrbStack Unused Images and Build Cache

Every local container build leaves layers behind in Docker’s build cache.

Inspect first:

docker system df

Clean safely (without touching running containers or database volumes):

# Remove unused images, stopped containers, and unused networks
docker system prune -a

# Remove all unused build cache
docker builder prune -a

Warning: Never casually add --volumes to docker system prune unless you are 100% sure no stopped container owns a PostgreSQL, Redis, or MinIO volume you care about.

If you use OrbStack, its Linux VM disk compacts asynchronously after Docker frees blocks—wait 1–2 minutes and check diskutil apfs list again to see the full reclaimed space reflected on macOS.


3. Package Managers, Toolchain Caches & Duplicate SDKs

Modern polyglot dev machines accumulate huge caches across every runtime:

# Inspect common hidden dotfolder caches
dua --stay-on-filesystem ~/.cache/* ~/.gradle ~/.dartServer ~/.bun ~/.npm ~/.pub-cache

# Homebrew: preview first, then clean old versions & download caches
brew cleanup --prune=all -n
brew cleanup --prune=all && brew autoremove

# Python uv cache (prune unused wheels, or 'clean' to wipe all)
uv cache prune
# uv cache clean

Watch out for duplicate SDK installations. If you have ever installed Flutter, Java, or Node via Homebrew and a version manager and manual downloads, check what is actually active on PATH:

which flutter && flutter --version

Consolidating multiple Flutter SDK copies into a single up-to-date Homebrew cask (brew upgrade --cask flutter && brew cleanup --prune=all flutter) easily saves 8–12 GB on its own.


4. The New 2025–2026 Developer Space Hog: AI Coding Agent Logs

If you use terminal AI coding agents heavily—like Claude Code (~/.claude/projects) or Codex CLI (~/.codex/archived_sessions)—their JSONL session transcripts and snapshots can quietly grow to 15–30+ GB in a single month. Almost no traditional Mac cleaner scans these directories yet.

Inspect size and age breakdown first (read-only):

dua --stay-on-filesystem ~/.claude/* ~/.codex/*

Check how much is older than 14 or 30 days:

find ~/.claude/projects ~/.codex/archived_sessions -type f -mtime +30 -print0 \
  | xargs -0 du -ch 2>/dev/null | tail -n 1

Options once you see the numbers:

  • Prune only files older than 30 days (or 14 days):
    find ~/.claude/projects -type f -mtime +30 -delete
  • Clear already-archived Codex sessions while keeping active ~/.codex/sessions untouched:
    find ~/.codex/archived_sessions -mindepth 1 -delete
  • Or move old transcripts to an external drive instead of deleting them if you like keeping history.

5. APFS Local Time Machine Snapshots & Pending macOS Updates

When macOS Settings shows massive unexplainable “System Data”, check APFS snapshots:

tmutil listlocalsnapshots /
diskutil apfs listSnapshots /

There are two very different kinds of snapshots you may see:

  1. Time Machine snapshots (com.apple.TimeMachine.*) — safe to thin when you need space back:
    # Ask macOS to safely thin up to 50 GB of local Time Machine snapshots
    sudo tmutil thinlocalsnapshots / 50000000000 4
  2. macOS Update snapshots (com.apple.os.update-MSUPrepareUpdate) — along with a large Preboot volume (15–20+ GB) or /System/Volumes/Data/macOS Install Data.
    • Do not delete these manually. That means macOS has downloaded and staged a Software Update waiting for a reboot. Finishing the macOS update automatically clears the staged files and reclaims the space safely.

A Safe 4-Phase Cleanup Workflow

Instead of running aggressive cleanup commands blindly, follow this four-phase sequence from safest to most selective:

Phase 1: Measure & Audit (100% Read-Only)

# Baseline APFS free space
df -h / && diskutil apfs list disk3 | head -n 10

# Top-level physical usage on home & Library
dua --stay-on-filesystem ~/* ~/.[!.]* | sort -h | tail -n 20
dua --stay-on-filesystem ~/Library/* | sort -h | tail -n 15

# Dry-runs across cleaners and ecosystems
mo clean --dry-run
brew cleanup --prune=all -n
docker system df
xcrun simctl list devices
tmutil listlocalsnapshots /

Phase 2: Zero-Regret Wins (Rebuildable & Unused)

Start with items that have zero data-loss risk:

  1. Clear ~/Library/Developer/Xcode/DerivedData/*
  2. Delete unused/shutdown QA simulators via xcrun simctl delete
  3. Run docker system prune -a && docker builder prune -a (without --volumes)
  4. Run brew cleanup --prune=all && brew autoremove
  5. Run uv cache prune (and clear ~/.dartServer if bloated)

Phase 3: Judgment Calls (Prune vs. Offload to External SSD)

Review items where you choose between deleting, pruning by age, or moving to an external SSD:

  • AI agent logs (~/.claude/projects, ~/.codex/archived_sessions)
  • Duplicate SDKs (old Flutter/Java/Node versions)
  • Unused Android Emulators (~/.android/avd)
  • Local ML weights (~/.cache/huggingface, ~/.lmstudio)
  • Old ~/Library/Developer/Xcode/iOS DeviceSupport symbols

Phase 4: Zero-Loss Deduplication & Stale Project Sweeping

# APFS copy-on-write deduplication (zero files deleted)
fclones group --min 1M --one-fs ~/Downloads ~/Documents | fclones dedupe --dry-run

# Sweep build folders in projects untouched for 14+ days
kondo -n -s -o 14d ~/dev

Safety Checklist: What Not to Blindly Wipe

  • Docker volumes (--volumes): Keep your local databases and persisted dev state intact unless you explicitly want to reset them.
  • Staged macOS update volumes (/System/Volumes/Update, Preboot, macOS Install Data): Let macOS finish or clean these via Software Update.
  • Active toolchain caches right before going offline: Clearing ~/.cache/uv, ~/.gradle, ~/.bun, or SwiftPM frees gigabytes quickly, but your next build will need an internet connection to re-download dependencies.
  • Inside ~/Library/CloudStorage: Manage cloud sync storage through the provider’s “Make Online-Only” controls rather than deleting files from the terminal (which propagates deletions to the cloud!).

Real-World Run: Reclaiming 97 GB in Under 15 Minutes

Here is what this exact workflow recovered on a 494 GB Apple Silicon Mac Mini SSD—without deleting a single active repository, running container, or database volume:

Cleanup ActionSpace Reclaimed
15 shutdown iOS/tvOS QA & test simulators (xcrun simctl delete)~42.0 GB
Xcode DerivedData (~/Library/Developer/Xcode/DerivedData)21.9 GiB
Docker / OrbStack unused images & build cache (docker system prune -a)20.2 GB
Archived Codex CLI sessions (~/.codex/archived_sessions)9.3 GiB
3 old/duplicate Flutter SDKs + Homebrew download cache11.9 GB
Claude & Codex session files > 30 days old0.2 GB
Net APFS Free Space Change (disk3)46.3 GB → 143.3 GB (+97.0 GB)

(That didn’t even require wiping uv, Gradle, SwiftPM, or browser caches yet—meaning another 30–50 GB of easy headroom is still available whenever needed.)


Quick Maintenance Cheat Sheet

Bookmark these five read-only checks to run once a month before your SSD ever hits 90%:

diskutil apfs list disk3 | head -n 10     # Real APFS free space
dua i --stay-on-filesystem ~              # Visual hunt for sudden space hogs
mo clean --dry-run                        # Preview macOS & dev cache bloat
docker system df                          # Check reclaimable Docker layers
kondo -n -s -o 14d ~/dev                  # Spot stale project build folders
Follow

Want more posts like this?

Follow along for more writing about language, AI, developer tools, and side projects.