A coding agent fills your disk faster than you do: node_modules in every project it sets up, Docker images it builds, Xcode DerivedData, Python environments, downloaded models. It is also good at finding them. What it should not do is guess with rm -r: one wrong path and a database or a project is gone.
The safer way is to give the agent a cleaner it can drive: one that knows which folders are rebuildable junk, skips what is in use, moves user files to the Trash and reports what it did. That is what the CleanMate command and its Agent Skill are for.
Which version has what
- Ubuntu: the
cm --jsoncommands, the Agent Skill and the rule thatcm --clean --yesnever removes Docker volumes or stopped containers are in CleanMate 2.2.0, available now. It also addscm --json lens,large,dupes,trashandrestore --list(below). - Mac: the
cleanmatecommand and its Agent Skill come with CleanMate 1.6. CleanMate 1.5 has the app only. From CleanMate 1.7,cleanmate restore --listalso lists launch agents removed in Login Items, andcleanmate restoreputs them back.
The commands below are the ones those versions use.
The commands
On a Mac, the command is inside the app: /Applications/CleanMate.app/Contents/Helpers/cleanmate. Link it into a folder on your PATH, or install CleanMate with brew install --cask homielab/tap/cleanmate, which does it for you.
cleanmate scan --json # what Smart Scan finds, no privacy items
cleanmate scan --json --group dev,ai # only some groups
cleanmate clean --dry-run --json --only user-caches,xcode-derived-data # preview, deletes nothing
cleanmate clean --yes --json --only user-caches,xcode-derived-data # clean those items
cleanmate restore --list # what CleanMate moved to the Trash, Login Items included (1.7)
On Ubuntu, the command is cm (from the PPA or the .deb on Ubuntu 24.04 LTS, 26.04 LTS and 26.10, or the cleanmate.sh --install script on any Ubuntu):
cm --json scan # one JSON object per line, no privacy items
cm --json scan --only logs,dev # only some groups
cm --json --dry-run clean ID… # preview
cm --json clean ID… # clean, with Trash restore keys in the result
cm --json large --min 500000000 --limit 20 # biggest files (also lens, dupes)
cm --json trash PATH… # move confirmed paths to the Trash
cm --json restore --list # what CleanMate moved to the Trash, newest first
Each item in the JSON has an id, a size in bytes, whether it is pre-selected, whether it is deleted or moved to the Trash, whether it may hold your data, and whether it is locked because its app is running. Every clean is written to the activity log (on a Mac ~/Library/Logs/CleanMate/activity.log, also in the app’s Settings › Activity).
Install the Agent Skill
The skill is an open Agent Skill: a folder with a SKILL.md that tells the agent how to find the command, scan, show the result and clean. Install it with:
bunx skills add homielab/cleanmate-macos # Mac
bunx skills add homielab/cleanmate-linux # Ubuntu
Or copy the repository’s skills/cleanmate folder into your agent’s skills folder: ~/.claude/skills/ for Claude Code, .cursor/skills/ for Cursor. Then ask in plain words.
What a session looks like
You: My disk is almost full, clean it up.
Agent: (runs
cleanmate scan --json) Found 38.2 GB. Developer: Xcode DerivedData 21.4 GB, npm cache 3.1 GB. User: caches 6.0 GB. Not suggested: Docker volumes 4.5 GB (may hold data, 3 volumes), AI models 3.2 GB (not ticked). Locked: Chrome cache, Chrome is running. I suggest the ticked items: 30.5 GB. Go ahead?You: Yes, but keep the npm cache.
Agent: (runs
cleanmate clean --yes --json --only xcode-derived-data,user-caches) Freed 27.4 GB. Nothing went to the Trash. Skipped 2 files in use.
The rules the skill follows
- Scan first, and never clean something it has not shown you.
- Clean only after you confirm, and only the item ids you confirmed (
--onlyon a Mac, item ids on Ubuntu). - Suggest only the items CleanMate ticks by default. Unticked items (AI models,
node_modules, old Xcode versions) only when you name them. - Never clean Privacy items (browser history, cookies, recent items) unless you asked for privacy cleaning.
- Items that may hold data, Docker volumes and stopped Docker containers, are never suggested or added on its own. It cleans one only when you name it after seeing its volumes or containers:
cleanmate clean --yes --json --only docker-volumeson a Mac,cm --json clean docker_volumeson Ubuntu. A clean of everything ticked skips them. - Do not offer locked items: tell you which app to quit, then scan again.
- Use
--dry-runwhen unsure, and never delete files by hand instead. - Report what was freed, what is in the Trash, and every path that was skipped and why.
- Never install anything, and never run
cmas root (on Ubuntu, items that need root ask forsudoorpkexec).
Without a terminal, cleanmate clean deletes nothing unless --yes is passed (exit code 4), so an agent cannot clean by accident.
Compared with CleanMyMac CLI
MacPaw makes CleanMyMac CLI, a terminal tool separate from the CleanMyMac app, which also cleans developer caches, project build folders and AI tool data (from MacPaw’s website, October 2026). CleanMate’s command is part of the app, uses the same items, Exclusions and safety checks as Smart Scan, is free and open source, runs on Ubuntu too, and comes with an open Agent Skill. See the comparison for more.
FAQ
Can the agent delete my projects? The command only touches the items CleanMate knows, with their safety checks. Project build folders and node_modules are listed only for projects idle for a while, are not ticked, and on a Mac go to the Trash.
Does it need Full Disk Access on a Mac? No, but without it folders macOS protects are skipped. The access belongs to the app running the command (Terminal, iTerm or your agent’s app), not to CleanMate.
Does it send anything to the network? No. The command never connects to the network.
For what each cleaned item is, see free up disk space as a developer on a Mac, on Ubuntu and Docker disk space. Every command, option and exit code is in the command line reference. They are also on the feature pages: macOS, Ubuntu.
