Swab the deck.

Swab is an open source command and menu bar app for macOS. It frees disk space and memory, and quits the apps you left open.

$ swab clean --dry-run
CATEGORY SIZE CONTENTS
app-caches 403 MB ~/Library/Caches, except Apple and iCloud
dev-caches 4 KB npm, yarn, bun, uv, pip, Gradle, Cargo, Homebrew
xcode 0 B DerivedData, simulator caches, previews
logs 127 KB ~/Library/Logs
docker not running Build cache and images no container uses
old-versions 0 B Old Codex and cursor-agent releases
claude-temp 0 B Closed sessions in /private/tmp
Total 403 MB
 
Off by default, add them with --all or by name
tool-downloads 0 B Hugging Face, Playwright and Puppeteer downloads
trash 0 B
system-queue unknown /private/var/dirs_cleaner, needs the admin password
 
Nothing was deleted. This was a dry run.

A Mac used for development fills up on its own. Xcode leaves DerivedData behind, every package manager keeps a cache, and the app you opened on Monday still holds memory on Friday. All of it can go.

Five commands. A menu bar app comes with them.

Runs in your terminal

Color and progress lines show only in a terminal. A pipe gets plain text, and Swab respects NO_COLOR.

Opens from the menu bar

Swab.app shows the same numbers as swab status, with a chart of the last minute. Clean up or free memory with a click. This one works. Try it.

The Swab panel, open from the menu bar.

Frees disk space and memory

swab clean deletes caches, logs and Docker leftovers that get rebuilt. swab purge flushes the file cache from memory.

Cleaned by default

  • app-caches
  • dev-caches
  • xcode
  • logs
  • docker
  • old-versions
  • claude-temp

Only when you name them

  • tool-downloads
  • trash
  • system-queue

Quits the apps you left open

Two rules, both off until you turn them on. Apps quit the way Command-Q quits them. Swab never force quits.

Quit an app that has not been in front for

$ swab unused after 8h

Quit an app when its last window closes

$ swab unused last-window on

Prints JSON for scripts

Every command takes --json. A command that deletes takes --dry-run, and will not run unattended without --yes.

swab status --json | jq .disk.freeBytes
swab clean xcode logs --yes
# exit status: 0 done, 1 failed, 2 wrong usage, 3 cancelled

Installs with Homebrew

For macOS 14 or later, on Apple silicon and Intel. The cask installs Swab.app and the swab command. Or take the disk image and drag Swab to Applications.

Download Swab.dmg
$ brew tap jxnxts/swab https://github.com/jxnxts/swab
$ brew install --cask jxnxts/swab/swab

Ships under MIT

The command and the app are in one repository, written from scratch in Swift with ideas from Stats, PureMac and MagicQuit. Bug reports and pull requests are welcome.

Read the source on GitHub

What Swab never deletes

Swab deletes what is inside the folders of its catalog and nothing else. It does not follow symbolic links, and it stays out of these.

  • Documents
  • Desktop
  • Downloads
  • Pictures
  • Movies
  • Music
  • iCloud Drive
  • Application Support
  • Containers
  • Preferences
  • Keychains
  • ~/.ssh
  • ~/.aws
  • ~/.gnupg
  • ~/.kube
  • ~/.docker
  • ~/.claude
  • ~/.config
  • ~/.nvm

Asks before it deletes

swab clean prints a table with the sizes and asks once. What it deletes does not go to the Trash.

Removes what gets rebuilt

The default categories hold files that tools rebuild or download again. The cost is time. The next Xcode build starts from zero.

Tests its own rules

The rules are in Safety.swift, and the tests for them in SafetyTests.swift.

Questions about Swab

Not answered here? Ask in an issue

Why does Swab ask for my password?

Two things need root: swab purge, because the purge tool in macOS does, and the system-queue category, because only root can read that folder. Nothing else asks.

Can I undo a cleanup?

No. Swab deletes the files and does not move them to the Trash. The default categories hold files that apps and tools rebuild, and swab clean --dry-run lists them without deleting any.

How much space does a cleanup free?

It depends on the Mac. swab clean --dry-run measures yours and deletes nothing. The dry run at the top of this page is real output, recorded on a build machine, and it found 403 MB.

Does Swab uninstall apps or delete node_modules?

No. Swab does not uninstall apps, and it does not look inside your projects. It cleans the folders of its catalog, such as the npm cache in your home folder, and leaves the node_modules of a project alone.

macOS says it cannot verify Swab. What now?

Swab.app is not notarized by Apple yet, so macOS stops it the first time. Open Swab once, then go to System Settings, Privacy & Security, and choose Open Anyway. You do this once.

Can I install only the command?

Yes. Tap the repository, then run brew install jxnxts/swab/swab, without --cask. Homebrew builds the command on your Mac, so it needs the Xcode Command Line Tools, and macOS has nothing to verify.

Does a purge make my Mac faster?

Usually not. macOS gives the file cache back on its own when an app needs memory. A purge helps right before a job that needs a lot of memory at once.

Why is an unused app still open?

Swab.app does the quitting, so it has to be running in the menu bar. The app in front never counts as unused. An app with unsaved changes asks you to save, and stays open until you answer. The last-window rule counts windows, and macOS asks you to allow that under Privacy & Security, Accessibility.

Which apps does Swab leave alone?

Finder, and anything that has no Dock icon. Music, Spotify, Podcasts and VLC start out excluded from the last-window rule, because they keep playing with no window open.

Does Swab send anything over the network?

No. Swab has no network code. It runs local tools such as docker and brew, which may use the network themselves.

Does it run on Linux?

No. Swab reads macOS and nothing else.