mole-mac-cleaner
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMole Mac Cleaner
Mole Mac 清理工具
Skill by ara.so — Daily 2026 Skills collection.
Mole () 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.
mo来自ara.so的技能 — 2026每日技能合集。
Mole()是一款一体化macOS维护CLI工具,将深度清理、智能应用卸载、磁盘分析、系统优化、实时监控和项目构建产物清理整合在一个二进制文件中。
moInstallation
安装
bash
undefinedbash
undefinedVia Homebrew (recommended)
通过Homebrew安装(推荐)
brew install mole
brew install mole
Via install script (supports version pinning)
通过安装脚本安装(支持固定版本)
curl -fsSL https://raw.githubusercontent.com/tw93/mole/main/install.sh | bash
curl -fsSL https://raw.githubusercontent.com/tw93/mole/main/install.sh | bash
Specific version
安装指定版本
curl -fsSL https://raw.githubusercontent.com/tw93/mole/main/install.sh | bash -s 1.17.0
curl -fsSL https://raw.githubusercontent.com/tw93/mole/main/install.sh | bash -s 1.17.0
Latest main branch (nightly)
安装最新主分支版本(夜间版)
curl -fsSL https://raw.githubusercontent.com/tw93/mole/main/install.sh | bash -s latest
undefinedcurl -fsSL https://raw.githubusercontent.com/tw93/mole/main/install.sh | bash -s latest
undefinedCore 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 --versionbash
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 --versionSafe 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-runCombine with debug for detailed output
结合debug参数查看详细输出
mo clean --dry-run --debug
mo optimize --dry-run --debug
undefinedmo clean --dry-run --debug
mo optimize --dry-run --debug
undefinedKey Command Details
关键命令详情
mo clean
— Deep Cleanup
mo cleanmo clean
— 深度清理
mo cleanCleans 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 . Edit it to protect paths you want to keep.
~/.config/mole/清理用户应用缓存、浏览器缓存(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 uninstallmo uninstall
— 智能应用卸载
mo uninstallFinds 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 optimizemo optimize
— 系统刷新
mo optimizebash
mo optimize # Run all optimizations
mo optimize --dry-run # Preview
mo optimize --whitelist # Exclude specific optimizationsOptimizations 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 analyzemo analyze
— 磁盘分析器
mo analyzebash
mo analyze # Analyze home directory (skips /Volumes by default)
mo analyze ~/Downloads # Analyze specific path
mo analyze /Volumes # Include external drives explicitlybash
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| Key | Action |
|---|---|
| Navigate list |
| Go back / Enter directory |
| Open in Finder |
| Reveal in Finder |
| Move to Trash (via Finder, safer than direct delete) |
| Show large files |
| 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| 按键 | 操作 |
|---|---|
| 导航列表 |
| 返回上级目录 / 进入子目录 |
| 在Finder中打开 |
| 在Finder中显示 |
| 移至废纸篓(通过Finder操作,比直接删除更安全) |
| 显示大文件 |
| 退出 |
mo status
— Live Dashboard
mo statusmo status
— 实时监控面板
mo statusbash
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 JSONJSON 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 : toggles the cat mascot, quits.
mo statuskqbash
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 statuskqmo purge
— Project Artifact Cleanup
mo purgemo purge
— 项目构建产物清理
mo purgeScans for , , , , , and similar directories. Projects newer than 7 days are unselected by default.
node_modulestargetbuilddistvenvbash
mo purge # Interactive multi-select
mo purge --dry-run # Preview
mo purge --paths # Configure custom scan directoriesConfigure custom scan paths ():
~/.config/mole/purge_paths~/Documents/MyProjects
~/Work/ClientA
~/Work/ClientBWhen this file exists, Mole uses only those paths. Otherwise it defaults to , , .
~/Projects~/GitHub~/devInstallfor faster scanning:fdbrew install fd
扫描、、、、等目录。默认不选择7天内的新项目。
node_modulestargetbuilddistvenvbash
mo purge # 交互式多选
mo purge --dry-run # 预览清理内容
mo purge --paths # 配置自定义扫描目录配置自定义扫描路径():
~/.config/mole/purge_paths~/Documents/MyProjects
~/Work/ClientA
~/Work/ClientB当该文件存在时,Mole仅扫描这些路径;否则默认扫描、、目录。
~/Projects~/GitHub~/dev安装可提升扫描速度:fdbrew install fd
mo installer
— Installer File Cleanup
mo installermo installer
— 安装包文件清理
mo installerbash
mo installer # Find .dmg/.pkg files in Downloads, Desktop, Homebrew cache, iCloud, Mail
mo installer --dry-run # Preview removalsbash
mo installer # 在下载文件夹、桌面、Homebrew缓存、iCloud、邮件中查找.dmg/.pkg文件
mo installer --dry-run # 预览将被移除的文件Configuration Files
配置文件
All config lives in :
~/.config/mole/| File | Purpose |
|---|---|
| Custom directories for |
| Log of all file operations |
Disable operation logging:
bash
export MO_NO_OPLOG=1
mo clean所有配置文件位于:
~/.config/mole/| 文件 | 用途 |
|---|---|
| 配置 |
| 所有文件操作的日志记录 |
禁用操作日志:
bash
export MO_NO_OPLOG=1
mo cleanShell Tab Completion
Shell 自动补全
bash
mo completion # Interactive setup for bash/zsh/fishbash
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-runbash
mo touchid # 为sudo命令启用Touch ID验证
mo touchid enable --dry-runScripting & 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
fibash
#!/bin/bash
health=$(mo status --json | jq -r '.health_score')
if [ "$health" -lt 70 ]; then
echo "健康分数较低:$health — 正在执行清理"
mo clean --dry-run # 准备就绪后替换为`mo clean`
fiGet 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/bashbash
#!/bin/bashNon-interactive purge of build artifacts after CI
CI结束后非交互式清理构建产物
MO_NO_OPLOG=1 mo purge --dry-run # always preview first in scripts
undefinedMO_NO_OPLOG=1 mo purge --dry-run # 脚本中请始终先预览
undefinedRaycast / Alfred quick launchers
Raycast / Alfred 快速启动
bash
curl -fsSL https://raw.githubusercontent.com/tw93/mole/main/install.sh | bashbash
curl -fsSL https://raw.githubusercontent.com/tw93/mole/main/install.sh | bashThen bind mo clean
, mo status
, mo analyze
as script commands in Raycast
mo cleanmo statusmo analyze然后在Raycast中绑定mo clean
、mo status
、mo analyze
作为脚本命令
mo cleanmo statusmo analyzeundefinedundefinedSafety Boundaries
安全边界
- moves files to Trash via Finder (recoverable) instead of direct deletion — prefer it for ad hoc cleanup
mo analyze - ,
clean,uninstall,purge, andinstallerare permanently destructive — alwaysremovefirst--dry-run - Mole validates paths and enforces protected-directory rules; it skips or refuses high-risk operations
- Operation log: — disable with
~/.config/mole/operations.logMO_NO_OPLOG=1 - Review SECURITY.md and SECURITY_AUDIT.md before using in automated pipelines
- 通过Finder将文件移至废纸篓(可恢复),而非直接删除 — 适合临时清理操作
mo analyze - 、
clean、uninstall、purge和installer命令为永久破坏性操作 — 请始终先使用remove预览--dry-run - Mole会验证路径并强制执行受保护目录规则;跳过或拒绝高风险操作
- 操作日志:— 可通过
~/.config/mole/operations.log禁用MO_NO_OPLOG=1 - 在自动化流水线中使用前,请查看SECURITY.md和SECURITY_AUDIT.md
Troubleshooting
故障排除
| Problem | Solution |
|---|---|
| Run |
| Purge scan is slow | Install |
| External drives not appearing in analyze | Run |
| Want to protect a cache from being cleaned | Run |
| Need to exclude an optimization step | Run |
| Script getting interactive prompts | Use |
| Nightly update not working | Nightly updates ( |
| 问题 | 解决方案 |
|---|---|
| 执行 |
| 清理扫描速度慢 | 安装 |
| 外部驱动器未在分析中显示 | 显式执行 |
| 希望保护某个缓存不被清理 | 执行 |
| 需要排除某个优化步骤 | 执行 |
| 脚本中出现交互式提示 | 使用 |
| 夜间版更新失败 | 夜间版更新( |
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 deletebash
mo update # 更新至最新稳定版
mo update --nightly # 更新至最新主分支版本(仅支持脚本安装方式)
mo remove # 完全卸载Mole
mo remove --dry-run # 预览卸载将删除的内容