mole-mac-cleaner

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Mole Mac Cleaner

Mole Mac 清理工具

Skill by ara.so — Daily 2026 Skills collection.
Mole (
mo
) is an all-in-one macOS maintenance CLI that combines deep cleaning, smart app uninstallation, disk analysis, system optimization, live monitoring, and project artifact purging into a single binary.
来自ara.so的技能 — 2026每日技能合集。
Mole(
mo
)是一款一体化macOS维护CLI工具,将深度清理、智能应用卸载、磁盘分析、系统优化、实时监控和项目构建产物清理整合在一个二进制文件中。

Installation

安装

bash
undefined
bash
undefined

Via Homebrew (recommended)

通过Homebrew安装(推荐)

brew install mole
brew install mole

Via install script (supports version pinning)

通过安装脚本安装(支持固定版本)

Specific version

安装指定版本

Latest main branch (nightly)

安装最新主分支版本(夜间版)

Core Commands

核心命令

bash
mo                    # Interactive menu (arrow keys or vim h/j/k/l)
mo clean              # Deep system cache + browser + dev tool cleanup
mo uninstall          # Remove apps plus all hidden remnants
mo optimize           # Rebuild caches, reset network, refresh Finder/Dock
mo analyze            # Visual disk space explorer
mo status             # Live real-time system health dashboard
mo purge              # Remove project build artifacts (node_modules, target, dist)
mo installer          # Find and remove installer .dmg/.pkg files

mo touchid            # Configure Touch ID for sudo
mo completion         # Set up shell tab completion
mo update             # Update Mole
mo update --nightly   # Update to latest unreleased build (script install only)
mo remove             # Uninstall Mole itself
mo --help
mo --version
bash
mo                    # 交互式菜单(使用方向键或Vim的h/j/k/l键操作)
mo clean              # 清理系统缓存、浏览器缓存及开发工具缓存
mo uninstall          # 移除应用及其所有隐藏残留文件
mo optimize           # 重建缓存、重置网络、刷新Finder/Dock
mo analyze            # 可视化磁盘空间分析器
mo status             # 实时系统健康监控面板
mo purge              # 删除项目构建产物(node_modules、target、dist等)
mo installer          # 查找并移除安装包文件(.dmg/.pkg格式)

mo touchid            # 配置Touch ID用于sudo验证
mo completion         # 设置Shell自动补全
mo update             # 更新Mole
mo update --nightly   # 更新至最新未发布版本(仅支持脚本安装方式)
mo remove             # 卸载Mole本身
mo --help
mo --version

Safe Preview Before Deleting

删除前的安全预览

Always dry-run destructive commands first:
bash
mo clean --dry-run
mo uninstall --dry-run
mo purge --dry-run
执行破坏性命令前,请先进行试运行:
bash
mo clean --dry-run
mo uninstall --dry-run
mo purge --dry-run

Combine with debug for detailed output

结合debug参数查看详细输出

mo clean --dry-run --debug mo optimize --dry-run --debug
undefined
mo clean --dry-run --debug mo optimize --dry-run --debug
undefined

Key Command Details

关键命令详情

mo clean
— Deep Cleanup

mo clean
— 深度清理

Cleans user app caches, browser caches (Chrome, Safari, Firefox), developer tool caches (Xcode, Node.js, npm), system logs, temp files, app-specific caches (Spotify, Dropbox, Slack), and Trash.
bash
mo clean                  # Interactive cleanup
mo clean --dry-run        # Preview what would be removed
mo clean --whitelist      # Manage protected caches (exclude from cleanup)
Whitelist config lives at
~/.config/mole/
. Edit it to protect paths you want to keep.
清理用户应用缓存、浏览器缓存(Chrome、Safari、Firefox)、开发工具缓存(Xcode、Node.js、npm)、系统日志、临时文件、特定应用缓存(Spotify、Dropbox、Slack)以及废纸篓。
bash
mo clean                  # 交互式清理
mo clean --dry-run        # 预览将被删除的内容
mo clean --whitelist      # 管理受保护的缓存(排除在清理范围外)
白名单配置文件位于
~/.config/mole/
,可编辑该文件来保留你需要的路径。

