All projects

unbloat

A terminal tool that gets disk space back from WSL and Docker Desktop on Windows, and says what each step costs before it runs any of them.

Role
Design and build
Client
Personal project
Year
2026
Stack
Tool
Go, Bubble Tea, Lip Gloss
Windows
WSL, Optimize-VHD, diskpart, golang.org/x/sys
Release
GitHub Actions, GitHub Releases

Clearing 15.2 GB freed nothing on C:

I kept running out of space on C: because of WSL, Windows’ way of running Linux, and Docker Desktop, which runs containers on top of it. Deleting files inside them doesn’t give C: anything back. One time C: was at 98%, and clearing 15.2 GB of caches didn’t move it. Getting the space back by hand is slow and easy to get wrong. It’s a common problem, too: WSL’s issue asking for that space to come back on its own has been open since 2019.

One checklist, every cost written beside it

WSL and Docker Desktop keep everything in virtual disk files on C:, and those files don’t shrink on their own. Space cleared inside one takes 2 more steps to reach C:. A trim marks what’s free, and it has to run from the disk’s own distro, the Linux install that uses it. Compacting then gives that space back to C:, and it means stopping Docker Desktop and shutting WSL down. With the trim in the wrong distro, little comes back: compacting Docker’s disk after a trim in Ubuntu returned 0.9 GB, and 7.6 GB after a trim in its own.

unbloat scans first. The scan changes nothing and doesn’t start a distro that’s stopped. Then it shows one checklist: npm, npx, pip and pnpm caches inside each running distro, Docker’s build cache and unused images, old files in %TEMP% and the package managers’ caches on Windows, and each virtual disk with its file size and how much of it is in use. Caches start ticked. Images and disks start unticked, with their cost written beside them, such as closing every WSL window.

unbloat's checklist in a terminal, light text on black. The top line reads 'C: 21.7 GB free of 236.9 GB'. Under 'Caches on Windows', a ticked 708 MB pnpm store, unreferenced packages only, noted 'how much it frees is only known after it runs'. Under 'Caches inside WSL (Ubuntu)', a ticked npm cache of 170 MB and npx cache of 22 MB, each noted 'rebuilt on the next install', and a ticked 3.7 GB pnpm store. Under Docker, an unticked 4.3 GB of images no container uses, noted 'downloaded again when needed', then 'Volumes are kept, 4.0 GB': 7 named, with the example name covered by a grey bar, and 28 anonymous, which may hold database data. Under Disks, 2 unticked items: Compact Ubuntu, a 29.8 GB file with 21.1 GB in use, and Compact Docker, a 16.7 GB file with 13.5 GB in use, each noted 'closes every WSL window and stops Docker Desktop'. At the bottom, 192 MB freed inside WSL and Docker, which reaches C: only after compacting, and 0 B freed on C: by this run, then the keys: space to tick, enter to review, c to review with commands, q to quit.
Every item says what it costs before anything runs. Space freed inside WSL and Docker gets its own total, because it only reaches C: once a disk is compacted. The grey bar covers a volume's name.

Docker volumes, where containers keep their data, are never offered. A database’s volume can look just like an unused one, and the official Postgres image keeps its data in an anonymous volume unless it’s given a name.

The same checklist with Docker Desktop stopped. The caches are listed as before. Under Docker, a single line: 'Docker Desktop is not running', with a note to start it and run unbloat again to include its build cache, images and disk. Under Disks, only 'Compact Ubuntu' is offered, a 29.8 GB file with 21.0 GB in use.
With Docker Desktop stopped, the Docker items and its disk drop out, and the checklist says how to bring them back.

Before it runs, it lists every step in order and can show the exact commands. Every command and its output goes to a log, and the summary says how much each compaction returned.

The same order, whatever gets ticked

One order, whatever gets ticked. Caches first, then Docker’s build cache, then a trim inside each disk’s own distro while everything is still running. Then Docker Desktop stops, WSL shuts down, each disk is checked for anything still holding it, and it’s compacted: with Optimize-VHD where Windows has it, and with diskpart and the disk attached read-only on Windows Home. A disk whose trim failed isn’t compacted, and if no trim worked, nothing shuts down.

Checks before the shutdown. With a disk ticked, the run won’t start if unbloat was launched from inside WSL, since shutting WSL down would end unbloat too. It spots that by finding wsl.exe among its own parent processes. Being on battery below 50% blocks the run as well, and an unknown power state counts as battery. If Docker Desktop won’t stop, WSL is left running.

safety check refuses if started from WSL or on battery below 50% WSL and Docker running clear caches Docker's build cache trim each disk inside its own distro if a trim worked stop Docker Desktop then shut WSL down if both stopped WSL and Docker stopped check each disk isn't in use compact each disk if its own trim worked
Clearing and trimming happen while WSL and Docker are running, and compacting waits until both have stopped. The safety check only comes up when a disk is ticked.

Ctrl+C stops the run before its next step. A step that has already started finishes. Every command also runs in its own hidden console, so an interrupt in unbloat’s window never reaches a diskpart that’s partway through a compaction.

One runner for every command. Every command goes through it, so the tests replay output recorded on a real machine: wsl.exe listings in UTF-16, the WSL registry read as JSON, docker system df and df. CI runs them on Linux and Windows and builds executables for amd64 and arm64, and a tag publishes both with checksums. GitHub’s Windows runners can’t run WSL 2, so the full run was checked by hand on a real machine.