简介
一键安全清理 macOS/Linux 磁盘垃圾,支持 12+ 类缓存预览删除,零依赖纯 bash 实现,dry-run 模式避免误删风险
原始描述
One-command disk cleanup for macOS and Linux — trash, caches, temp files, old kernels, snap revisions, Homebrew, Docker, and Xcode artifacts. Use when user a...
通过你的 Agent 添加
安装目录:storage-cleanup/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
storage-cleanup 是一个跨平台的磁盘清理脚本,专为 macOS 和 Linux 设计,通过单一命令回收数十 GB 存储空间。使用前强烈建议先执行 --dry-run 预览模式,确认待删除项后再使用 --yes 执行清理。
基本命令:
bash scripts/cleanup.sh --dry-run # 预览模式,安全无风险
bash scripts/cleanup.sh --yes # 确认执行清理
bash scripts/cleanup.sh --yes --skip-docker --skip-kernels # 跳过特定类别
显著优点
- 零依赖设计:仅需 bash + awk,无需额外安装,兼容所有原生系统
- 跨平台智能适配:自动检测操作系统,仅执行适用的清理项,避免报错
- 12+ 清理目标:覆盖垃圾回收站、pip/Go/node 构建缓存、IDE 缓存、Docker 悬空镜像、旧内核/snap 版本、Homebrew 旧包、Xcode 构建产物等
- 安全优先架构:默认 dry-run 模式,必须显式
--yes 才执行删除;支持 --skip-* 参数精细控制跳过类别
- 量化反馈:清理前后显示磁盘使用变化,精确报告释放字节数
潜在缺点与局限性
- 非交互式清理:部分高价值目标(如 Ollama 模型、Conda 环境、Time Machine 快照)需手动处理,脚本仅提供命令指引
- 时间阈值固定:
/tmp 清理采用 60 分钟硬编码,无法自定义
- macOS 特权限制:部分目录可能需要
sudo 才能完全清理,脚本未自动提权
- 无配置文件:每次执行需通过命令行参数调整,不适合自动化定时任务的场景化配置
适合人群
- 开发者工作环境(JetBrains/VSCode/Xcode 重度用户)
- CI/CD 构建节点维护人员
- 磁盘空间紧张的笔记本/服务器用户
- 需要快速安全清理但不希望安装复杂清理工具的用户
常规风险
风险项
说明
缓解措施
误删数据
尽管 dry-run 可预览,但用户可能跳过检查
强制养成 --dry-run 优先习惯
旧内核删除
Linux 下删除非当前运行内核,极端情况影响启动
--skip-kernels 选项 + 保留当前运行内核的设计
Docker 清理
删除 dangling 镜像可能影响未标记的构建缓存
--skip-docker 选项,按需使用
Xcode 清理
DerivedData/Archives 删除后需重新构建/归档
开发环境可接受的重构成本
--yes 才执行删除;支持 --skip-* 参数精细控制跳过类别- 非交互式清理:部分高价值目标(如 Ollama 模型、Conda 环境、Time Machine 快照)需手动处理,脚本仅提供命令指引
- 时间阈值固定:
/tmp清理采用 60 分钟硬编码,无法自定义 - macOS 特权限制:部分目录可能需要
sudo才能完全清理,脚本未自动提权 - 无配置文件:每次执行需通过命令行参数调整,不适合自动化定时任务的场景化配置
适合人群
- 开发者工作环境(JetBrains/VSCode/Xcode 重度用户)
- CI/CD 构建节点维护人员
- 磁盘空间紧张的笔记本/服务器用户
- 需要快速安全清理但不希望安装复杂清理工具的用户
常规风险
风险项
说明
缓解措施
误删数据
尽管 dry-run 可预览,但用户可能跳过检查
强制养成 --dry-run 优先习惯
旧内核删除
Linux 下删除非当前运行内核,极端情况影响启动
--skip-kernels 选项 + 保留当前运行内核的设计
Docker 清理
删除 dangling 镜像可能影响未标记的构建缓存
--skip-docker 选项,按需使用
Xcode 清理
DerivedData/Archives 删除后需重新构建/归档
开发环境可接受的重构成本
| 风险项 | 说明 | 缓解措施 |
|---|---|---|
| 误删数据 | 尽管 dry-run 可预览,但用户可能跳过检查 | 强制养成 --dry-run 优先习惯 |
| 旧内核删除 | Linux 下删除非当前运行内核,极端情况影响启动 | --skip-kernels 选项 + 保留当前运行内核的设计 |
| Docker 清理 | 删除 dangling 镜像可能影响未标记的构建缓存 | --skip-docker 选项,按需使用 |
| Xcode 清理 | DerivedData/Archives 删除后需重新构建/归档 | 开发环境可接受的重构成本 |
总体评估:这是一个设计审慎、风险可控的系统维护工具,适合技术用户在日常开发维护中使用,但不建议对系统不熟悉的普通用户直接 --yes 执行。
技能正文
name: storage-cleanup
description: One-command disk cleanup for macOS and Linux — trash, caches, temp files, old kernels, snap revisions, Homebrew, Docker, and Xcode artifacts. Use when user asks to free storage, clean up disk, reclaim space, reduce disk usage, or encounters low disk / "disk full" warnings. Safe by default with dry-run mode. No dependencies beyond bash and awk.
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-runshows 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,--skip-snap - Reports savings — shows before/after disk usage and exact bytes freed
Quick Start
# Preview what would be cleaned (safe, changes nothing)
bash scripts/cleanup.sh --dry-run
# Clean everything
bash scripts/cleanup.sh --yes
# Clean but keep Docker and old kernels
bash scripts/cleanup.sh --yes --skip-docker --skip-kernels
What Gets Cleaned
Both Platforms
Target
Typical Size
Notes
Trash
1–50 GB
macOS ~/.Trash, Linux ~/.local/share/Trash
Stale /tmp
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
# Preview what would be cleaned (safe, changes nothing)
bash scripts/cleanup.sh --dry-run
# Clean everything
bash scripts/cleanup.sh --yes
# Clean but keep Docker and old kernels
bash scripts/cleanup.sh --yes --skip-docker --skip-kernels
Both Platforms
| Target | Typical Size | Notes |
|---|---|---|
| Trash | 1–50 GB | macOS ~/.Trash, Linux ~/.local/share/Trash |
Stale /tmp |
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 |
| Target | Typical Size | Notes |
|---|---|---|
| Apt cache | 200 MB–2 GB | apt clean |
| 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
brew cleanup --prune=7
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
--dry-run
Preview cleanup without deleting anything
--yes / -y
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
| Target | Typical Size | Notes |
|---|---|---|
| Homebrew old versions | 500 MB–5 GB | brew cleanup --prune=7 |
| 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 |
| Flag | Effect |
|---|---|
--dry-run |
Preview cleanup without deleting anything |
--yes / -y |
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→ollama rm <unused> - npm global cache:
npm cache clean --force - Conda envs:
conda env list→conda remove -n <env> --all - Compressed logs:
sudo find /var/log -name "*.gz" -delete - Flatpak (Linux):
flatpak uninstall --unused - Time Machine snapshots (macOS):
tmutil listlocalsnapshots /→tmutil deletelocalsnapshots <date>
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。