mo uninstall
— Smart App Removal

mo uninstall
— 智能应用卸载

Finds apps, shows size and last-used date, then removes the app bundle plus all related files:
  • Application Support, Caches, Preferences
  • Logs, WebKit storage, Cookies
  • Extensions, Plugins, Launch Daemons
bash
mo uninstall              # Interactive multi-select list
mo uninstall --dry-run    # Preview removals
查找应用,显示应用大小和最后使用时间,然后移除应用包及其所有相关文件:
  • 应用支持文件、缓存、偏好设置
  • 日志、WebKit存储、Cookie
  • 扩展、插件、启动守护进程
bash
mo uninstall              # 交互式多选列表
mo uninstall --dry-run    # 预览将被移除的内容

mo optimize
— System Refresh

mo optimize
— 系统刷新

bash
mo optimize               # Run all optimizations
mo optimize --dry-run     # Preview
mo optimize --whitelist   # Exclude specific optimizations
Optimizations include:
  • Rebuild system databases and clear caches
  • Reset network services
  • Refresh Finder and Dock
  • Clean diagnostic and crash logs
  • Remove swap files and restart dynamic pager
  • Rebuild launch services and Spotlight index
bash
mo optimize               # 执行所有优化操作
mo optimize --dry-run     # 预览优化内容
mo optimize --whitelist   # 排除特定优化步骤
优化操作包括:
  • 重建系统数据库并清理缓存
  • 重置网络服务
  • 刷新Finder和Dock
  • 清理诊断和崩溃日志
  • 删除交换文件并重启动态分页器
  • 重建启动服务和Spotlight索引

mo analyze
— Disk Explorer

mo analyze
— 磁盘分析器

bash
mo analyze                # Analyze home directory (skips /Volumes by default)
mo analyze ~/Downloads    # Analyze specific path
mo analyze /Volumes       # Include external drives explicitly
bash
mo analyze                # 分析用户主目录(默认排除/Volumes目录)
mo analyze ~/Downloads    # 分析指定路径
mo analyze /Volumes       # 显式包含外部驱动器

Machine-readable output for scripting

生成机器可读的JSON输出用于脚本

mo analyze --json ~/Documents

**JSON output example:**
```json
{
  "path": "/Users/you/Documents",
  "entries": [
    { "name": "Library", "path": "...", "size": 80939438080, "is_dir": true }
  ],
  "total_size": 168393441280,
  "total_files": 42187
}
Navigator shortcuts inside
mo analyze
:
KeyAction
↑↓
or
j/k
Navigate list
←→
or
h/l
Go back / Enter directory
O
Open in Finder
F
Reveal in Finder
Move to Trash (via Finder, safer than direct delete)
L
Show large files
Q
Quit
mo analyze --json ~/Documents

**JSON输出示例:**
```json
{
  "path": "/Users/you/Documents",
  "entries": [
    { "name": "Library", "path": "...", "size": 80939438080, "is_dir": true }
  ],
  "total_size": 168393441280,
  "total_files": 42187
}
mo analyze
中的导航快捷键:
按键操作
↑↓
j/k
导航列表
←→
h/l
返回上级目录 / 进入子目录
O
在Finder中打开
F
在Finder中显示
移至废纸篓(通过Finder操作,比直接删除更安全)
L
显示大文件
Q
退出

mo status
— Live Dashboard

mo status
— 实时监控面板

