CleanMate

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

With 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

CommandWhat it prints or doesChanges 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 --versionThe app’s version.No
cleanmate --helpUsage, options, Undo, Full Disk Access and exit codes.No

Ubuntu: cm

CommandWhat it prints or doesChanges things
cmOpens the terminal app.No
cm --guiOpens 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-runWith any command: shows what would happen and deletes nothing.No
cm --autoWhat automatic cleaning runs: user, developer and AI cache junk, then a desktop notification.Yes
cm --checkThe daily check: notifies when / is almost full or no scan ran for a while. Cleans nothing.No
cm --json scan --only logs,devThe 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 placesWhere 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 --versionThe version and the system details a bug report needs.No
cm --helpAll 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

Safety

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

CodeMeaning
0OK, also when some items or files were skipped.
1Error.
2Invalid 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.
3No Full Disk Access with --require-fda, or space, large, dupes or similar asked for a folder macOS protects without it.
4clean, trash, uninstall APP, privacy --erase or login-items remove without --yes and without a terminal: nothing was deleted or moved.
5uninstall: the app is open, or did not quit with --quit. Nothing was moved.

Ubuntu: cm --scan, --clean and --auto

CodeMeaning
0Everything asked was done (JSON: "status":"ok").
1A task failed (JSON: "status":"failed").
2Wrong option or argument.
3Partly 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-macos
bunx skills add homielab/cleanmate-linux

Then ask in plain words, for example:

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