CleanMate

All guides · macOS and Ubuntu · Updated

Let an AI agent clean your disk on Mac and Ubuntu: Claude Code, Codex and Cursor with the CleanMate command and Agent Skill

How to let Claude Code, Codex, Cursor or another AI agent free up disk space safely on a Mac or on Ubuntu: the cleanmate and cm commands, the open Agent Skill, the rules it follows, and which CleanMate version has what.

Download for macOS · Install on Ubuntu — free and open source

CleanMate on Ubuntu asking before it cleans, the same confirm step an AI agent goes through with the cleanmate command

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

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

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.

Skip the commands

CleanMate runs on both systems: pick yours.

Open source — star it on GitHub: CleanMate for macOS · CleanMate for Ubuntu

How CleanMate decides what is safe to remove →