Documentation

1

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-cleanup

Prefer plain text? A subcommand never opens the interface:

bash

macos-cleanup scan

Read the full user guide →

Update, 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-self

Coming 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 --preview

To 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 uninstall
2

User 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,npm

The interface has seven tabs, reached with the keys 1 to 7. The bottom line always lists the keys that work right now.

#TabMeaning
1DashboardScan, 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.
2CategoriesEvery category with its tier, mode and size, and a mark for what can be undone. Choose what to clean.
3QuarantineRestore 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.
4HistoryPast runs and their reports. Apply a recent plan.
5SettingsSafety limits, rules, retention, schedule, language and look. Colours follow your terminal unless you pick dark or light.
6DiagnosticsHealth checks, Full Disk Access and a preview of the 3.x migration.
7HelpKeys, 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.

TierMeaning
regenerableRebuilt 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.
reviewCostly to rebuild or visible to you. Each one needs your consent in the session and is never part of an automatic run.
reportMeasured 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 --apply

In 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 remove

Settings 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.

3

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 points

An 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.

StepWhat it doesChanges your files
PreflightChecks settings, categories, Full Disk Access and free space, and takes the lock so only one run changes files at a time.No
ScanMeasures every selected category. Nothing is changed.No
PlanDecides what happens to each item: move it to quarantine, run a native tool, report it only, or skip it with a reason.No
CleanActs only on what you approved. Each item is checked again just before it is touched.Yes
VerifyReads free space again and compares the measured change with the estimate.No
ReportWrites 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 --unusable

Unusable 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.

4

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.

RequirementNotes
PlatformOfficial 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 × 12At least 40 columns by 12 rows. Without a terminal you get plain text.
NetworkOnly to install, and to check for or fetch an update when you ask. The tool itself never uses the network.

Cleanup categories

Tier and categoriesUndo
Regenerable: app-caches, xcode-derived, npx, gradle, cocoapods, cargo, swift-pm, bundler, composerrestorable
Regenerable: npm, yarn, pnpm, pippermanent (native tool)
Review: trash, user-caches, app-caches-review, user-logs, diagnostic-reports, device-support, pnpm-stale, ios-backups, installersrestorable
Review: system-logs, tmppermanent, and only in permanent mode
Review: simulators, sim-runtimes, brew, gem, docker, tm-snapshotspermanent (native tool)
Report only: system-caches, xcode-archives, maven, android-avd, app-leftovers, browser-caches, browser-data, mail-data, mail-downloadsnot 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 --json

Without 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.

5

Developer Guide

Development Setup

Clone

bash

git clone https://github.com/KasprowiczM/macos_cleanup.git
cd macos_cleanup

Dependencies

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.

CodeMeaning / Contract
0Done
1The run finished but something failed, or a restore or purge could not complete every entry
2Wrong usage, refused option combination, invalid setting, refused plan, or --tui without a terminal
3This macOS version is not supported
130Interrupted

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

LanguageStyle
Bashshellcheck, Bash 3.2 compatibility
PythonPython 3.9+, standard library only (no pip dependencies)
MarkdownClear, scannable

Pull Request Workflow

  1. Find or open an Issue before significant work
  2. Branch from main: git checkout -b feat/your-feature
  3. Conventional commits: feat(scope): summary
  4. Run the test suite and the release checks before pushing
  5. 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])
6

FAQ

Frequently Asked Questions

Moving files into quarantine frees no space until you purge the run ('macos-cleanup quarantine purge <run> --apply'). Local snapshots can also hold deleted blocks, APFS clones share blocks, and APFS returns space late. After a run, the result shows 'estimated' and 'measured' space separately and says why they differ. Check purgeable space with 'diskutil info /System/Volumes/Data | grep -i Purgeable'.

For the full technical documentation, see the docs/ directory on GitHub →

Visual era: 2026