CleanMate command line reference
CleanMate has a command for scripts and AI agents on both systems: cleanmate on macOS and cm on Ubuntu. Same items and safety rules as the app, machine-readable output with --json, and everything it moves goes to the Trash.
Install
macOS: the command is inside CleanMate.app. Settings › Integrations installs it with one button: a link in ~/.local/bin, no administrator password. Or link it yourself into a folder on your PATH (add the folder to PATH in your shell profile if it isn’t there):
mkdir -p ~/.local/bin
ln -s /Applications/CleanMate.app/Contents/Helpers/cleanmate ~/.local/bin/cleanmate
cleanmate --helpWith Homebrew: brew install --cask homielab/tap/cleanmate also puts cleanmate on your PATH.
Ubuntu: cm comes with the PPA, the .deb and the install script, so there is nothing more to install. Run cm --help to see every option. Install steps for each Ubuntu version are on the download page. Download page.
Commands
Commands that change something are marked. Names, descriptions and messages are always in English, whatever the app’s language, so scripts and agents can read them.
macOS: cleanmate
| Command | What it prints or does | Changes things |
|---|---|---|
cleanmate list [--json] [--privacy] | Every Smart Scan item: group, id, name, what it removes, ticked by default or not, deleted or moved to the Trash, whether it may hold data. | No |
cleanmate scan [--only ID,ID…] [--group G,G…] [--privacy] [--json] [--require-fda] | What Smart Scan would find now: items by group with their size, and the total ticked by default. | No |
cleanmate clean [--only ID,ID…] [--group G,G…] [--privacy] [--dry-run] [--yes] [--json] [--require-fda] | Scans again, then cleans. Per item: what was deleted, moved to the Trash or kept and why, then the totals. | Yes |
cleanmate space [PATH] [--limit N] [--json] | What fills a folder, like Space Lens: its children by size, biggest first, and the folder total. PATH defaults to your home folder. | No |
cleanmate large [--min-size SIZE] [--older-than DAYS] [--in PATH] [--limit N] [--json] | Large files, biggest first, with kind, last change and last use. | No |
cleanmate dupes [--min-size SIZE] [--in PATH] [--limit N] [--json] | Duplicate files of 1 MB or more: groups by space wasted, each copy with its last change and what removing it frees. | No |
cleanmate similar [PATH…] [--limit N] [--json] | Photos that look alike: groups by space to free, the one suggested to keep first. | No |
cleanmate trash [--yes] [--json] [--] PATH… | Moves exactly those files and folders to the Trash, with the safety rules of Space Lens. Nothing is deleted. | Yes |
cleanmate restore --list [--limit N] [--json] | The items CleanMate moved to the Trash that are still there, newest first. | No |
cleanmate restore [--json] [--] TRASHED… | Puts items back at their old place, named by their place in the Trash. Never overwrites. | Yes |
cleanmate uninstall [--leftovers] [--json] | The apps the Uninstaller lists, with the size of the app and of its data; with --leftovers, only the leftovers of apps already removed. | No |
cleanmate uninstall APP [--leftovers-only] [--quit] [--dry-run] [--yes] [--json] | Moves the app and its data in ~/Library to the Trash. Never touches an open app. | Yes |
cleanmate privacy [--json] | Privacy items per browser (history, cookies, form data), recent items and shell history, with their size. | No |
cleanmate privacy --erase [ID…] [--dry-run] [--yes] [--json] | Erases the items named, skipping a running browser. Erased traces can’t be put back. | Yes |
cleanmate login-items [--json] | Login items and launch agents: label, state, program, the app each belongs to, whether it can be removed. | No |
cleanmate login-items remove LABEL [--yes] [--json] | Moves one of your own login items to the Trash and stops it; restore puts it back. | Yes |
cleanmate --version | The app’s version. | No |
cleanmate --help | Usage, options, Undo, Full Disk Access and exit codes. | No |
Ubuntu: cm
| Command | What it prints or does | Changes things |
|---|---|---|
cm | Opens the terminal app. | No |
cm --gui | Opens the desktop app (Ubuntu 24.04 or newer). | No |
cm --scan [--only LIST] | Prints what a Smart Scan finds. LIST: system, logs, user, browser, apps, ai, models, dev, privacy (privacy only when named). | No |
cm --clean [--yes] [--only LIST] | Smart Scan, then cleans the selected items; asks once unless you pass --yes. | Yes |
cm --dry-run | With any command: shows what would happen and deletes nothing. | No |
cm --auto | What automatic cleaning runs: user, developer and AI cache junk, then a desktop notification. | Yes |
cm --check | The daily check: notifies when / is almost full or no scan ran for a while. Cleans nothing. | No |
cm --json scan --only logs,dev | The scan as JSON: items with id, category, label, bytes, locked, root, trash and data_loss. | No |
cm --json clean ID… | Cleans the items named: task events, then freed bytes and the Trash restore keys. Add --dry-run to preview. | Yes |
cm --json lens [--path DIR] [--limit N] | One folder, biggest first. movable: false means look only, and reason says why. | No |
cm --json places | Where Space Lens can start: home, the system disk, other disks. | No |
cm --json large [--min BYTES] [--days N] [--path DIR] [--limit N] [--all-drives] | Big files: path, bytes, kind, mtime and atime; --days keeps files neither changed nor opened for N days. | No |
cm --json dupes [--min BYTES] [--path DIR] [--limit N] | Groups of identical files, newest copy first. | No |
cm --json trash [--home-only] PATH… | Moves the paths you confirmed to the Trash. One task line per path with a restore key, or the reason it was refused. | Yes |
cm restore --list [--limit N] [--gone DAYS] | What CleanMate moved to the Trash and is still there, newest first; --gone also lists what has left the Trash since. | No |
cm --json restore KEY… | Puts Trash items back, by the keys from trash or restore --list. | Yes |
cm --version | The version and the system details a bug report needs. | No |
cm --help | All options. | No |
Run cleanmate --help or cm --help for every option.
Machine-readable output: --json
On macOS, --json prints one JSON object, with sizes in bytes. A failed command prints {"error": {"code", "message"}}. For example cleanmate restore --list --json:
{
"count" : 2,
"items" : [
{ "date" : "2026-11-02T09:41:12+07:00", "kind" : "file", "path" : "/Users/me/Downloads/trip copy.mov", "size" : 1200000000, "source" : "Command Line", "trashed" : "/Users/me/.Trash/trip copy.mov" },
{ "date" : "2026-11-01T18:03:55+07:00", "kind" : "folder", "path" : "/Users/me/Projects/old-app", "size" : 734003200, "source" : "Space Lens", "trashed" : "/Users/me/.Trash/old-app" }
],
"version" : "1.12"
}On Ubuntu, put --json before the command: cm --json CMD prints one JSON object per line and nothing else, ending with a done event. cm --json clean streams task events (state run, ok, skip or fail), then done with the freed bytes and the Trash restore keys.
Preview with --dry-run
- cleanmate clean --dry-run prints the same report as a clean, deletes nothing and logs nothing. On Ubuntu, --dry-run works with every command.
- Without a terminal (scripts, AI agents), the macOS commands that change something delete or move nothing and exit with code 4 unless you pass --yes.
Safety
- --yes skips what may hold your data. On macOS, Docker volumes and stopped containers are cleaned only when named with --only; on Ubuntu, cm --clean --yes never removes them, and cm --json clean docker_volumes cleans them by name.
- Files you own go to the Trash. Only junk that apps rebuild, such as caches and logs, is deleted for good, and macOS privacy erasing can’t be undone.
- On macOS the command never asks for a password, never connects to the network and changes no setting. Full Disk Access belongs to the app that runs it (Terminal, iTerm, your agent’s app): without it, folders macOS protects are skipped, and --require-fda exits with code 3 instead.
- On Ubuntu, system items such as the APT cache, the journal and old kernels need sudo. Without it they are left out and the exit code is 3.
Restore what was moved to the Trash
On macOS, cleanmate restore --list shows what CleanMate moved to the Trash and is still there, from the command, Smart Scan, Space Lens and the other modules. cleanmate restore TRASHED… puts items back at their old place when nothing is there now.
On Ubuntu, cm restore --list shows the same, newest first; cm --json restore KEY… puts items back by the keys it prints.
Step by step, with the Finder and Files app: restore files CleanMate moved to the Trash
Exit codes
macOS: cleanmate
| Code | Meaning |
|---|---|
0 | OK, also when some items or files were skipped. |
1 | Error. |
2 | Invalid arguments, a PATH that does not exist, is not a folder or can’t be read, or no app, Privacy item or login item by that name. |
3 | No Full Disk Access with --require-fda, or space, large, dupes or similar asked for a folder macOS protects without it. |
4 | clean, trash, uninstall APP, privacy --erase or login-items remove without --yes and without a terminal: nothing was deleted or moved. |
5 | uninstall: the app is open, or did not quit with --quit. Nothing was moved. |
Ubuntu: cm --scan, --clean and --auto
| Code | Meaning |
|---|---|
0 | Everything asked was done (JSON: "status":"ok"). |
1 | A task failed (JSON: "status":"failed"). |
2 | Wrong option or argument. |
3 | Partly done: system items were left out for want of sudo, or a scan timed out (JSON: "status":"partial"). |
cm --json commands exit 0 when they could answer; read status and each task’s state.
Agent Skill for AI agents
An open Agent Skill teaches Claude Code, Codex, Cursor and other agents to use the command: scan first, show you the result, clean only the items you confirmed, and move files to the Trash only with paths you named. It never installs anything and never deletes by hand. Install it with:
bunx skills add homielab/cleanmate-macosbunx skills add homielab/cleanmate-linuxThen ask in plain words, for example:
- Use cleanmate to show what takes space in my home folder, read-only.
- Scan with cleanmate and list what it would clean by group. Don’t clean anything yet.
- Find files over 1 GB that I haven’t opened for six months and show them to me before moving anything to the Trash.
The same skill can put back what it moved: ask it to list what CleanMate moved to the Trash and restore the items you pick.
More
Get CleanMate
Free and open source. Review every item before it is removed.
Open source — star it on GitHub: CleanMate for macOS · CleanMate for Ubuntu