DEV Community

Cover image for Why I built my own CLI to clean Docker & Node garbage (instead of using CleanMyMac)
Aitor Santana Cabrera
Aitor Santana Cabrera

Posted on

Why I built my own CLI to clean Docker & Node garbage (instead of using CleanMyMac)

We've all been there. You are working on a feature, you try to build a Docker container, and suddenly:

Error: No space left on device

As developers, our hard drives are graveyards of abandoned node_modules, dangling Docker layers, 3-month-old Gradle caches, and NuGet packages from projects we haven't touched in years.

I tried using generic cleaners (like CleanMyMac), but they are great for clearing browser caches, not for understanding what a "stale Docker volume" is. I also found myself running random rm -rf snippets from StackOverflow, which—let's be honest—is terrifying on a production machine.

So, I decided to build my own tool. Meet DevSweep.

🧹 What is DevSweep?

DevSweep is a CLI tool specifically designed to clean developer artifacts. It doesn't care about your Spotify cache; it cares about the 20GB of build artifacts sitting in your library.

It currently supports cleaning:

  • 🐳 Docker: Dangling images, stopped containers, unused volumes.
  • 📦 Node.js: Recursively finds and deletes node_modules (with safety checks).
  • 🐘 Gradle & Maven: Cleans old caches and wrapper distributions.
  • 🔷 .NET: Cleans bin/obj folders and NuGet caches.

🛡️ The "Safety First" Philosophy (Why TDD?)

The biggest problem with cleaning scripts is trust.
"What if this script deletes my current project? What if it wipes my database?"

To solve this, I didn't just write a bash script; I engineered it.

  • TDD approach: The project has a suite of over 100+ tests. Every deletion logic is tested against mock directories before it ever touches your real files.
  • Dry Run: It comes with a verify mode to see exactly what will be deleted before you pull the trigger.
  • Scoped Targets: It looks for specific patterns (like a package.json sibling to node_modules) to avoid false positives.

🛠️ Under the Hood (Current & Future)

Currently, DevSweep is written in Bash.
Why? Because I wanted something that ran natively on any macOS/Linux machine without requiring the user to install a runtime, compile code, or manage dependencies. It's transparent: you can open the file and read the code.

However, I have big plans. 🚀

I am currently architecting DevSweep v2, which will be a complete rewrite in .NET 10 (Preview) with Native AOT.

  • Why .NET? To ship a single, self-contained, ultra-fast binary.
  • Better UI: I plan to integrate Spectre.Console to move from simple text output to a full TUI (Terminal User Interface) with progress bars and interactive selection.

🤝 Open Source & Feedback

I just released the first stable version on GitHub. It's still early days, and yes, I'm currently working on translating some comments in the code to English (thanks for the Reddit feedback!), but the logic is solid and tested.

I’d love for you to try it out, break it, or suggest new stacks to support (maybe Rust/Cargo? Xcode?).

🔗 Repository: github.com/Sstark97/devsweep

Let me know in the comments: What is the one folder on your machine that always eats up your space? 👇

Top comments (1)

Collapse
 
sstark97 profile image
Aitor Santana Cabrera

Hey everyone! OP here. I'm currently working on the v2 roadmap (moving to .NET). If you have any feature requests for the new TUI, let me know!