← work

DiskScope: a disk analyzer for macOS

A native SwiftUI app with a zoomable treemap and a Reclaimable tab, plus a one-file Python CLI. It reports what's really on disk.

For
Personal
Role
Everything
Stack
SwiftUI, Python (stdlib only)
Status
Live, free for macOS
The DiskScope landing page.
The landing page, live at diskscope.vercel.app.

The problem

The question a disk analyzer should answer is "what is actually taking space, and what can I safely get back?" du and apps like DaisyDisk answer a slightly different question, because on macOS a file's size and the space it occupies are often not the same thing. Cleanup based on the wrong number is guesswork.

DiskScope is a native macOS app with a zoomable treemap and a "Reclaimable" tab, and a companion command-line tool in a single Python file with no dependencies beyond the standard library.

What was hard

Getting an honest number meant handling the cases where file size and disk usage aren't the same thing:

  • It counts st_blocks, not apparent size. Sparse files and iCloud files that have been evicted to the cloud report what they actually occupy, which can be far less than their size.
  • It deduplicates hardlinks. pnpm stores and Homebrew are full of them. A file with three names is counted once, and the space saved by deduplication is reported.
  • It skips the /System/Volumes/Data firmlink. On modern macOS that path leads back into the same data, and following it counts everything in your home folder twice.
  • It knows what developer junk is. node_modules, .next, .turbo, DerivedData, Pods and the Cargo, Gradle and Maven caches are grouped, sized and labelled with how to get each one back.
  • It never deletes anything itself. The CLI's --clean option writes a shell script for you to read and run. The decision stays with you.

How I checked it

Each rule above exists because the naive number was wrong in that specific case, and the README states them so they can be checked against du. A full scan of my home folder covered about 6.6 million files in roughly three minutes. That figure is from my notes at the time and I haven't re-measured it for this page.

Result

A finished app: diskscope.py is 934 lines, the Swift sources are 2,058 lines, and there's a built DiskScope-1.0.0.dmg, an app icon and a landing page, live at diskscope.vercel.app with the app to download. It's a small tool, but it's one I treated like a product.