One of the things I find interesting about the tools we use to manage disk space is that, for the most part, they solve the problem of finding where our storage went, but leave us with the problem of figuring out what we can actually remove.

As a software engineer, there are quite a few things that accumulate on my machine over time. Build artifacts from Rust projects, Python virtual environments, JavaScript dependencies, repositories I haven't worked on in months, and different types of caches.

Some of these things can be recreated, others are still relevant, and some might contain work that doesn't exist anywhere else.

Knowing how much space they consume is useful, but I think there is more information we could use to make that decision.

This is what I wanted to explore with attic, an open-source disk explorer for macOS written in Rust.

Finding what takes up disk space with attic

Understanding what is consuming disk space

One of the decisions I made early on was to separate the process of collecting filesystem information from the interface used to explore it.

I didn't want to wait for a filesystem scan every time I opened the application, particularly considering how much data a development machine can accumulate.

attic runs a background service that maintains information about the filesystem. Once the initial scan is complete, the service uses filesystem events to keep that information up to date.

The terminal interface allows you to navigate directories, see how storage is distributed, and sort the information by size or last usage.

This by itself is not particularly different from what other disk explorers offer. Where I wanted to take it further was in how we use that information.

Identifying cleanup candidates

Consider the following example:

Directory Size Last used
Current project 25 GB Today
Rust build artifacts 12 GB 5 months ago
JavaScript dependencies 8 GB 3 months ago
Python virtual environment 4 GB 7 months ago

These are hypothetical numbers, but probably not that far from what many of us have on our machines.

If we sort everything by size, the current project is the first result. However, the other three directories are probably more relevant if what we are trying to do is recover disk space.

attic uses both size and last usage to identify potential cleanup candidates.

There is another consideration here. If a Rust project consumes 15 GB, but 13 GB of that comes from its target/ directory, recommending the entire project for cleanup doesn't make much sense.

We can recover most of that space without touching the source code.

attic tries to identify these situations and recognizes some of the artifacts commonly generated by development tools, including:

  • Rust target/ directories.
  • JavaScript node_modules/ directories.
  • Python virtual environments.
  • Different types of caches.

These are identified as rebuildable artifacts, which provides some additional context when reviewing the recommendations.

The terminal interface has a separate view for cleanup candidates that can be accessed without navigating through the entire filesystem.

Reviewing cleanup recommendations and safely moving items to the Trash

There is still quite a bit of room to improve how these recommendations are generated, particularly when considering different development ecosystems and how people organize their workspaces.

Git repositories are an interesting case

Something I wanted to consider when building attic was what happens when a cleanup candidate is a Git repository.

A repository might not have been used in six months, consume several gigabytes, and still contain changes that were never committed or pushed.

Looking at filesystem metadata alone wouldn't necessarily tell us that.

attic checks for these conditions and displays a warning when a repository contains uncommitted or unpushed work. Removing one of these repositories requires an additional confirmation.

attic warns before removing Git repositories containing uncommitted or unpushed work

There are similar considerations for recently used files and certain macOS libraries.

When removing something through attic, the operation is performed through Finder and the item is moved to the Trash. This also allows you to use Finder's Put Back functionality if needed.

Of course, these checks don't guarantee that something is safe to remove. There will always be information about a file or directory that the application doesn't have.

The final decision remains with the user.

Making use of the background service

Since attic already maintains information about disk usage, it seemed reasonable to use that information to identify when it might be worth doing some cleanup.

I don't necessarily need to know every time something changes on my filesystem, but knowing that there are several gigabytes of potentially recoverable space is useful.

By default, attic can generate a macOS notification when the estimated recoverable space reaches 5 GB and has increased sufficiently since the previous notification or cleanup.

attic notices cleanup opportunities in the background and sends a macOS notification

The threshold and frequency of these notifications can be configured, or notifications can be disabled entirely.

One thing worth clarifying is that the background service doesn't remove anything. Its responsibility is to maintain filesystem information, identify candidates, and notify the user when appropriate.

Some considerations around the implementation

attic is written in Rust and consists of two components distributed through the same binary: a background service and a terminal interface.

The background service is managed through launchd and is responsible for the initial scan, processing filesystem events, maintaining the local index, and generating cleanup recommendations.

One of the more interesting aspects of this implementation is handling filesystem changes in development environments.

Consider what happens when we run something like:

cargo build 

Or:

npm install 

Both operations can generate a considerable number of filesystem events in a relatively short period of time.

Processing every event independently and immediately rescanning the affected directories would introduce unnecessary work, particularly when the directories are still being modified.

Instead, attic allows changes to settle before rescanning the affected directories.

The filesystem information is persisted locally, which means the terminal interface can consume the existing information rather than initiating a new scan every time it is opened.

Closing the interface doesn't interrupt the monitoring process either.

There are some interesting trade-offs between how quickly the information should be updated and how much work the background service should perform. A disk management tool should not become another source of unnecessary resource consumption.

This is something I would like to continue evaluating across different machines, filesystem sizes, and development workloads.

Everything runs locally

Considering the type of information attic collects, I didn't see a reason for any of it to leave the machine.

The application makes no network requests. The filesystem index, configuration, recommendations, and processing all remain local.

There is no external backend or telemetry.

Installing attic

You can install attic through Homebrew:

brew tap sergiommarcial/attic brew trust sergiommarcial/attic brew install sergiommarcial/attic/attic brew services start attic 

Once installed, you can open the terminal interface with:

attic 

To check the status of the background service:

attic status 

The first scan might take a few minutes, depending on your filesystem.

You might also want to grant Full Disk Access to the attic binary and restart the service. macOS restricts access to certain directories, so without this permission, some of the filesystem information will be incomplete.

The application reports directories it couldn't access.

Configuration

Most of the behavior can be configured through a TOML file located at:

~/.config/attic/config.toml 

For example:

roots = [] excludes = [] min_file_size = "500MB" notify_threshold = "5GB" notify_max_per_day = 1 

You can configure which locations to scan, which directories to exclude, the minimum size of cleanup candidates, and how notifications should behave.

Additional configuration options are documented in the repository.

A few things to keep in mind

The amount of recoverable space reported by attic is an estimate.

Moving something to the Trash doesn't immediately release that storage, and things like Time Machine local snapshots can also affect when macOS actually reclaims the space.

There are also limitations to what we can infer from filesystem metadata. Last usage, for example, is useful information, but it doesn't necessarily tell us whether something will be needed again.

These are some of the reasons I wanted to keep cleanup recommendations separate from the actual cleanup operation.

What's next?

There are several things I would like to explore further with attic, particularly around how cleanup candidates are identified and how much context we can provide about them.

I'm also interested in understanding what other developers would consider relevant when managing disk space. Different languages, build systems, container runtimes, and development environments generate different types of artifacts, and there are probably quite a few cases I haven't considered yet.

attic is open source under the MIT license.

If you use macOS, give it a try and let me know what you think. I'm particularly interested in what it identifies on your machine, what it misses, and what you think it shouldn't be recommending in the first place.

Out of curiosity, what usually ends up consuming the most space on your development machine?

For those interested in the implementation or contributing to the project, the code and documentation are available here:

https://github.com/sergiommarcial/attic