Documentation
Getting Started
Overview
macOS Cleanup is a local tool for careful disk cleanup on macOS. It measures first, shows you a plan, and acts only on what you approve. Use it from a terminal interface or from plain commands.
Most removals go to a quarantine you can restore from. Native tool cleanups are permanent and say so. Protected paths such as Mail, Keychains and SSH/GPG keys are never touched, and the tool never uses sudo.
Readable and checkable
Shell and Python source with no compiled binaries. Releases ship with a checksum file that the installer verifies; they are not cryptographically signed.
macOS only
The tool is built for macOS and its developer tools. Apple Silicon with macOS 11 or later is the supported setup.
Installation
You need an Apple Silicon Mac with macOS 11 or later, Bash 3.2 (included with macOS) and Python 3.9 or later for the terminal interface. The installer downloads the release package, checks its SHA-256 checksum, installs the program and links the macos-cleanup command. It never uses sudo and never starts a cleanup. Read it before you run it. It links macos-cleanup and mac-cleanup, a shorter name for the same command, in ~/.local/bin, and tells you if another program on your PATH answers to either name.
bash
/bin/bash -c "$(curl -fsSL https://github.com/KasprowiczM/macOS_cleanup/releases/latest/download/install.sh)"Check your Mac first, then open the interface and press S to scan. A scan changes nothing.
bash
macos-cleanup doctor
macos-cleanupPrefer plain text? A subcommand never opens the interface:
bash
macos-cleanup scanUpdate, migrate, uninstall
Run the installer again to upgrade; only the program folder is replaced, and your settings, state and quarantine stay. You can also update on request. The tool uses the network only when you run these commands.
bash
macos-cleanup update-self --check
macos-cleanup update-selfComing from 3.x? Preview what would be copied into the new layout. migrate only copies and never deletes your old files.
bash
macos-cleanup migrate --previewTo remove the tool, preview first. It keeps your settings, state and quarantine unless you ask otherwise. It removes both command names, but only its own links, never another program's file.
bash
macos-cleanup uninstall --dry-run
macos-cleanup uninstallUser Guide
The interface and commands
Run macos-cleanup in a terminal to open the interface on the Dashboard. Press S to scan, P to preview what a cleanup would do, then C to clean the safe categories or X to clean the ones you selected. Scanning and previewing change nothing. The shorter name mac-cleanup is the same command and opens the same interface; --cli gives plain terminal mode.
terminal
# Open the interface (plain text when there is no terminal)
macos-cleanup
# Measure, change nothing
macos-cleanup scan
# Write a plan you can read
macos-cleanup plan
# Clean the categories set to auto, after one question
macos-cleanup clean --safe
# Clean exactly these categories
macos-cleanup clean --only trash,npmThe interface has seven tabs, reached with the keys 1 to 7. The bottom line always lists the keys that work right now.
| # | Tab | Meaning |
|---|---|---|
1 | Dashboard | Scan, Preview, Clean safe and Clean selected, with live progress for each step and the result of the last run. Clean safe acts on eligible categories in auto mode after confirmation. Quarantine is the default; permanent mode cannot be undone. |
2 | Categories | Every category with its tier, mode and size, and a mark for what can be undone. Choose what to clean. |
3 | Quarantine | Restore points with their age and size. Restore a whole run or selected items; an item whose place is taken is skipped, never overwritten. Purging a run asks you to type the last part of its id. |
4 | History | Past runs and their reports. Apply a recent plan. |
5 | Settings | Safety limits, rules, retention, schedule, language and look. Colours follow your terminal unless you pick dark or light. |
6 | Diagnostics | Health checks, Full Disk Access and a preview of the 3.x migration. |
7 | Help | Keys, tiers, paths and version. |
Tiers and modes
Every category has a tier, and the tier decides how the tool treats it. A mode (auto, review or skip) says whether it may be cleaned without asking.
| Tier | Meaning |
|---|---|
regenerable | Rebuilt by the owner of the data. Out of the box only caches of known apps run without a question; the other categories of this tier are offered for review until you set them to auto. |
review | Costly to rebuild or visible to you. Each one needs your consent in the session and is never part of an automatic run. |
report | Measured and explained, never removed by this tool. |
Modes: auto means a safe clean may include it, review means it is always asked about, and skip means it is never processed. Press m in the Categories tab to cycle them.
Every category also shows whether removal can be undone: restorable (moved to quarantine), permanent (a native tool such as npm, yarn, pnpm, pip, brew, gem, docker, xcrun simctl or tmutil, or permanent mode), or not removed (report only).
Quarantine (restore points)
Where the tool moves files itself, it moves them into a quarantine folder on the same disk and records what it moved. You can restore a whole run or only selected items; an item whose original place is taken is reported, never overwritten. Quarantine frees no space until you purge it, and purging is permanent.
terminal
# List restore points
macos-cleanup quarantine list
# Put the latest run back
macos-cleanup restore latest
# Preview a purge, then remove those runs for good
macos-cleanup quarantine purge latest
macos-cleanup quarantine purge latest --applyIn the Quarantine tab, mark items with Space and press r to restore them. With nothing marked, r restores the whole run. Either way you see a preview first.
Honest space accounting
Results show two numbers. Estimated is the sum of the sizes of the items processed, an upper bound. Measured is the change in free space, taken before and after the run when it can be measured. They often differ: quarantine frees nothing until you purge it, local snapshots keep deleted blocks, APFS clones share blocks, and APFS returns space late. The result card says which applies.
Automatic runs (opt-in)
Off by default, and the installer never turns them on. Enable them in Settings or with the commands below, which manage one macOS LaunchAgent. A scheduled run moves items of the regenerable tier whose mode is auto into quarantine (out of the box, caches of known apps) and purges quarantine runs past their retention period. It runs no native tool, nothing from the review tier, and never uses permanent mode.
terminal
macos-cleanup schedule install --time 10:30
macos-cleanup schedule status
macos-cleanup schedule removeSettings and files
Settings live in one file, settings.conf, which is read as plain data and never run. The interface and the command line use the same file. Category modes are saved in category-modes.tsv, excludes.txt lists paths to leave alone, and rules.local.yaml can only make the rules stricter.
Architecture
Architecture
Two faces, one engine: the terminal interface and the plain command line run the same Bash engine and show the same facts. The core is Bash 3.2; Python 3.9 or later drives the interface, plans and migrate. Nothing runs in the background unless you enable the automatic run.
Where files live
folders
~/.local/share/macos-cleanup program
~/.config/macos-cleanup settings and rules
~/.local/state/macos-cleanup logs, reports, plans, history
~/Library/Application Support/macOS_cleanup/quarantine restore pointsAn upgrade replaces only the program; settings, state and quarantine stay. Each folder can be moved with an absolute path in MACOS_CLEANUP_HOME, MACOS_CLEANUP_CONFIG_DIR, MACOS_CLEANUP_STATE_DIR or MACOS_CLEANUP_QUARANTINE_DIR. Quarantine must be on the same disk as your home folder.
The six steps of a run
Every run is a pipeline of steps, and the interface shows them with progress. Only Clean changes your files, and only what you approved. A restore or purge goes through the same steps, with the work done in Clean.
| Step | What it does | Changes your files |
|---|---|---|
| Preflight | Checks settings, categories, Full Disk Access and free space, and takes the lock so only one run changes files at a time. | No |
| Scan | Measures every selected category. Nothing is changed. | No |
| Plan | Decides what happens to each item: move it to quarantine, run a native tool, report it only, or skip it with a reason. | No |
| Clean | Acts only on what you approved. Each item is checked again just before it is touched. | Yes |
| Verify | Reads free space again and compares the measured change with the estimate. | No |
| Report | Writes the report and the run summary, and adds the run to History. | No |
A plan is signed and is accepted only on the Mac and for the user that wrote it, within 24 hours; apply refuses anything else.
One mutating run at a time
Runs that change files exclude each other, including a run of 3.x. A lock left behind by a crashed run is recovered automatically.
- Atomic lock: The lock is taken with an atomic mkdir, so two runs cannot both start.
- Stale lock recovery: If a run crashed, the recorded process is checked and the stale lock is released automatically.
Active build protection
Purging caches during a build can corrupt it. Before it touches selected caches, the tool checks whether their owner is running:
- Build tools such as Xcode, Gradle, Cargo, npm, pnpm and Composer are checked first.
- When the owner is running, the category is skipped with the reason in use.
Simulator runtimes (xcrun simctl)
Simulator runtimes live in a system-managed store, so the tool never removes them itself. It asks Apple's own command:
bash
xcrun simctl runtime delete --unusableUnusable runtimes are removed only when you pick them in an interactive run, never from a safe clean or an automatic run, and never while Xcode or Simulator is running. The step is permanent.
Native tools and APFS
Native tool cleanups (npm, yarn, pnpm, pip, brew, gem, docker, xcrun simctl, tmutil) run the vendor command and cannot be undone. Time Machine snapshot removal keeps the newest local snapshot of each volume. The protected list is matched without regard to letter case, as on a default APFS volume.
Platform Reference
Requirements
Version 4.0.5. Apple Silicon Macs running macOS 11 or later are the supported setup. Intel Macs are not blocked by the code but are outside official support.
| Requirement | Notes |
|---|---|
| Platform | Official support: Apple Silicon Macs running macOS 11 Big Sur through macOS 26+ Tahoe. |
| Bash 3.2+ | Included with macOS. |
| Python 3.9+ | Needed for the terminal interface, for plans (plan and apply) and for migrate. If it is missing, run xcode-select --install. |
| 40 × 12 | At least 40 columns by 12 rows. Without a terminal you get plain text. |
| Network | Only to install, and to check for or fetch an update when you ask. The tool itself never uses the network. |
Cleanup categories
| Tier and categories | Undo |
|---|---|
| Regenerable: app-caches, xcode-derived, npx, gradle, cocoapods, cargo, swift-pm, bundler, composer | restorable |
| Regenerable: npm, yarn, pnpm, pip | permanent (native tool) |
| Review: trash, user-caches, app-caches-review, user-logs, diagnostic-reports, device-support, pnpm-stale, ios-backups, installers | restorable |
| Review: system-logs, tmp | permanent, and only in permanent mode |
| Review: simulators, sim-runtimes, brew, gem, docker, tm-snapshots | permanent (native tool) |
| Report only: system-caches, xcode-archives, maven, android-avd, app-leftovers, browser-caches, browser-data, mail-data, mail-downloads | not removed |
39 categories in total. sim-runtimes, docker and tm-snapshots run only when you pick them in an interactive run.
Doctor and Full Disk Access
macos-cleanup doctor checks your paths, runtime, Full Disk Access, free space, local snapshots, Time Machine age, lock state, leftovers from 3.x and the automatic run. It changes nothing. mac-cleanup doctor works the same way.
bash
macos-cleanup doctor
macos-cleanup doctor --jsonWithout Full Disk Access some folders cannot be read, so a scan is marked partial and those sizes are lower bounds. The tool checks by listing the names in a few protected folders, never by reading file contents, and it never tries to get around the restriction. To grant it, open System Settings, then Privacy & Security, then Full Disk Access, add your terminal app and restart it. The grant is optional.
Developer Guide
Development Setup
Clone
bash
git clone https://github.com/KasprowiczM/macos_cleanup.git
cd macos_cleanupDependencies
The tool uses native Bash (3.2 or later) and Python 3.9 or later with the standard library only. No external packages are required.
Deterministic CLI Exit Codes
macOS Cleanup returns deterministic UNIX exit codes for scripts and for the automatic run.
| Code | Meaning / Contract |
|---|---|
0 | Done |
1 | The run finished but something failed, or a restore or purge could not complete every entry |
2 | Wrong usage, refused option combination, invalid setting, refused plan, or --tui without a terminal |
3 | This macOS version is not supported |
130 | Interrupted |
Safety contracts
Code contributions must keep these invariants:
- One mutating run at a time: Every subcommand that changes files takes the atomic lock before it touches the filesystem.
- Build guard: Rules that prune compiler caches (Xcode, Swift, Rust, Gradle) check for running toolchain processes first.
- One removal path: Removals go through safe_remove, and native tools run only with a validated target. Nothing deletes by another route.
- Consent: Consent comes only from flags, settings.conf and the interface's own dialogs, never from a stray environment variable.
Code Style
| Language | Style |
|---|---|
| Bash | shellcheck, Bash 3.2 compatibility |
| Python | Python 3.9+, standard library only (no pip dependencies) |
| Markdown | Clear, scannable |
Pull Request Workflow
- Find or open an Issue before significant work
- Branch from
main:git checkout -b feat/your-feature - Conventional commits:
feat(scope): summary - Run the test suite and the release checks before pushing
- Open a PR with a clear description and linked issue
Security
Do NOT file public GitHub Issues for security vulnerabilities. Use one of:
- Email — gaipro.mk@gmail.com (subject prefix
[macos_cleanup-security])
FAQ
Frequently Asked Questions
For the full technical documentation, see the docs/ directory on GitHub →