Storage Cleanup
Reclaim tens of gigabytes in one command. No config files, no dependencies, no damage.
Why This Skill
Systems accumulate junk silently — IDE caches, old snap revisions, stale pip builds, forgotten trash, outdated kernels. Manually hunting them down wastes time and risks deleting the wrong thing.
This skill:
- - Scans 12+ cleanup targets across both macOS and Linux in a single pass
- Safe by default —
--dry-run shows exactly what would be cleaned before touching anything - Zero dependencies — pure bash + awk, works on any stock macOS or Linux install
- Cross-platform — auto-detects OS and runs only what applies (no errors on missing tools)
- Selective — skip any category with
--skip-kernels, --skip-docker, --skip-brew, INLINECODE4 - Reports savings — shows before/after disk usage and exact bytes freed
Quick Start
CODEBLOCK0
What Gets Cleaned
Both Platforms
| Target | Typical Size | Notes |
|---|
| Trash | 1–50 GB | macOS ~/.Trash, Linux INLINECODE6 |
| Stale INLINECODE7 |
1–10 GB | pip/npm/rust build dirs older than 60 min |
| pip cache | 50–500 MB |
pip cache purge |
| Go build cache | 100 MB–2 GB |
go clean -cache |
| pnpm / yarn / node caches | 50–500 MB | Safe to regenerate |
| JetBrains IDE cache | 1–10 GB | IntelliJ, PyCharm, WebStorm, etc. |
| Whisper model cache | 1–5 GB | Redownloads on demand |
| Chrome / Firefox cache | 200 MB–2 GB | Browsing cache only |
| Playwright browsers | 200 MB–1 GB | Redownloads on demand |
| Docker dangling images | 0–10 GB | Only unreferenced images + build cache |
Linux Only
| Target | Typical Size | Notes |
|---|
| Apt cache | 200 MB–2 GB | INLINECODE10 |
| Journal logs |
500 MB–4 GB | Vacuumed to 200 MB |
| Disabled snap revisions | 500 MB–5 GB | Old versions kept by snapd |
| Old kernels | 200–800 MB | Keeps current running kernel |
macOS Only
| Target | Typical Size | Notes |
|---|
| Homebrew old versions | 500 MB–5 GB | INLINECODE11 |
| Xcode DerivedData |
2–30 GB | Build artifacts, safe to clear |
| Xcode Archives | 1–20 GB | Old build archives |
| iOS DeviceSupport | 2–15 GB | Old device symbols |
| CoreSimulator caches | 500 MB–5 GB | Simulator disk images |
| Old user logs | 100 MB–1 GB | Logs older than 30 days |
Options
| Flag | Effect |
|---|
| INLINECODE12 | Preview cleanup without deleting anything |
| INLINECODE13 / INLINECODE14 |
Run without confirmation prompts |
|
--skip-kernels | Don't remove old kernels (Linux) |
|
--skip-snap | Don't remove disabled snap revisions (Linux) |
|
--skip-docker | Don't prune Docker |
|
--skip-brew | Don't clean Homebrew |
Manual Extras
Targets the script doesn't touch (check manually if needed):
- - Ollama models:
ollama list → INLINECODE20 - npm global cache: INLINECODE21
- Conda envs:
conda env list → INLINECODE23 - Compressed logs: INLINECODE24
- Flatpak (Linux): INLINECODE25
- Time Machine snapshots (macOS):
tmutil listlocalsnapshots / → INLINECODE27
存储清理
一条命令即可回收数十GB空间。无需配置文件,无依赖,无损害。
为什么需要这个技能
系统会悄无声息地积累垃圾——IDE缓存、旧的snap版本、过期的pip构建、被遗忘的回收站、过时的内核。手动清理既浪费时间,又有误删重要文件的风险。
这个技能:
- - 扫描12+个清理目标,一次性覆盖macOS和Linux
- 默认安全——--dry-run参数会在实际清理前精确显示将要清理的内容
- 零依赖——纯bash+awk脚本,可在任何标准macOS或Linux系统上运行
- 跨平台——自动检测操作系统,仅运行适用的清理项(缺失工具时不会报错)
- 可选择——使用--skip-kernels、--skip-docker、--skip-brew、--skip-snap跳过任意类别
- 报告节省空间——显示清理前后的磁盘使用情况以及精确释放的字节数
快速开始
bash
预览将要清理的内容(安全操作,不会更改任何内容)
bash scripts/cleanup.sh --dry-run
清理所有内容
bash scripts/cleanup.sh --yes
清理但保留Docker和旧内核
bash scripts/cleanup.sh --yes --skip-docker --skip-kernels
清理内容
双平台通用
| 目标 | 典型大小 | 说明 |
|---|
| 回收站 | 1–50 GB | macOS ~/.Trash,Linux ~/.local/share/Trash |
| 过期的/tmp |
1–10 GB | 超过60分钟的pip/npm/rust构建目录 |
| pip缓存 | 50–500 MB | pip cache purge |
| Go构建缓存 | 100 MB–2 GB | go clean -cache |
| pnpm / yarn / node缓存 | 50–500 MB | 可安全重新生成 |
| JetBrains IDE缓存 | 1–10 GB | IntelliJ、PyCharm、WebStorm等 |
| Whisper模型缓存 | 1–5 GB | 按需重新下载 |
| Chrome / Firefox缓存 | 200 MB–2 GB | 仅浏览器缓存 |
| Playwright浏览器 | 200 MB–1 GB | 按需重新下载 |
| Docker悬空镜像 | 0–10 GB | 仅未引用的镜像和构建缓存 |
仅限Linux
| 目标 | 典型大小 | 说明 |
|---|
| Apt缓存 | 200 MB–2 GB | apt clean |
| 日志文件 |
500 MB–4 GB | 压缩至200 MB |
| 已禁用的snap版本 | 500 MB–5 GB | snapd保留的旧版本 |
| 旧内核 | 200–800 MB | 保留当前运行的内核 |
仅限macOS
| 目标 | 典型大小 | 说明 |
|---|
| Homebrew旧版本 | 500 MB–5 GB | brew cleanup --prune=7 |
| Xcode DerivedData |
2–30 GB | 构建产物,可安全清除 |
| Xcode归档 | 1–20 GB | 旧的构建归档 |
| iOS DeviceSupport | 2–15 GB | 旧的设备符号文件 |
| CoreSimulator缓存 | 500 MB–5 GB | 模拟器磁盘镜像 |
| 旧用户日志 | 100 MB–1 GB | 超过30天的日志 |
选项
| 标志 | 效果 |
|---|
| --dry-run | 预览清理内容,不删除任何文件 |
| --yes / -y |
运行时不提示确认 |
| --skip-kernels | 不移除旧内核(Linux) |
| --skip-snap | 不移除已禁用的snap版本(Linux) |
| --skip-docker | 不清理Docker |
| --skip-brew | 不清理Homebrew |
手动额外清理
脚本不会触及以下目标(如需清理请手动检查):
- - Ollama模型:ollama list → ollama rm <未使用的>
- npm全局缓存:npm cache clean --force
- Conda环境:conda env list → conda remove -n <环境名> --all
- 压缩日志:sudo find /var/log -name *.gz -delete
- Flatpak(Linux):flatpak uninstall --unused
- Time Machine快照(macOS):tmutil listlocalsnapshots / → tmutil deletelocalsnapshots <日期>