Generic guides tell you to empty your trash. Here is the actual guide to hunting down the invisible developer tools and hidden macOS system files eating your hard drive.

If you use a Mac heavily: especially if you write code, test software or sync mobile devices, you already know the feeling.

You go to save a file, and your Mac spits back the dreaded warning: Your disk is almost full.

So you do what everyone does. You open the "Storage Management" UI. You empty your trash. You delete three old movies and a bunch of screenshots. You gain exactly 1.2 GB of space. Then you look at the storage bar, and see a mysterious gray block labeled "System Data" taking up 120GB of space.

Generic Mac cleanup guides don't help here. You can't just delete "System Data" from a menu.

Today, we are going to do a deep clean. No third-party "Mac Cleaner" subscriptions required. Just pure, targeted terminal commands to nuke the invisible bloat. We will tackle this in two phases: the hidden macOS system files, and the abandoned developer infrastructure.

Here is the exact routine I run every three months to reclaim massive amounts of disk space.

Phase 1: The Hidden macOS System Hogs

The massive "System Data" block usually consists of three things: local backups, cache files, and logs.

1. The Ghost Backups: Local Time Machine Snapshots

This is the single biggest culprit for mysterious "System" storage bloat.

If you use Time Machine, macOS creates local snapshots of your drive on your internal disk, even when your external backup drive isn't plugged in. It saves these "just in case," and they can easily consume 30GB to 60GB of space.

The Fix: Open your terminal and list the local snapshots:

tmutil listlocalsnapshots /

You will see a list of dates. You can delete them one by one, or you can force macOS to thin them out automatically by running:

None
tmutil thinlocalsnapshots / 10000000000 4

(This command asks macOS to free up 10GB of snapshot space, at a high urgency level of 4).

2. The Forgotten Archives: iOS Backups

If you have ever plugged an iPhone or iPad into your Mac to sync or update, macOS probably created a full backup of that device. A single iPhone backup can be 50GB+.

The Fix: You can manage these via Finder (click your device, click "Manage Backups"), or you can nuke them directly from the terminal if you no longer need them:

rm -rf ~/Library/Application\ Support/MobileSync/Backup/*

3. The Clutter: System and App Caches

Every app you use generates cache files to load faster. Over time, apps you haven't opened in years are still holding onto gigabytes of cache.

The Fix: It is generally safe to clear your user cache. The apps will simply rebuild what they need the next time you open them.

rm -rf ~/Library/Caches/*

Note: Restart your Mac after running this so the system can cleanly rebuild active caches.

Phase 2: The Developer Graveyard

If you write code, your disk isn't just full of system data; it's full of dangling Docker volumes, cached packages from old projects, and gigabytes of compiled binaries.

4. The Whale in the Room: Docker

Docker doesn't clean up after itself by default. Every time you build an image or spin up a database volume, Docker allocates space. When you stop that container, the space sits there, hoarding gigabytes.

The Fix: Run the nuclear option for Docker cleanup:

docker system prune -a --volumes

(This removes all unused images and anonymous volumes not currently attached to a running container. I routinely clear 40GB with this single command).

5. The Black Hole: node_modules

If you write JavaScript or TypeScript, your hard drive is riddled with node_modules folders. Each one is roughly the size of a black hole.

The Fix: Use npkill. It is a brilliant open-source utility that scans your system for node_modules directories, sorts them by size, and lets you delete them with the spacebar. Run it directly via npx:

npx npkill

6. The Apple Tax: Xcode DerivedData

Xcode stores project indexes, build logs, and compiled intermediate files in a folder called DerivedData. Over time, this folder grows to absurd proportions.

The Fix: It is completely safe to delete. Xcode will just rebuild what it needs next time.

rm -rf ~/Library/Developer/Xcode/DerivedData/*

7. The Hoarder: Homebrew Cache

When you run brew upgrade, Homebrew downloads the new version, installs it, and keeps the old archive forever.

The Fix: Tell Homebrew to clean up its outdated downloads:

brew cleanup
None

Phase 3: The Detective Work

If you've run the commands above and your disk is still dangerously full, it's time to play detective.

Navigate to your home directory (cd ~) and run this command:

du -sh * 2>/dev/null | sort -rh | head -20

What this does: It calculates the disk usage of every folder, silences the permission errors, sorts them by biggest first, and shows you the top 20 offenders.

Once you spot a massive folder (say, ~/Downloads), cd into it and run the command again. Keep drilling down until you find the exact log file, virtual machine image, or abandoned video asset that is choking your machine.

The Maintenance Routine

You don't need a paid "Mac Cleaner" app running in your menu bar, draining your battery. You just need to run this routine once a quarter.

  1. Thin your Time Machine snapshots.
  2. Clear old iOS backups.
  3. Prune Docker.
  4. Nuke old node_modules with npkill.
  5. Clear the Homebrew cache.

Bookmark this page. The next time macOS gives you the dreaded "Your disk is almost full" warning, you'll know exactly what to do.

I'm Dhanush Nehru an Engineer, Cybersecurity Enthusiast, Youtuber and Content creator. I document my journey through articles and videos, sharing real-world insights about DevOps, automation, security, cloud engineering and more.

You can support me / sponsor me or follow my work via X, Instagram ,Github or Youtube