macos-disk-cleanup

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

macOS Disk Cleanup

macOS磁盘清理

Measure before deleting, spend the safe wins first, and treat anything holding local-only state as confirm-first — it needs the user's explicit go-ahead, because nothing re-downloads it.
删除前先进行计量,优先处理安全可清理的内容,所有仅存储本地状态的内容都属于需先确认类别——需要用户明确同意后再操作,因为这些内容无法重新下载。

Process

流程

  1. Measure top-level and home usage.
  2. Drill into the largest user-owned directories.
  3. Classify every candidate as a quick win or confirm-first, and present the two groups separately.
  4. Run the quick wins; ask before each confirm-first deletion.
  5. Re-measure and report the delta.
Done when every consumer above ~1G is classified, each confirm-first deletion was individually approved, and a before/after
df -h /
frames what the run actually freed.
  1. 测量根目录和用户主目录的使用情况。
  2. 深入查看占用空间最大的用户自有目录。
  3. 将所有待清理项分为快速清理项和需确认清理项,并分别展示这两类。
  4. 执行快速清理项;在执行每个需确认的删除操作前询问用户。
  5. 重新测量并报告磁盘空间变化量。
完成标志:所有占用空间超过约1GB的内容都已分类,每个需确认的删除操作都获得单独批准,且通过清理前后的
df -h /
命令统计实际释放的空间。

Measure

测量

bash
undefined
bash
undefined

1. Top-level

1. 根目录层级

du -sh /System /Users /private /Applications /Library 2>/dev/null | sort -rh
du -sh /System /Users /private /Applications /Library 2>/dev/null | sort -rh

2. Home breakdown

2. 用户主目录细分

du -sh ~/Library ~/Code ~/Downloads 2>/dev/null | sort -rh
du -sh ~/Library ~/Code ~/Downloads 2>/dev/null | sort -rh

3. Library breakdown

3. Library目录细分

du -sh ~/Library/Application\ Support/* ~/Library/Caches/* ~/Library/Group\ Containers/* 2>/dev/null | sort -rh | head -20

Aim the drill-down with the user's profile:

| Profile | Check first | Typical gain |
|---|---|---|
| Developer | Homebrew, uv/npm/pip, DerivedData, simulators | 10–20G |
| AI/ML user | Ollama unused models, HuggingFace, LM Studio | 5–15G |
| Chrome-heavy | OptGuideOnDeviceModel, GoogleUpdater | ~5G |
du -sh ~/Library/Application\ Support/* ~/Library/Caches/* ~/Library/Group\ Containers/* 2>/dev/null | sort -rh | head -20

根据用户的使用场景针对性地深入排查:

| 用户类型 | 优先检查内容 | 典型释放空间 |
|---|---|---|
| 开发者 | Homebrew、uv/npm/pip、DerivedData、模拟器 | 10–20GB |
| AI/ML用户 | Ollama未使用模型、HuggingFace、LM Studio | 5–15GB |
| 重度Chrome用户 | OptGuideOnDeviceModel、GoogleUpdater | ~5GB |

Quick Wins

快速清理项

Everything here rebuilds or re-downloads on demand — run without asking.
CommandFreesNotes
brew cleanup --prune=all
2–10GCached installers
uv cache clean --force
1–10Guv package cache
npm cache clean --force
500M–2Gnpm cache
pip3 cache purge
100–500Mpip cache
pre-commit clean
200–500Mpre-commit envs
rm -rf ~/Library/Developer/Xcode/DerivedData
500M–5GRebuilds on demand
xcrun simctl delete unavailable
1–10GUnused iOS simulators
以下所有内容都可按需重建或重新下载——无需询问即可执行。
命令释放空间说明
brew cleanup --prune=all
2–10GB缓存的安装包
uv cache clean --force
1–10GBuv包缓存
npm cache clean --force
500MB–2GBnpm缓存
pip3 cache purge
100–500MBpip缓存
pre-commit clean
200–500MBpre-commit环境
rm -rf ~/Library/Developer/Xcode/DerivedData
500MB–5GB可按需重建
xcrun simctl delete unavailable
1–10GB未使用的iOS模拟器

Path catalog

路径目录

For the per-path verdicts — Chrome, AI model caches, dev tool caches, and the confirm-first app data — read
references/paths.md
before proposing any deletion outside the quick wins above.
对于各路径的清理判定——Chrome、AI模型缓存、开发工具缓存以及需确认的应用数据——在提议清理上述快速清理项之外的任何内容前,请阅读
references/paths.md

After Cleanup

清理后

df -h /
lags because APFS local snapshots still hold the freed blocks. Check
tmutil listlocalsnapshots /
and tell the user they thin themselves within ~24h — the number is already correct underneath, so the next move is to wait rather than clean again.
df -h /
的结果会有延迟,因为APFS本地快照仍占用已释放的块。使用
tmutil listlocalsnapshots /
查看快照,告知用户快照会在约24小时内自动缩减——实际释放的空间已经生效,无需再次清理,只需等待即可。