Intelligently analyze macOS disk usage and provide actionable cleanup recommendations to reclaim storage space. This skill follows a safety-first philosophy: analyze thoroughly, present clear findings, and require explicit user confirmation before executing any deletions.
Target users: Users with basic technical knowledge who understand file systems but need guidance on what's safe to delete on macOS.
智能分析macOS磁盘使用情况,并提供可执行的清理建议以回收存储空间。本技能遵循安全优先原则:全面分析、清晰呈现结果,执行任何删除操作前必须获得用户明确确认。
目标用户:具备基础技术知识、了解文件系统,但需要指导判断macOS上哪些内容可安全删除的用户。
- Safety First, Never Bypass: NEVER execute dangerous commands (, , etc.) without explicit user confirmation. No shortcuts, no workarounds.
- Value Over Vanity: Your goal is NOT to maximize cleaned space. Your goal is to identify what is truly useless vs valuable cache. Clearing 50GB of useful cache just to show a big number is harmful.
- Network Environment Awareness: Many users (especially in China) have slow/unreliable internet. Re-downloading caches can take hours. A cache that saves 30 minutes of download time is worth keeping.
- Impact Analysis Required: Every cleanup recommendation MUST include "what happens if deleted" column. Never just list items without explaining consequences.
- Patience Over Speed: Disk scans can take 5-10 minutes. NEVER interrupt or skip slow operations. Report progress to user regularly.
- User Executes Cleanup: After analysis, provide the cleanup command for the user to run themselves. Do NOT auto-execute cleanup.
- Conservative Defaults: When in doubt, don't delete. Err on the side of caution.
ABSOLUTE PROHIBITIONS:
- ❌ NEVER run on user directories automatically
- ❌ NEVER run without dry-run preview first
- ❌ NEVER use or
docker system prune -a --volumes
- ❌ NEVER skip analysis steps to save time
- ❌ NEVER append to Mole commands (except )
- ❌ NEVER recommend deleting useful caches just to inflate cleanup numbers
- 安全第一,绝不越界:未经用户明确确认,绝不能执行危险命令(如、等)。没有捷径,没有变通方法。
- 价值优先,拒绝虚荣:你的目标不是最大化清理空间,而是识别真正无用的内容与有价值的缓存。为了显示清理大数字而删除50GB有用缓存是有害的。
- 考虑网络环境:许多用户(尤其是国内用户)网络速度慢或不稳定。重新下载缓存可能需要数小时。一个能节省30分钟下载时间的缓存是值得保留的。
- 必须进行影响分析:每条清理建议必须包含“删除后会发生什么”的说明。绝不能只列出项目却不解释后果。
- 耐心优先于速度:磁盘扫描可能需要5-10分钟。绝不能中断或跳过耗时的操作,要定期向用户报告进度。
- 由用户执行清理:分析完成后,提供清理命令让用户自行执行。绝不能自动执行清理操作。
- 保守默认策略:存疑时,不删除。宁可信其有,不可信其无。
绝对禁止事项:
- ❌ 绝不能自动在用户目录下运行
- ❌ 绝不能在未先进行试运行预览的情况下运行
- ❌ 绝不能使用或
docker system prune -a --volumes
- ❌ 绝不能为了节省时间而跳过分析步骤
- ❌ 绝不能在Mole命令后追加(除了)
- ❌ 绝不能为了虚增清理数字而建议删除有用缓存
Workflow Decision Tree
工作流决策树
User reports disk space issues
↓
Quick Diagnosis
↓
┌──────┴──────┐
│ │
Immediate Deep Analysis
Cleanup (continue below)
│ │
└──────┬──────┘
↓
Present Findings
↓
User Confirms
↓
Execute Cleanup
↓
Verify Results
用户反馈磁盘空间问题
↓
快速诊断
↓
┌──────┴──────┐
│ │
立即清理 深度分析
(继续下方步骤)
│ │
└──────┬──────┘
↓
呈现分析结果
↓
用户确认
↓
执行清理
↓
验证结果
Step 1: Quick Diagnosis with Mole
步骤1:使用Mole进行快速诊断
Primary tool: Use Mole for disk analysis. It provides comprehensive, categorized results.
主要工具:使用Mole进行磁盘分析,它能提供全面的分类结果。
1.1 Pre-flight Checks
1.1 前置检查
Check Mole installation and version
检查Mole是否安装及版本
brew install tw93/tap/mole
brew install tw93/tap/mole
Check for updates (Mole updates frequently)
检查更新(Mole更新频繁)
brew info tw93/tap/mole | head -5
brew info tw93/tap/mole | head -5
Upgrade if outdated
若版本过时则升级
brew upgrade tw93/tap/mole
brew upgrade tw93/tap/mole
1.2 Choose Analysis Method
1.2 选择分析方法
IMPORTANT: Use
as the primary analysis tool, NOT
.
| Command | Purpose | Use When |
|---|
| Interactive disk usage explorer (TUI tree view) | PRIMARY: Understanding what's consuming space |
| Preview cleanup categories | SECONDARY: Only after to see cleanup preview |
- Dedicated disk analysis tool with interactive tree navigation
- Allows drilling down into specific directories
- Shows actual disk usage breakdown, not just cleanup categories
- More informative for understanding storage consumption
| 命令 | 用途 | 使用场景 |
|---|
| 交互式磁盘使用情况浏览器(TUI树形视图) | 主要工具:了解存储空间占用情况 |
| 预览清理分类 | 次要工具:仅在之后使用,查看清理预览 |
- 专用磁盘分析工具,支持交互式树形导航
- 可深入查看特定目录
- 显示实际磁盘使用情况细分,而非仅清理分类
- 更有助于理解存储消耗情况
1.3 Run Analysis via tmux
1.3 通过tmux运行分析
IMPORTANT: Mole requires TTY. Always use tmux from Claude Code.
CRITICAL TIMING NOTE: Home directory scans are SLOW (5-10 minutes or longer for large directories). Inform user upfront and wait patiently.
重要提示:Mole需要TTY环境。在Claude Code中始终使用tmux。
关键时间提示:主目录扫描速度较慢(大型目录可能需要5-10分钟或更久)。提前告知用户并耐心等待。
Create tmux session
创建tmux会话
tmux new-session -d -s mole -x 120 -y 40
tmux new-session -d -s mole -x 120 -y 40
Run disk analysis (PRIMARY tool - interactive TUI)
运行磁盘分析(主要工具 - 交互式TUI)
tmux send-keys -t mole 'mo analyze' Enter
tmux send-keys -t mole 'mo analyze' Enter
Wait for scan - BE PATIENT!
等待扫描完成 - 请耐心等待!
Home directory scanning typically takes 5-10 minutes
主目录扫描通常需要5-10分钟
Report progress to user regularly
定期向用户报告进度
sleep 60 && tmux capture-pane -t mole -p
sleep 60 && tmux capture-pane -t mole -p
Navigate the TUI with arrow keys
使用箭头键导航TUI
tmux send-keys -t mole Down # Move to next item
tmux send-keys -t mole Enter # Expand/select item
tmux send-keys -t mole 'q' # Quit when done
**Alternative: Cleanup preview (use AFTER mo analyze)**
```bash
tmux send-keys -t mole Down # 移动到下一项
tmux send-keys -t mole Enter # 展开/选择项目
tmux send-keys -t mole 'q' # 完成后退出
**替代方案:清理预览(仅在mo analyze之后使用)**
```bash
Run dry-run preview (SAFE - no deletion)
运行试运行预览(安全 - 无删除操作)
tmux send-keys -t mole 'mo clean --dry-run' Enter
tmux send-keys -t mole 'mo clean --dry-run' Enter
Wait for scan (report progress to user every 30 seconds)
等待扫描完成(每30秒向用户报告一次进度)
Be patient! Large directories take 5-10 minutes
请耐心等待!大型目录需要5-10分钟
sleep 30 && tmux capture-pane -t mole -p
sleep 30 && tmux capture-pane -t mole -p
1.4 Progress Reporting
1.4 进度报告
Report scan progress to user regularly:
📊 Disk Analysis in Progress...
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⏱️ Elapsed: 2 minutes
Current status:
✅ Applications: 49.5 GB (complete)
✅ System Library: 10.3 GB (complete)
⏳ Home: scanning... (this may take 5-10 minutes)
⏳ App Library: pending
I'm waiting patiently for the scan to complete.
Will report again in 30 seconds...
定期向用户报告扫描进度:
📊 磁盘分析进行中...
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⏱️ 已耗时:2分钟
当前状态:
✅ 应用程序:49.5 GB(已完成)
✅ 系统库:10.3 GB(已完成)
⏳ 主目录:扫描中...(可能需要5-10分钟)
⏳ 应用库:待处理
我正在耐心等待扫描完成,将在30秒后再次报告进度...
1.5 Present Final Findings
1.5 呈现最终结果
After scan completes, present structured results:
📊 Disk Space Analysis (via Mole)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Free space: 27 GB
🧹 Recoverable Space (dry-run preview):
➤ User Essentials
• User app cache: 16.67 GB
• User app logs: 102.3 MB
• Trash: 642.9 MB
➤ Browser Caches
• Chrome cache: 1.90 GB
• Safari cache: 4 KB
➤ Developer Tools
• uv cache: 9.96 GB
• npm cache: (detected)
• Docker cache: (detected)
• Homebrew cache: (detected)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Total recoverable: ~30 GB
⚠️ This was a dry-run preview. No files were deleted.
扫描完成后,以结构化方式呈现结果:
📊 磁盘空间分析结果(通过Mole)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
可用空间:27 GB
🧹 可回收空间(试运行预览):
➤ 用户核心数据
• 用户应用缓存: 16.67 GB
• 用户应用日志: 102.3 MB
• 废纸篓: 642.9 MB
➤ 浏览器缓存
• Chrome缓存: 1.90 GB
• Safari缓存: 4 KB
➤ 开发工具
• uv缓存: 9.96 GB
• npm缓存: (已检测到)
• Docker缓存: (已检测到)
• Homebrew缓存: (已检测到)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
总可回收空间:约30 GB
⚠️ 这是试运行预览,未删除任何文件。
Step 2: Deep Analysis Categories
步骤2:深度分析分类
Scan the following categories systematically. Reference
references/cleanup_targets.md
for detailed explanations.
系统地扫描以下分类。详细说明可参考
references/cleanup_targets.md
。
Category 1: System & Application Caches
分类1:系统与应用缓存
Locations to analyze:
- - User application caches
- - System-wide caches (requires sudo)
- - Application logs
- - System logs (requires sudo)
Analysis script:
bash
scripts/analyze_caches.py --user-only
Safety level: 🟢 Generally safe to delete (apps regenerate caches)
Exceptions to preserve:
- Browser caches while browser is running
- IDE caches (may slow down next startup)
- Package manager caches (Homebrew, pip, npm)
分析位置:
- - 用户应用缓存
- - 系统级缓存(需要sudo权限)
- - 应用日志
- - 系统日志(需要sudo权限)
分析脚本:
bash
scripts/analyze_caches.py --user-only
安全级别:🟢 通常可安全删除(应用会重新生成缓存)
需保留的例外情况:
- 浏览器运行时的浏览器缓存
- IDE缓存(删除后可能会减慢下次启动速度)
- 包管理器缓存(Homebrew、pip、npm)
Category 2: Application Remnants
分类2:应用残留
Locations to analyze:
~/Library/Application Support/*
- App data
- - Preference files
- - Sandboxed app data
Analysis approach:
- List installed applications in
- Cross-reference with
~/Library/Application Support
- Identify orphaned folders (app uninstalled but data remains)
Analysis script:
bash
scripts/find_app_remnants.py
Safety level: 🟡 Caution required
- ✅ Safe: Folders for clearly uninstalled apps
- ⚠️ Check first: Folders for apps you rarely use
- ❌ Keep: Active application data
分析位置:
~/Library/Application Support/*
- 应用数据
- - 偏好设置文件
- - 沙箱应用数据
分析方法:
- 列出中已安装的应用
- 与
~/Library/Application Support
中的内容进行交叉比对
- 识别孤立文件夹(应用已卸载但数据仍保留)
分析脚本:
bash
scripts/find_app_remnants.py
安全级别:🟡 需要谨慎操作
- ✅ 安全:已明确卸载的应用对应的文件夹
- ⚠️ 需先检查:很少使用的应用对应的文件夹
- ❌ 保留:正在使用的应用数据
Category 3: Large Files & Duplicates
分类3:大文件与重复文件
Analysis script:
bash
scripts/analyze_large_files.py --threshold 100MB --path ~
Find duplicates (optional, resource-intensive):
分析脚本:
bash
scripts/analyze_large_files.py --threshold 100MB --path ~
查找重复文件(可选,资源消耗较大):
Use fdupes if installed
若已安装fdupes则使用
if command -v fdupes &> /dev/null; then
fdupes -r ~/Documents ~/Downloads
fi
📦 Large Files (>100MB):
━━━━━━━━━━━━━━━━━━━━━━━━
- movie.mp4 4.2 GB ~/Downloads
- dataset.csv 1.8 GB ~/Documents/data
- old_backup.zip 1.5 GB ~/Desktop
...
🔁 Duplicate Files:
- screenshot.png (3 copies) 15 MB each
- document_v1.docx (2 copies) 8 MB each
**Safety level**: 🟡 User judgment required
if command -v fdupes &> /dev/null; then
fdupes -r ~/Documents ~/Downloads
fi
📦 大文件(>100MB):
━━━━━━━━━━━━━━━━━━━━━━━━
- movie.mp4 4.2 GB ~/Downloads
- dataset.csv 1.8 GB ~/Documents/data
- old_backup.zip 1.5 GB ~/Desktop
...
🔁 重复文件:
- screenshot.png(3个副本) 每个15 MB
- document_v1.docx(2个副本) 每个8 MB
Category 4: Development Environment Cleanup
分类4:开发环境清理
Targets:
- Docker: images, containers, volumes, build cache
- Homebrew: cache, old versions
- Node.js: , npm cache
- Python: pip cache, , venv
- Git: folders in archived projects
Analysis script:
bash
scripts/analyze_dev_env.py
Example findings:
🐳 Docker Resources:
- Unused images: 12 GB
- Stopped containers: 2 GB
- Build cache: 8 GB
- Orphaned volumes: 3 GB
Total potential: 25 GB
📦 Package Managers:
- Homebrew cache: 5 GB
- npm cache: 3 GB
- pip cache: 1 GB
Total potential: 9 GB
🗂️ Old Projects:
- archived-project-2022/.git 500 MB
- old-prototype/.git 300 MB
Cleanup commands (require confirmation):
清理目标:
- Docker:镜像、容器、卷、构建缓存
- Homebrew:缓存、旧版本
- Node.js:、npm缓存
- Python:pip缓存、、虚拟环境
- Git:归档项目中的文件夹
分析脚本:
bash
scripts/analyze_dev_env.py
示例结果:
🐳 Docker资源:
- 未使用镜像: 12 GB
- 已停止容器: 2 GB
- 构建缓存: 8 GB
- 孤立卷: 3 GB
总可回收空间: 25 GB
📦 包管理器:
- Homebrew缓存: 5 GB
- npm缓存: 3 GB
- pip缓存: 1 GB
总可回收空间: 9 GB
🗂️ 旧项目:
- archived-project-2022/.git 500 MB
- old-prototype/.git 300 MB
清理命令(需用户确认):
Homebrew cleanup (safe)
Homebrew清理(安全)
npm _npx only (safe - temporary packages)
仅清理npm _npx(安全 - 临时包)
pip cache (use with caution)
pip缓存(谨慎使用)
pip cache purge
**Docker cleanup - SPECIAL HANDLING REQUIRED:**
⚠️ **NEVER use these commands:**
```bash
pip cache purge
**Docker清理 - 特殊处理要求:**
⚠️ **绝不能使用以下命令:**
```bash
❌ DANGEROUS - deletes ALL volumes without confirmation
❌ 危险 - 无确认即删除所有卷
docker volume prune -f
docker system prune -a --volumes
✅ **Correct approach - per-volume confirmation:**
```bash
docker volume prune -f
docker system prune -a --volumes
✅ **正确方法 - 按卷确认:**
```bash
1. List all volumes
1. 列出所有卷
2. Identify which projects each volume belongs to
2. 识别每个卷所属的项目
docker volume inspect <volume_name>
docker volume inspect <volume_name>
3. Ask user to confirm EACH project they want to delete
3. 请求用户确认每个要删除的项目
Example: "Do you want to delete all volumes for 'ragflow' project?"
示例:"是否要删除'ragflow'项目的所有卷?"
4. Delete specific volumes only after confirmation
4. 仅在确认后删除特定卷
docker volume rm ragflow_mysql_data ragflow_redis_data
**Safety level**: 🟢 Homebrew/npm cleanup, 🔴 Docker volumes require per-project confirmation
docker volume rm ragflow_mysql_data ragflow_redis_data
**安全级别**:🟢 Homebrew/npm清理安全,🔴 Docker卷需要按项目确认
Step 3: Integration with Mole
步骤3:与Mole集成
Mole (
https://github.com/tw93/Mole) is a
command-line interface (CLI) tool for comprehensive macOS cleanup. It provides interactive terminal-based analysis and cleanup for caches, logs, developer tools, and more.
CRITICAL REQUIREMENTS:
- TTY Environment: Mole requires a TTY for interactive commands. Use when running from Claude Code or scripts.
- Version Check: Always verify Mole is up-to-date before use.
- Safe Help Command: Only is safe. Do NOT append to other commands.
Installation check and upgrade:
关键要求:
- TTY环境:Mole的交互式命令需要TTY环境。从Claude Code或脚本运行时使用。
- 版本检查:使用前始终确认Mole为最新版本。
- 安全帮助命令:仅是安全的。绝不能在其他命令后追加。
安装检查与升级:
Check if installed and get version
检查是否安装及版本
brew install tw93/tap/mole
brew install tw93/tap/mole
brew info tw93/tap/mole | head -5
brew info tw93/tap/mole | head -5
brew upgrade tw93/tap/mole
**Using Mole with tmux (REQUIRED for Claude Code):**
```bash
brew upgrade tw93/tap/mole
**结合tmux使用Mole(Claude Code中必须使用):**
```bash
Create tmux session for TTY environment
创建tmux会话以提供TTY环境
tmux new-session -d -s mole -x 120 -y 40
tmux new-session -d -s mole -x 120 -y 40
Run analysis (safe, read-only)
运行分析(安全,只读)
tmux send-keys -t mole 'mo analyze' Enter
tmux send-keys -t mole 'mo analyze' Enter
Wait for scan (be patient - can take 5-10 minutes for large directories)
等待扫描完成(耐心等待 - 大型目录可能需要5-10分钟)
tmux capture-pane -t mole -p
tmux capture-pane -t mole -p
tmux kill-session -t mole
**Available commands (from `mo --help`):**
| Command | Safety | Description |
|---------|--------|-------------|
| `mo --help` | ✅ Safe | View all commands (ONLY safe help) |
| `mo analyze` | ✅ Safe | Disk usage explorer (read-only) |
| `mo status` | ✅ Safe | System health monitor |
| `mo clean --dry-run` | ✅ Safe | Preview cleanup (no deletion) |
| `mo clean` | ⚠️ DANGEROUS | Actually deletes files |
| `mo purge` | ⚠️ DANGEROUS | Remove project artifacts |
| `mo uninstall` | ⚠️ DANGEROUS | Remove applications |
**Reference guide:**
See `references/mole_integration.md` for detailed tmux workflow and troubleshooting.
tmux kill-session -t mole
**可用命令(来自`mo --help`):**
| 命令 | 安全性 | 描述 |
|---------|--------|-------------|
| `mo --help` | ✅ 安全 | 查看所有命令(唯一安全的帮助命令) |
| `mo analyze` | ✅ 安全 | 磁盘使用情况浏览器(只读) |
| `mo status` | ✅ 安全 | 系统健康监控 |
| `mo clean --dry-run` | ✅ 安全 | 预览清理操作(无删除) |
| `mo clean` | ⚠️ 危险 | 实际删除文件 |
| `mo purge` | ⚠️ 危险 | 删除项目构建产物 |
| `mo uninstall` | ⚠️ 危险 | 卸载应用程序 |
**参考指南:**
详细的tmux工作流与故障排除可参考`references/mole_integration.md`。
Multi-Layer Deep Exploration with Mole
使用Mole进行多层深度探索
CRITICAL: For comprehensive analysis, you MUST perform multi-layer exploration, not just top-level scans. This section documents the proven workflow for navigating Mole's TUI.
关键提示:为了全面分析,必须进行多层探索,而不仅仅是顶层扫描。本节记录了在Mole的TUI中导航的成熟工作流。
tmux new-session -d -s mole -x 120 -y 40
tmux new-session -d -s mole -x 120 -y 40
tmux send-keys -t mole 'mo analyze' Enter
tmux send-keys -t mole 'mo analyze' Enter
Wait for initial scan
等待初始扫描完成
sleep 8 && tmux capture-pane -t mole -p
sleep 8 && tmux capture-pane -t mole -p
Navigation keys (send via tmux)
导航键(通过tmux发送)
tmux send-keys -t mole Enter # Enter/expand selected directory
tmux send-keys -t mole Left # Go back to parent directory
tmux send-keys -t mole Down # Move to next item
tmux send-keys -t mole Up # Move to previous item
tmux send-keys -t mole 'q' # Quit TUI
tmux send-keys -t mole Enter # 进入/展开选中的目录
tmux send-keys -t mole Left # 返回父目录
tmux send-keys -t mole Down # 移动到下一项
tmux send-keys -t mole Up # 移动到上一项
tmux send-keys -t mole 'q' # 退出TUI
Capture current view
获取当前视图内容
tmux capture-pane -t mole -p
tmux capture-pane -t mole -p
Multi-Layer Exploration Workflow
多层探索工作流
Step 1: Top-level overview
Start mo analyze, wait for initial menu
启动mo analyze,等待初始菜单加载
tmux send-keys -t mole 'mo analyze' Enter
sleep 8 && tmux capture-pane -t mole -p
tmux send-keys -t mole 'mo analyze' Enter
sleep 8 && tmux capture-pane -t mole -p
1. Home 289.4 GB (58.5%)
1. Home 289.4 GB (58.5%)
2. App Library 145.2 GB (29.4%)
2. App Library 145.2 GB (29.4%)
3. Applications 49.5 GB (10.0%)
3. Applications 49.5 GB (10.0%)
4. System Library 10.3 GB (2.1%)
4. System Library 10.3 GB (2.1%)
**Step 2: Enter largest directory (Home)**
```bash
tmux send-keys -t mole Enter
sleep 10 && tmux capture-pane -t mole -p
**步骤2:进入最大目录(Home)**
```bash
tmux send-keys -t mole Enter
sleep 10 && tmux capture-pane -t mole -p
1. Library 144.4 GB (49.9%)
1. Library 144.4 GB (49.9%)
2. Workspace 52.0 GB (18.0%)
2. Workspace 52.0 GB (18.0%)
3. .cache 19.3 GB (6.7%)
3. .cache 19.3 GB (6.7%)
4. Applications 17.0 GB (5.9%)
4. Applications 17.0 GB (5.9%)
**Step 3: Drill into specific directories**
```bash
Go to .cache (3rd item: Down Down Enter)
进入.cache(第3项:按两次Down再按Enter)
tmux send-keys -t mole Down Down Enter
sleep 5 && tmux capture-pane -t mole -p
tmux send-keys -t mole Down Down Enter
sleep 5 && tmux capture-pane -t mole -p
1. uv 10.3 GB (55.6%)
1. uv 10.3 GB (55.6%)
2. modelscope 5.5 GB (29.5%)
2. modelscope 5.5 GB (29.5%)
3. huggingface 887.8 MB (4.7%)
3. huggingface 887.8 MB (4.7%)
**Step 4: Navigate back and explore another branch**
```bash
**步骤4:返回并探索另一个分支**
```bash
tmux send-keys -t mole Left
sleep 2
tmux send-keys -t mole Left
sleep 2
Navigate to different directory
导航到其他目录
tmux send-keys -t mole Down Down Down Down Enter # Go to .npm
sleep 5 && tmux capture-pane -t mole -p
**Step 5: Deep dive into Library**
```bash
tmux send-keys -t mole Down Down Down Down Enter # 进入.npm
sleep 5 && tmux capture-pane -t mole -p
**步骤5:深入Library目录**
```bash
Back to Home, then into Library
返回Home,然后进入Library
tmux send-keys -t mole Left
tmux send-keys -t mole Up Up Up Up Up Up Enter # Go to Library
sleep 10 && tmux capture-pane -t mole -p
tmux send-keys -t mole Left
tmux send-keys -t mole Up Up Up Up Up Up Enter # 进入Library
sleep 10 && tmux capture-pane -t mole -p
1. Application Support 37.1 GB
1. Application Support 37.1 GB
2. Containers 35.4 GB
2. Containers 35.4 GB
3. Developer 17.8 GB ← Xcode is here
3. Developer 17.8 GB ← Xcode相关内容在此
4. Caches 8.2 GB
4. Caches 8.2 GB
Recommended Exploration Path
推荐探索路径
For comprehensive analysis, follow this exploration tree:
mo analyze
├── Home (Enter)
│ ├── Library (Enter)
│ │ ├── Developer (Enter) → Xcode/DerivedData, iOS DeviceSupport
│ │ ├── Caches (Enter) → Playwright, JetBrains, etc.
│ │ └── Application Support (Enter) → App data
│ ├── .cache (Enter) → uv, modelscope, huggingface
│ ├── .npm (Enter) → _cacache, _npx
│ ├── Downloads (Enter) → Large files to review
│ ├── .Trash (Enter) → Confirm trash contents
│ └── miniconda3/other dev tools (Enter) → Check last used time
├── App Library → Usually overlaps with ~/Library
└── Applications → Installed apps
为了全面分析,请遵循以下探索树:
mo analyze
├── Home(Enter)
│ ├── Library(Enter)
│ │ ├── Developer(Enter)→ Xcode/DerivedData、iOS DeviceSupport
│ │ ├── Caches(Enter)→ Playwright、JetBrains等
│ │ └── Application Support(Enter)→ 应用数据
│ ├── .cache(Enter)→ uv、modelscope、huggingface
│ ├── .npm(Enter)→ _cacache、_npx
│ ├── Downloads(Enter)→ 需检查的大文件
│ ├── .Trash(Enter)→ 确认废纸篓内容
│ └── miniconda3/其他开发工具(Enter)→ 检查最后使用时间
├── App Library → 通常与~/Library内容重叠
└── Applications → 已安装的应用
| Directory | Scan Time | Notes |
|---|
| Top-level menu | 5-8 seconds | Fast |
| Home directory | 5-10 minutes | Large, be patient |
| ~/Library | 3-5 minutes | Many small files |
| Subdirectories | 2-30 seconds | Varies by size |
| 目录 | 扫描时间 | 说明 |
|---|
| 顶层菜单 | 5-8秒 | 快速 |
| 主目录 | 5-10分钟 | 内容庞大,请耐心等待 |
| ~/Library | 3-5分钟 | 包含大量小文件 |
| 子目录 | 2-30秒 | 时间因大小而异 |
Example Complete Session
完整会话示例
tmux new-session -d -s mole -x 120 -y 40
tmux new-session -d -s mole -x 120 -y 40
2. Start analysis and get overview
2. 启动分析并获取概览
tmux send-keys -t mole 'mo analyze' Enter
sleep 8 && tmux capture-pane -t mole -p
tmux send-keys -t mole 'mo analyze' Enter
sleep 8 && tmux capture-pane -t mole -p
tmux send-keys -t mole Enter
sleep 10 && tmux capture-pane -t mole -p
tmux send-keys -t mole Enter
sleep 10 && tmux capture-pane -t mole -p
4. Enter .cache to see dev caches
4. 进入.cache查看开发缓存
tmux send-keys -t mole Down Down Enter
sleep 5 && tmux capture-pane -t mole -p
tmux send-keys -t mole Down Down Enter
sleep 5 && tmux capture-pane -t mole -p
5. Back to Home, then to .npm
5. 返回Home,然后进入.npm
tmux send-keys -t mole Left
sleep 2
tmux send-keys -t mole Down Down Down Down Enter
sleep 5 && tmux capture-pane -t mole -p
tmux send-keys -t mole Left
sleep 2
tmux send-keys -t mole Down Down Down Down Enter
sleep 5 && tmux capture-pane -t mole -p
6. Back to Home, enter Library
6. 返回Home,进入Library
tmux send-keys -t mole Left
sleep 2
tmux send-keys -t mole Up Up Up Up Up Up Enter
sleep 10 && tmux capture-pane -t mole -p
tmux send-keys -t mole Left
sleep 2
tmux send-keys -t mole Up Up Up Up Up Up Enter
sleep 10 && tmux capture-pane -t mole -p
7. Enter Developer to see Xcode
7. 进入Developer查看Xcode内容
tmux send-keys -t mole Down Down Down Enter
sleep 5 && tmux capture-pane -t mole -p
tmux send-keys -t mole Down Down Down Enter
sleep 5 && tmux capture-pane -t mole -p
tmux send-keys -t mole Enter
sleep 5 && tmux capture-pane -t mole -p
tmux send-keys -t mole Enter
sleep 5 && tmux capture-pane -t mole -p
9. Enter DerivedData to see projects
9. 进入DerivedData查看项目内容
tmux send-keys -t mole Enter
sleep 5 && tmux capture-pane -t mole -p
tmux send-keys -t mole Enter
sleep 5 && tmux capture-pane -t mole -p
tmux kill-session -t mole
tmux kill-session -t mole
Key Insights from Exploration
探索关键发现
After multi-layer exploration, you will discover:
- What projects are using DerivedData - specific project names
- Which caches are actually large - uv vs npm vs others
- Age of files - Mole shows ">3mo", ">7mo", ">1yr" markers
- Specific volumes and their purposes - Docker project data
- Downloads that can be cleaned - old dmgs, duplicate files
经过多层探索后,你将发现:
- 哪些项目在使用DerivedData - 具体项目名称
- 哪些缓存实际占用大量空间 - uv、npm或其他缓存
- 文件的使用时长 - Mole会显示">3mo"、">7mo"、">1yr"等标记
- 特定卷及其用途 - Docker项目数据
- 可清理的下载内容 - 旧镜像文件、重复文件
Anti-Patterns: What NOT to Delete
反模式:绝不能删除的内容
CRITICAL: The following items are often suggested for cleanup but should NOT be deleted in most cases. They provide significant value that outweighs the space they consume.
关键提示:以下内容常被建议清理,但在大多数情况下不应删除。它们的价值远大于占用的空间。
Items to KEEP (Anti-Patterns)
需保留的内容(反模式)
| Item | Size | Why NOT to Delete | Real Impact of Deletion |
|---|
| Xcode DerivedData | 10+ GB | Build cache saves 10-30 min per full rebuild | Next build takes 10-30 minutes longer |
| npm _cacache | 5+ GB | Downloaded packages cached locally | redownloads everything (30min-2hr in China) |
| ~/.cache/uv | 10+ GB | Python package cache | Every Python project reinstalls deps from PyPI |
| Playwright browsers | 3-4 GB | Browser binaries for automation testing | Redownload 2GB+ each time (30min-1hr) |
| iOS DeviceSupport | 2-3 GB | Required for device debugging | Redownload from Apple when connecting device |
| Docker stopped containers | <500 MB | May restart anytime with | Lose container state, need to recreate |
| ~/.cache/huggingface | varies | AI model cache | Redownload large models (hours) |
| ~/.cache/modelscope | varies | AI model cache (China) | Same as above |
| JetBrains caches | 1+ GB | IDE indexing and caches | IDE takes 5-10 min to re-index |
| 项目 | 大小 | 绝不能删除的原因 | 删除后的实际影响 |
|---|
| Xcode DerivedData | 10+ GB | 构建缓存可节省每次完整构建10-30分钟的时间 | 下次构建时间将增加10-30分钟 |
| npm _cacache | 5+ GB | 已下载的包缓存本地存储 | 将重新下载所有内容(国内网络下需要30分钟-2小时) |
| ~/.cache/uv | 10+ GB | Python包缓存 | 每个Python项目都需要从PyPI重新安装依赖 |
| Playwright浏览器 | 3-4 GB | 自动化测试所需的浏览器二进制文件 | 每次使用都需要重新下载2GB+内容(30分钟-1小时) |
| iOS DeviceSupport | 2-3 GB | 设备调试必需 | 连接设备时需要从Apple重新下载 |
| Docker已停止容器 | <500 MB | 可随时通过重启 | 丢失容器状态,需要重新创建 |
| ~/.cache/huggingface | 大小不定 | AI模型缓存 | 重新下载大型模型(需要数小时) |
| ~/.cache/modelscope | 大小不定 | AI模型缓存(国内) | 与上述情况相同 |
| JetBrains缓存 | 1+ GB | IDE索引与缓存 | IDE重新索引需要5-10分钟 |
The vanity trap: Showing "Cleaned 50GB!" feels good but:
- User spends next 2 hours redownloading npm packages
- Next Xcode build takes 30 minutes instead of 30 seconds
- AI project fails because models need redownload
The right mindset: "I found 50GB of caches. Here's why most of them are actually valuable and should be kept..."
虚荣陷阱:显示“已清理50GB!”看起来很棒,但实际上:
- 用户接下来需要花2小时重新下载npm包
- 下次Xcode构建需要30分钟而不是30秒
- AI项目因需要重新下载模型而失败
正确心态:“我发现了50GB缓存,但其中大部分实际上很有价值,应该保留……”
What IS Actually Safe to Delete
真正可安全删除的内容
| Item | Why Safe | Impact |
|---|
| Trash | User already deleted these files | None - user's decision |
| Homebrew old versions | Replaced by newer versions | Rare: can't rollback to old version |
| npm _npx | Temporary npx executions | Minor: npx re-downloads on next use |
| Orphaned app remnants | App already uninstalled | None - app doesn't exist |
| Specific unused Docker volumes | Projects confirmed abandoned | None - if truly abandoned |
| 项目 | 为什么安全 | 影响 |
|---|
| 废纸篓 | 用户已决定删除这些文件 | 无 - 用户自主选择 |
| Homebrew旧版本 | 已被新版本替代 | 罕见情况:无法回滚到旧版本 |
| npm _npx | npx临时执行文件 | 轻微影响:下次使用npx时需要重新下载 |
| 孤立应用残留 | 应用已卸载 | 无 - 应用已不存在 |
| 特定未使用的Docker卷 | 项目已确认废弃 | 无 - 若确实已废弃 |
Report Format Requirements
报告格式要求
Every cleanup report MUST follow this format with impact analysis:
Disk Analysis Report
磁盘分析报告
Classification Legend
分类图例
| Symbol | Meaning |
|---|
| 🟢 | Absolutely Safe - No negative impact, truly unused |
| 🟡 | Trade-off Required - Useful cache, deletion has cost |
| 🔴 | Do Not Delete - Contains valuable data or actively used |
| 符号 | 含义 |
|---|
| 🟢 | 绝对安全 - 无负面影响,真正未使用的内容 |
| 🟡 | 需要权衡 - 有用的缓存,删除会有代价 |
| 🔴 | 绝不能删除 - 包含有价值的数据或正在使用的内容 |
| Item | Size | Classification | What It Is | Impact If Deleted |
|---|
| Trash | 643 MB | 🟢 | Files you deleted | None |
| npm _npx | 2.1 GB | 🟢 | Temp npx packages | Minor redownload |
| npm _cacache | 5 GB | 🟡 | Package cache | 30min-2hr redownload |
| DerivedData | 10 GB | 🟡 | Xcode build cache | 10-30min rebuild |
| Docker volumes | 11 GB | 🔴 | Project databases | DATA LOSS |
| 项目 | 大小 | 分类 | 内容说明 | 删除影响 |
|---|
| 废纸篓 | 643 MB | 🟢 | 用户已删除的文件 | 无 |
| npm _npx | 2.1 GB | 🟢 | npx临时包 | 轻微影响:下次使用npx时重新下载 |
| npm _cacache | 5 GB | 🟡 | 包缓存 | 30分钟-2小时的重新下载时间 |
| DerivedData | 10 GB | 🟡 | Xcode构建缓存 | 10-30分钟的额外构建时间 |
| Docker卷 | 11 GB | 🔴 | 项目数据库 | 数据丢失 |
Only items marked 🟢 are recommended for cleanup.
Items marked 🟡 require your judgment based on usage patterns.
Items marked 🔴 require explicit confirmation per-item.
仅标记为🟢的项目建议清理。
标记为🟡的项目需要你根据使用模式自行判断。
标记为🔴的项目需要逐项明确确认。
High-Quality Report Template
高质量报告模板
After multi-layer exploration, present findings using this proven template:
分析日期: YYYY-MM-DD
使用工具: Mole CLI + 多层目录探索
分析原则: 安全第一,价值优于虚荣
分析日期: YYYY-MM-DD
使用工具: Mole CLI + 多层目录探索
分析原则: 安全第一,价值优于虚荣
| 区域 | 总占用 | 关键发现 |
|---|
| Home | XXX GB | Library占一半(XXX GB) |
| App Library | XXX GB | 与Home/Library重叠统计 |
| Applications | XXX GB | 应用本体 |
| 区域 | 总占用 | 关键发现 |
|---|
| Home | XXX GB | Library占一半(XXX GB) |
| App Library | XXX GB | 与Home/Library统计重叠 |
| Applications | XXX GB | 应用本体 |
🟢 绝对安全可删除 (约 X.X GB)
🟢 绝对安全可删除 (约 X.X GB)
| 项目 | 大小 | 位置 | 删除后影响 | 清理命令 |
|---|
| 废纸篓 | XXX MB | ~/.Trash | 无 - 你已决定删除的文件 | 清空废纸篓 |
| npm _npx | X.X GB | ~/.npm/_npx | 下次 npx 命令重新下载 | |
| Homebrew 旧版本 | XX MB | /opt/homebrew | 无 - 已被新版本替代 | |
废纸篓内容预览:
| 项目 | 大小 | 位置 | 删除后影响 | 清理命令 |
|---|
| 废纸篓 | XXX MB | ~/.Trash | 无 - 你已决定删除的文件 | 清空废纸篓 |
| npm _npx | X.X GB | ~/.npm/_npx | 下次npx命令会重新下载 | |
| Homebrew旧版本 | XX MB | /opt/homebrew | 无 - 已被新版本替代 | |
废纸篓内容预览:
1. [项目名] (X.X GB) - [状态描述]
1. [项目名] (X.X GB) - [状态描述]
| 子目录 | 大小 | 最后使用 |
|---|
| [子目录1] | X.X GB | >X个月 |
| [子目录2] | X.X GB | >X个月 |
问题: [需要用户回答的问题]
| 子目录 | 大小 | 最后使用 |
|---|
| [子目录1] | X.X GB | >X个月 |
| [子目录2] | X.X GB | >X个月 |
问题: [需要用户回答的问题]
2. Downloads 中的旧文件 (X.X GB)
2. Downloads中的旧文件 (X.X GB)
| 文件/目录 | 大小 | 年龄 | 建议 |
|---|
| [文件1] | X.X GB | - | [建议] |
| [文件2] | XXX MB | >X个月 | [建议] |
建议: 手动检查 Downloads,删除已不需要的文件。
| 文件/目录 | 大小 | 使用时长 | 建议 |
|---|
| [文件1] | X.X GB | - | [建议] |
| [文件2] | XXX MB | >X个月 | [建议] |
建议: 手动检查Downloads文件夹,删除不再需要的文件。
3. 停用的 Docker 项目 Volumes
3. 停用的Docker项目Volumes
| 项目前缀 | 可能包含的数据 | 需要你确认 |
|---|
| MySQL, Redis | 还在用吗? |
| Postgres | 还在用吗? |
注意: 我不会使用
,只会在你确认后删除特定项目的 volumes。
| 项目前缀 | 可能包含的数据 | 需要你确认 |
|---|
| MySQL、Redis | 还在使用吗? |
| Postgres | 还在使用吗? |
注意: 我不会使用
命令,只会在你确认后删除特定项目的volumes。
🔴 不建议删除的项目 (有价值的缓存)
🔴 不建议删除的项目 (有价值的缓存)
| 项目 | 大小 | 为什么要保留 |
|---|
| Xcode DerivedData | XX GB | [项目名]的编译缓存,删除后下次构建需要X分钟 |
| npm _cacache | X.X GB | 所有下载过的 npm 包,删除后需要重新下载 |
| ~/.cache/uv | XX GB | Python 包缓存,重新下载在中国网络下很慢 |
| [其他有价值的缓存] | X.X GB | [保留原因] |
| 项目 | 大小 | 保留原因 |
|---|
| Xcode DerivedData | XX GB | [项目名]的编译缓存,删除后下次构建需要X分钟 |
| npm _cacache | X.X GB | 所有已下载的npm包,删除后需要重新下载 |
| ~/.cache/uv | XX GB | Python包缓存,国内网络下重新下载速度很慢 |
| [其他有价值的缓存] | X.X GB | [保留原因] |
| 项目 | 大小 | 说明 |
|---|
| OrbStack/Docker | XX GB | 正常的 VM/容器占用 |
| [其他发现] | X.X GB | [说明] |
| 项目 | 大小 | 说明 |
|---|
| OrbStack/Docker | XX GB | 正常的虚拟机/容器占用 |
| [其他发现] | X.X GB | [说明] |
1. 清空废纸篓 (XXX MB)
1. 清空废纸篓 (XXX MB)
手动: Finder → 清空废纸篓
手动操作: Finder → 清空废纸篓
2. npm _npx (X.X GB)
2. npm _npx (X.X GB)
3. Homebrew 旧版本 (XX MB)
3. Homebrew旧版本 (XX MB)
brew cleanup --prune=0
**预计释放**: ~X.X GB
---
**需要你确认后执行**:
1. **[项目1]** - [确认问题]
2. **[项目2]** - [确认问题]
3. **Docker 项目** - 告诉我哪些项目确定不用了
brew cleanup --prune=0
**预计释放空间**: ~X.X GB
---
**需要你确认后执行**:
1. **[项目1]** - [确认问题]
2. **[项目2]** - [确认问题]
3. **Docker项目** - 告诉我哪些项目确定不再使用
Report Quality Checklist
报告质量检查清单
Before presenting the report, verify:
Step 4: Present Recommendations
步骤4:呈现建议
Format findings into actionable recommendations with risk levels:
macOS Cleanup Recommendations
macOS清理建议
Total space recoverable: ~XX GB
Current usage: XX%
🟢 Safe to Execute (Low Risk)
🟢 可安全执行(低风险)
These are safe to delete and will be regenerated as needed:
-
Empty Trash (~12 GB)
- Location: ~/.Trash
- Command:
-
Clear System Caches (~45 GB)
- Location: ~/Library/Caches
- Command:
rm -rf ~/Library/Caches/*
- Note: Apps may be slightly slower on next launch
-
Remove Homebrew Cache (~5 GB)
这些内容可安全删除,必要时会重新生成:
-
清空废纸篓 (~12 GB)
-
清理系统缓存 (~45 GB)
- 位置:~/Library/Caches
- 命令:
rm -rf ~/Library/Caches/*
- 注意:应用首次启动可能会稍慢
-
删除Homebrew缓存 (~5 GB)
🟡 Review Recommended (Medium Risk)
🟡 建议检查后操作(中风险)
Review these items before deletion:
-
Large Downloads (~38 GB)
- Location: ~/Downloads
- Action: Manually review and delete unneeded files
- Files: [list top 10 largest files]
-
Application Remnants (~8 GB)
- Apps: [list detected uninstalled apps]
- Locations: [list paths]
- Action: Confirm apps are truly uninstalled before deleting data
删除前请检查这些内容:
-
大体积下载文件 (~38 GB)
- 位置:~/Downloads
- 操作:手动检查并删除不需要的文件
- 文件列表:[列出前10个大文件]
-
应用残留 (~8 GB)
- 涉及应用:[列出检测到的已卸载应用]
- 位置:[列出路径]
- 操作:确认应用确实已卸载后再删除数据
🔴 Keep Unless Certain (High Risk)
🔴 非确定情况下请保留(高风险)
Only delete if you know what you're doing:
-
Docker Volumes (~3 GB)
- May contain important data
- Review with:
-
Time Machine Local Snapshots (~XX GB)
- Automatic backups, will be deleted when space needed
- Command to check:
tmutil listlocalsnapshots /
仅当你明确了解内容时再删除:
-
Docker卷 (~3 GB)
-
Time Machine本地快照 (~XX GB)
- 自动备份,空间不足时会自动删除
- 检查命令:
tmutil listlocalsnapshots /
Step 5: Execute with Confirmation
步骤5:获得确认后执行
CRITICAL: Never execute deletions without explicit user confirmation.
Interactive confirmation flow:
关键提示:未经用户明确确认,绝不能执行删除操作。
交互式确认流程:
Example from scripts/safe_delete.py
示例来自scripts/safe_delete.py
def confirm_delete(path: str, size: str, description: str) -> bool:
"""
Ask user to confirm deletion.
Args:
path: File/directory path
size: Human-readable size
description: What this file/directory is
Returns:
True if user confirms, False otherwise
"""
print(f"\n🗑️ Confirm Deletion")
print(f"━━━━━━━━━━━━━━━━━━")
print(f"Path: {path}")
print(f"Size: {size}")
print(f"Description: {description}")
response = input("\nDelete this item? [y/N]: ").strip().lower()
return response == 'y'
**For batch operations:**
```python
def batch_confirm(items: list) -> list:
"""
Show all items, ask for batch confirmation.
Returns list of items user approved.
"""
print("\n📋 Items to Delete:")
print("━━━━━━━━━━━━━━━━━━")
for i, item in enumerate(items, 1):
print(f"{i}. {item['path']} ({item['size']})")
print("\nOptions:")
print(" 'all' - Delete all items")
print(" '1,3,5' - Delete specific items by number")
print(" 'none' - Cancel")
response = input("\nYour choice: ").strip().lower()
if response == 'none':
return []
elif response == 'all':
return items
else:
# Parse numbers
indices = [int(x.strip()) - 1 for x in response.split(',')]
return [items[i] for i in indices if 0 <= i < len(items)]
def confirm_delete(path: str, size: str, description: str) -> bool:
"""
请求用户确认删除操作。
参数:
path: 文件/目录路径
size: 易读的大小格式
description: 该文件/目录的说明
返回:
用户确认则返回True,否则返回False
"""
print(f"\
🗑️ 确认删除")
print(f"━━━━━━━━━━━━━━━━━━")
print(f"路径: {path}")
print(f"大小: {size}")
print(f"说明: {description}")
是否删除此项目? [y/N]: ").strip().lower()
return response == 'y'
**批量操作确认:**
```python
def batch_confirm(items: list) -> list:
"""
显示所有项目,请求批量确认。
返回用户批准的项目列表。
"""
print("\
📋 待删除项目:")
print("━━━━━━━━━━━━━━━━━━")
for i, item in enumerate(items, 1):
print(f"{i}. {item['path']} ({item['size']})")
print("\
选项:")
print(" 'all' - 删除所有项目")
print(" '1,3,5' - 按编号删除特定项目")
print(" 'none' - 取消操作")
response = input("\
你的选择: ").strip().lower()
if response == 'none':
return []
elif response == 'all':
return items
else:
# 解析编号
indices = [int(x.strip()) - 1 for x in response.split(',')]
return [items[i] for i in indices if 0 <= i < len(items)]
Step 6: Verify Results
步骤6:验证结果
After cleanup, verify the results and report back:
Compare before/after
对比清理前后的空间使用情况
Calculate space recovered
计算回收的空间
(handled by scripts/cleanup_report.py)
(由scripts/cleanup_report.py处理)
✅ Cleanup Complete!
Before: 450 GB used (90%)
After: 385 GB used (77%)
━━━━━━━━━━━━━━━━━━━━━━━━
Recovered: 65 GB
Breakdown:
- System caches: 45 GB
- Downloads: 12 GB
- Homebrew cache: 5 GB
- Application remnants: 3 GB
⚠️ Notes:
- Some applications may take longer to launch on first run
- Deleted items cannot be recovered unless you have Time Machine backup
- Consider running this cleanup monthly
💡 Maintenance Tips:
- Set up automatic Homebrew cleanup: weekly
- Review Downloads folder monthly
- Enable "Empty Trash Automatically" in Finder preferences
✅ 清理完成!
清理前: 已使用450 GB (90%)
清理后: 已使用385 GB (77%)
━━━━━━━━━━━━━━━━━━━━━━━━
回收空间: 65 GB
空间回收明细:
- 系统缓存: 45 GB
- 下载文件: 12 GB
- Homebrew缓存: 5 GB
- 应用残留: 3 GB
⚠️ 注意事项:
- 部分应用首次启动可能会耗时更久
- 删除的项目除非有Time Machine备份,否则无法恢复
- 建议每月进行一次此类清理
💡 维护建议:
- 设置Homebrew自动每周清理:
- 每月检查Downloads文件夹
- 在Finder偏好设置中启用“自动清空废纸篓”
Never delete these without explicit user instruction:
- , , content
- Active project directories
- Database files (*.db, *.sqlite)
- Configuration files for active apps
- SSH keys, credentials, certificates
- Time Machine backups
未经用户明确指示,绝不能删除以下内容:
- 、、中的内容
- 活跃的项目目录
- 数据库文件(.db、.sqlite)
- 正在使用的应用的配置文件
- SSH密钥、凭据、证书
- Time Machine备份
Require Sudo Confirmation
需要Sudo权限的操作需确认
These operations require elevated privileges. Ask user to run commands manually:
- Clearing (system-wide)
- Clearing (system logs)
- Clearing (system temp)
Example prompt:
⚠️ This operation requires administrator privileges.
Please run this command manually:
sudo rm -rf /Library/Caches/*
⚠️ You'll be asked for your password.
以下操作需要提升权限。请让用户手动运行命令:
- 清理(系统级)
- 清理(系统日志)
- 清理(系统临时文件)
提示示例:
⚠️ 此操作需要管理员权限。
请手动运行以下命令:
sudo rm -rf /Library/Caches/*
⚠️ 运行时会要求你输入密码。
Backup Recommendation
备份建议
Before executing any cleanup >10GB, recommend:
💡 Safety Tip:
Before cleaning XX GB, consider creating a Time Machine backup.
Quick backup check:
tmutil latestbackup
If no recent backup, run:
tmutil startbackup
清理空间超过10GB前,建议用户:
💡 安全提示:
在清理XX GB空间前,建议创建Time Machine备份。
快速检查备份情况:
tmutil latestbackup
若没有近期备份,请运行:
tmutil startbackup
"Operation not permitted" errors
“Operation not permitted”错误
macOS may block deletion of certain system files due to SIP (System Integrity Protection).
Solution: Don't force it. These protections exist for security.
macOS可能会因系统完整性保护(SIP)而阻止删除某些系统文件。
解决方案:不要强制删除。这些保护措施是为了安全考虑。
App crashes after cache deletion
删除缓存后应用崩溃
Rare but possible. Solution: Restart the app, it will regenerate necessary caches.
这种情况很少见,但有可能发生。解决方案:重启应用,它会重新生成必要的缓存。
Docker cleanup removes important data
Docker清理删除了重要数据
Prevention: Always list Docker volumes before cleanup:
bash
docker volume ls
docker volume inspect <volume_name>
预防措施:清理前始终列出Docker卷:
bash
docker volume ls
docker volume inspect <volume_name>
- - Scan and categorize cache directories
- - Detect orphaned application data
- - Find large files with smart filtering
- - Scan development environment resources
- - Interactive deletion with confirmation
- - Generate before/after reports
- - 扫描并分类缓存目录
- - 检测孤立的应用数据
- - 通过智能过滤查找大文件
- - 扫描开发环境资源
- - 带确认机制的交互式删除
- - 生成清理前后的报告
- - Detailed explanations of each cleanup target
- - How to use Mole alongside this skill
- - Comprehensive list of what to never delete
- - 每个清理目标的详细说明
- - 如何将Mole与本技能结合使用
- - 绝不能删除的内容的完整列表
Example 1: Quick Cache Cleanup
示例1:快速缓存清理
User request: "My Mac is running out of space, can you help?"
Workflow:
- Run quick diagnosis
- Identify system caches as quick win
- Present findings: "45 GB in ~/Library/Caches"
- Explain: "These are safe to delete, apps will regenerate them"
- Ask confirmation
- Execute:
rm -rf ~/Library/Caches/*
- Report: "Recovered 45 GB"
用户请求: "我的Mac空间不足,能帮忙清理吗?"
工作流:
- 运行快速诊断
- 识别系统缓存为快速清理目标
- 呈现结果: "~/Library/Caches中存在45 GB缓存"
- 说明: "这些可安全删除,应用会重新生成缓存"
- 请求确认
- 执行:
rm -rf ~/Library/Caches/*
- 报告: "已回收45 GB空间"
Example 2: Development Environment Cleanup
示例2:开发环境清理
User request: "I'm a developer and my disk is full"
Workflow:
- Run
scripts/analyze_dev_env.py
- Present Docker + npm + Homebrew findings
- Explain each category
- Provide cleanup commands with explanations
- Let user execute (don't auto-execute Docker cleanup)
- Verify results
用户请求: "我是开发者,我的磁盘满了"
工作流:
- 运行
scripts/analyze_dev_env.py
- 呈现Docker + npm + Homebrew的分析结果
- 解释每个分类
- 提供带说明的清理命令
- 让用户自行执行(绝不自动执行Docker清理)
- 验证结果
Example 3: Finding Large Files
示例3:查找大文件
User request: "What's taking up so much space?"
Workflow:
- Run
scripts/analyze_large_files.py --threshold 100MB
- Present top 20 large files with context
- Categorize: videos, datasets, archives, disk images
- Let user decide what to delete
- Execute confirmed deletions
- Suggest archiving to external drive
用户请求: "什么内容占用了这么多空间?"
工作流:
- 运行
scripts/analyze_large_files.py --threshold 100MB
- 呈现前20个大文件及相关上下文
- 分类:视频、数据集、归档文件、磁盘镜像
- 让用户决定删除哪些内容
- 执行已确认的删除操作
- 建议将文件归档到外部驱动器
- Start Conservative: Begin with obviously safe targets (caches, trash)
- Explain Everything: Users should understand what they're deleting
- Show Examples: List 3-5 example files from each category
- Respect User Pace: Don't rush through confirmations
- Document Results: Always show before/after space usage
- Educate: Include maintenance tips in final report
- Integrate Tools: Suggest Mole for users who prefer GUI
- 从保守开始:从明显安全的目标开始(缓存、废纸篓)
- 解释所有内容:用户应该了解他们要删除的是什么
- 提供示例:每个分类列出3-5个示例文件
- 尊重用户节奏:不要催促用户确认
- 记录结果:始终显示清理前后的空间使用情况
- 教育用户:在最终报告中包含维护建议
- 整合工具:为偏好图形界面的用户推荐Mole
When NOT to Use This Skill
不适用此技能的场景
- User wants automatic/silent cleanup (against safety-first principle)
- User needs Windows/Linux cleanup (macOS-specific skill)
- User has <10% disk usage (no cleanup needed)
- User wants to clean system files requiring SIP disable (security risk)
In these cases, explain limitations and suggest alternatives.
- 用户需要自动/静默清理(违反安全优先原则)
- 用户需要Windows/Linux系统的清理(本技能仅适用于macOS)
- 用户磁盘使用率<10%(无需清理)
- 用户需要清理需要禁用SIP的系统文件(存在安全风险)
在这些情况下,请说明限制并建议替代方案。",