bash
mo status                 # Real-time CPU, GPU, memory, disk, network, processes
mo status --json          # JSON output for scripting
mo status | jq '.health_score'   # Auto-detects pipe → outputs JSON
JSON output example:
json
{
  "host": "MacBook-Pro",
  "health_score": 92,
  "cpu": { "usage": 45.2, "logical_cpu": 8 },
  "memory": { "total": 25769803776, "used": 15049334784, "used_percent": 58.4 },
  "disks": [],
  "uptime": "3d 12h 45m"
}
Shortcuts inside
mo status
:
k
toggles the cat mascot,
q
quits.
bash
mo status                 # 实时显示CPU、GPU、内存、磁盘、网络、进程信息
mo status --json          # 输出JSON格式用于脚本
mo status | jq '.health_score'   # 自动检测管道输出,返回JSON格式
JSON输出示例:
json
{
  "host": "MacBook-Pro",
  "health_score": 92,
  "cpu": { "usage": 45.2, "logical_cpu": 8 },
  "memory": { "total": 25769803776, "used": 15049334784, "used_percent": 58.4 },
  "disks": [],
  "uptime": "3d 12h 45m"
}
mo status
中的快捷键:
k
切换猫咪吉祥物显示,
q
退出。

mo purge
— Project Artifact Cleanup

mo purge
— 项目构建产物清理

Scans for
node_modules
,
target
,
build
,
dist
,
venv
, and similar directories. Projects newer than 7 days are unselected by default.
bash
mo purge                  # Interactive multi-select
mo purge --dry-run        # Preview
mo purge --paths          # Configure custom scan directories
Configure custom scan paths (
~/.config/mole/purge_paths
):
~/Documents/MyProjects
~/Work/ClientA
~/Work/ClientB
When this file exists, Mole uses only those paths. Otherwise it defaults to
~/Projects
,
~/GitHub
,
~/dev
.
Install
fd
for faster scanning:
brew install fd
扫描
node_modules
target
build
dist
venv
等目录。默认不选择7天内的新项目。
bash
mo purge                  # 交互式多选
mo purge --dry-run        # 预览清理内容
mo purge --paths          # 配置自定义扫描目录
配置自定义扫描路径
~/.config/mole/purge_paths
):
~/Documents/MyProjects
~/Work/ClientA
~/Work/ClientB
当该文件存在时,Mole仅扫描这些路径;否则默认扫描
~/Projects
~/GitHub
~/dev
目录。
安装
fd
可提升扫描速度:
brew install fd

mo installer
— Installer File Cleanup

mo installer
— 安装包文件清理

bash
mo installer              # Find .dmg/.pkg files in Downloads, Desktop, Homebrew cache, iCloud, Mail
mo installer --dry-run    # Preview removals
bash
mo installer              # 在下载文件夹、桌面、Homebrew缓存、iCloud、邮件中查找.dmg/.pkg文件
mo installer --dry-run    # 预览将被移除的文件

Configuration Files

配置文件

All config lives in
~/.config/mole/
:
FilePurpose
purge_paths
Custom directories for
mo purge
to scan
operations.log
Log of all file operations
Disable operation logging:
bash
export MO_NO_OPLOG=1
mo clean
所有配置文件位于
~/.config/mole/
文件用途
purge_paths
配置
mo purge
命令的自定义扫描目录
operations.log
所有文件操作的日志记录
禁用操作日志:
bash
export MO_NO_OPLOG=1
mo clean

Shell Tab Completion

Shell 自动补全

bash
mo completion             # Interactive setup for bash/zsh/fish
bash
mo completion             # 为bash/zsh/fish交互式设置自动补全

Touch ID for sudo

为sudo启用Touch ID

bash
mo touchid                # Enable Touch ID authentication for sudo commands
mo touchid enable --dry-run
bash
mo touchid                # 为sudo命令启用Touch ID验证
mo touchid enable --dry-run

Scripting & Automation Patterns

脚本与自动化模式

Check disk health in a script

在脚本中检查磁盘健康状况

bash
#!/bin/bash
health=$(mo status --json | jq -r '.health_score')
if [ "$health" -lt 70 ]; then
  echo "Health score low: $health — running cleanup"
  mo clean --dry-run  # swap to `mo clean` when ready
fi
bash
#!/bin/bash
health=$(mo status --json | jq -r '.health_score')
if [ "$health" -lt 70 ]; then
  echo "健康分数较低:$health — 正在执行清理"
  mo clean --dry-run  # 准备就绪后替换为`mo clean`
fi

Get largest directories as JSON and process with jq

获取最大目录的JSON数据并使用jq处理

bash
mo analyze --json ~/Downloads | jq '.entries | sort_by(-.size) | .[0:5] | .[] | {name, size_gb: (.size / 1073741824 | . * 100 | round / 100)}'
bash
mo analyze --json ~/Downloads | jq '.entries | sort_by(-.size) | .[0:5] | .[] | {name, size_gb: (.size / 1073741824 | . * 100 | round / 100)}'

Automated project purge in CI teardown

CI环境中的自动化项目清理

bash
#!/bin/bash
bash
#!/bin/bash

Non-interactive purge of build artifacts after CI

CI结束后非交互式清理构建产物

MO_NO_OPLOG=1 mo purge --dry-run # always preview first in scripts
undefined
MO_NO_OPLOG=1 mo purge --dry-run # 脚本中请始终先预览
undefined

Raycast / Alfred quick launchers

Raycast / Alfred 快速启动

bash
curl -fsSL https://raw.githubusercontent.com/tw93/mole/main/install.sh | bash
bash
curl -fsSL https://raw.githubusercontent.com/tw93/mole/main/install.sh | bash

Then bind
mo clean
,
mo status
,
mo analyze
as script commands in Raycast

然后在Raycast中绑定
mo clean
mo status
mo analyze
作为脚本命令

undefined
undefined

Safety Boundaries

安全边界

  • mo analyze
    moves files to Trash via Finder (recoverable) instead of direct deletion — prefer it for ad hoc cleanup
  • clean
    ,
    uninstall
    ,
    purge
    ,
    installer
    , and
    remove
    are permanently destructive — always
    --dry-run
    first
  • Mole validates paths and enforces protected-directory rules; it skips or refuses high-risk operations
  • Operation log:
    ~/.config/mole/operations.log
    — disable with
    MO_NO_OPLOG=1
  • Review SECURITY.md and SECURITY_AUDIT.md before using in automated pipelines
  • mo analyze
    通过Finder将文件移至废纸篓(可恢复),而非直接删除 — 适合临时清理操作
  • clean
    uninstall
    purge
    installer
    remove
    命令为永久破坏性操作 — 请始终先使用
    --dry-run
    预览
  • Mole会验证路径并强制执行受保护目录规则;跳过或拒绝高风险操作
  • 操作日志:
    ~/.config/mole/operations.log
    — 可通过
    MO_NO_OPLOG=1
    禁用
  • 在自动化流水线中使用前,请查看SECURITY.mdSECURITY_AUDIT.md

Troubleshooting

故障排除

ProblemSolution
mo: command not found
Run
brew install mole
or re-run install script; check
$PATH
Purge scan is slowInstall
fd
:
brew install fd
External drives not appearing in analyzeRun
mo analyze /Volumes
explicitly
Want to protect a cache from being cleanedRun
mo clean --whitelist
to add it
Need to exclude an optimization stepRun
mo optimize --whitelist
Script getting interactive promptsUse
--dry-run
flag; check for
MO_NO_OPLOG=1
env var
Nightly update not workingNightly updates (
--nightly
) only work with script install, not Homebrew
问题解决方案
mo: command not found
执行
brew install mole
或重新运行安装脚本;检查
$PATH
配置
清理扫描速度慢安装
fd
brew install fd
外部驱动器未在分析中显示显式执行
mo analyze /Volumes
希望保护某个缓存不被清理执行
mo clean --whitelist
添加至白名单
需要排除某个优化步骤执行
mo optimize --whitelist
进行配置
脚本中出现交互式提示使用
--dry-run
参数;检查是否设置
MO_NO_OPLOG=1
环境变量
夜间版更新失败夜间版更新(
--nightly
)仅支持脚本安装方式,不支持Homebrew

Update & Remove

更新与卸载

bash
mo update                 # Update to latest stable
mo update --nightly       # Update to latest main (script install only)
mo remove                 # Uninstall Mole completely
mo remove --dry-run       # Preview what remove would delete
bash
mo update                 # 更新至最新稳定版
mo update --nightly       # 更新至最新主分支版本(仅支持脚本安装方式)
mo remove                 # 完全卸载Mole
mo remove --dry-run       # 预览卸载将删除的内容