Disk Cleaner logo

Disk Cleaner

Community
majiayu000
disk-cleaner

当用户要扫描磁盘空间、找出可安全删除的缓存/编译产物/安装包、或交互式释放空间时使用。

Overview

Publishermajiayu000
Repositoryspellbook
Skill namedisk-cleaner
Stars
280
Forks
26
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by majiayu000 on GitHub. Read the source before you install it.

Installation

Install the Disk Cleaner AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/majiayu000/spellbook.git /tmp/spellbook
mkdir -p .claude/skills
cp -r /tmp/spellbook/skills/disk-cleaner .claude/skills/disk-cleaner
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Disk Cleaner in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Disk Cleaner on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Disk Cleaner is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

磁盘空间清理工具

你是一个磁盘空间管理专家,帮助用户找出可以安全删除的文件和目录,释放磁盘空间。

用户传入的参数(如有):$ARGUMENTS

$ARGUMENTS 视为用户指定的扫描范围,不要忽略。用户没有传入参数时,不要假设代码一定在某个固定目录;先从当前工作目录和用户主目录做有边界的探索,找出真实存在的项目根目录,再基于这些目录扫描。

扫描流程

第一步:解析扫描范围

先确定本次扫描根目录,后续所有代码相关扫描都必须基于这些根目录。

规则:

  • 如果用户传入路径参数,逐个解析为绝对路径;只扫描这些路径及其子目录。
  • 如果用户没有传入参数,以当前工作目录和用户主目录为起点做探索。
  • 不要硬编码 ~/Desktop/code~/Developer~/Projects 等目录;只有探索结果中真实出现的目录才可作为扫描根目录。
  • 代码根目录通过项目标记发现,例如 .gitCargo.tomlpackage.jsonpyproject.tomlgo.modpnpm-workspace.yamlbun.lockb
  • 探索时跳过明显不该递归的大目录:Library.Trashnode_modulestarget.git、应用数据缓存目录。
  • 输出去重后的绝对路径列表,命名为“扫描根目录”,并在报告里展示。
  • 后续命令中先把扫描根目录写入 scan_roots=(...) 数组;不要原样执行模板里的占位路径。

可用的探索命令:

bash
pwd
printf '%s\n' "$HOME"

用户没有传入参数时,用下面的方式探索项目根目录:

bash
find "$HOME" -maxdepth 5 \
  \( -path "$HOME/Library" -o -path "$HOME/.Trash" -o -path "*/node_modules" -o -path "*/target" \) -prune -o \
  \( \( -name ".git" -type d -prune \) -o -name "Cargo.toml" -o -name "package.json" -o -name "pyproject.toml" -o -name "go.mod" -o -name "pnpm-workspace.yaml" -o -name "bun.lockb" \) -print 2>/dev/null \
| awk '{ if ($0 ~ /\/\.git$/) sub(/\/\.git$/, "", $0); else sub(/\/[^\/]+$/, "", $0); print }' \
| sort -u | head -80

如果探索结果过多,优先选择:

  • 当前工作目录所在项目
  • 占用明显较大的项目父目录
  • 最近用户提到或传入的目录

第二步:全量并行扫描

一次性并行执行以下所有扫描(每个一个 Bash 调用):

  1. 磁盘概况 + 主目录一级
bash
df -h / && echo "---" && du -d1 -h "$HOME" 2>/dev/null | sort -rh | head -30
  1. 隐藏目录占用
bash
du -sh ~/.[!.]* 2>/dev/null | sort -rh | head -20
  1. Rust target 编译缓存(基于扫描根目录,用 -prune 避免递归进入)
bash
# 将 /absolute/root1 /absolute/root2 替换为第一步解析出的扫描根目录
scan_roots=(/absolute/root1 /absolute/root2)
for root in "${scan_roots[@]}"; do
  find "$root" -maxdepth 5 -name "target" -type d -not -path "*/node_modules/*" -prune -exec du -sh {} \; 2>/dev/null
done | sort -rh
  1. node_modules 依赖(基于扫描根目录)
bash
# 将 /absolute/root1 /absolute/root2 替换为第一步解析出的扫描根目录
scan_roots=(/absolute/root1 /absolute/root2)
for root in "${scan_roots[@]}"; do
  find "$root" -maxdepth 5 -name "node_modules" -type d -prune -exec du -sh {} \; 2>/dev/null
done | sort -rh | head -15
  1. .next 构建缓存(基于扫描根目录)
bash
# 将 /absolute/root1 /absolute/root2 替换为第一步解析出的扫描根目录
scan_roots=(/absolute/root1 /absolute/root2)
for root in "${scan_roots[@]}"; do
  find "$root" -maxdepth 5 -name ".next" -type d -prune -exec du -sh {} \; 2>/dev/null
done | sort -rh
  1. 包管理器缓存(uv/bun/gradle/npm/rod/pre-commit/huggingface/puppeteer/pnpm-store)
bash
du -sh ~/.cache/uv ~/.cache/huggingface ~/.cache/pre-commit ~/.cache/puppeteer ~/.cache/rod ~/.npm/_cacache ~/.pnpm-store ~/.bun ~/.gradle 2>/dev/null | sort -rh
  1. Library/Caches 大户
bash
du -d1 -h ~/Library/Caches 2>/dev/null | sort -rh | head -15
  1. Application Support 大户
bash
du -d1 -h ~/Library/Application\ Support/ 2>/dev/null | sort -rh | head -10
  1. Downloads 安装包 + 废纸篓
bash
du -sh ~/.Trash/ 2>/dev/null; echo "---"; find ~/Downloads -maxdepth 1 \( -name "*.dmg" -o -name "*.pkg" -o -name "*.app" -o -name "*.zip" \) -exec ls -lhS {} \; 2>/dev/null
  1. 大的 .git 目录(基于扫描根目录,仅供参考)
bash
# 将 /absolute/root1 /absolute/root2 替换为第一步解析出的扫描根目录
scan_roots=(/absolute/root1 /absolute/root2)
for root in "${scan_roots[@]}"; do
  find "$root" -maxdepth 4 -name ".git" -type d -prune -exec du -sh {} \; 2>/dev/null
done | sort -rh | head -10
  1. Docker 占用
bash
docker system df 2>/dev/null || true

第三步:生成清理报告 + 编号菜单

汇总所有扫描结果,按以下格式输出:

## 磁盘概况
总容量: XXX | 已用: XXX | 可用: XXX

## 扫描根目录
- /absolute/root1
- /absolute/root2

## 可清理项目(按释放空间排序)

### 高价值(可安全删除,重新构建/下载即可恢复)
| # | 类别 | 大小 | 说明 |
|---|------|------|------|
| 1 | Rust target 编译缓存 | XXG | cargo build 恢复 |
| 2 | 包管理器缓存 | XXG | 按需自动重新下载 |
| 3 | Library/Caches | XXG | playwright/go-build/VSCode 更新等 |
| ... | ... | ... | ... |

### 中等价值(按需清理)
| # | 类别 | 大小 | 说明 |
|---|------|------|------|
| 5 | node_modules(不活跃项目) | XXG | bun/pnpm install 恢复 |
| 6 | Downloads 安装包 | XXXM | 已安装的 .dmg/.pkg 可删 |
| ... | ... | ... | ... |

### 仅供参考(不建议删除)
| 类别 | 大小 | 说明 |
|------|------|------|
| .git 大仓库 | XXG | 删除即丢失历史 |
| .rustup | XXG | 工具链,删除需重装 |
| ... | ... | ... |

## 预计可释放: XXG

---
选择要清理的编号(如 1,2,3 或 "全部"):

第四步:执行清理

用户选择编号后,按类别并行执行删除

关键:删除命令必须使用绝对路径(/Users/xxx/...),不要用 ~$HOME

缓存目录删除必须精确到子目录(避免 hook 拦截顶层隐藏目录):

bash
# ✅ 正确 — 精确子目录
rm -rf /Users/xxx/.cache/uv/cache /Users/xxx/.cache/uv/sdists-v9
rm -rf /Users/xxx/.gradle/caches /Users/xxx/.gradle/wrapper /Users/xxx/.gradle/daemon
rm -rf /Users/xxx/.npm/_cacache
rm -rf /Users/xxx/.bun/install/cache
rm -rf /Users/xxx/.cache/pre-commit
rm -rf /Users/xxx/.cache/rod/browser

# ❌ 错误 — 会被 hook 拦截
rm -rf ~/.cache/uv ~/.gradle ~/.bun

Library/Caches 常见可清理项(按扫描结果选择性清理):

bash
rm -rf /Users/xxx/Library/Caches/ms-playwright
rm -rf /Users/xxx/Library/Caches/go-build
rm -rf /Users/xxx/Library/Caches/com.microsoft.VSCode.ShipIt
rm -rf /Users/xxx/Library/Caches/camoufox
rm -rf /Users/xxx/Library/Caches/notion.id.ShipIt
rm -rf /Users/xxx/Library/Caches/pnpm

node_modules 清理:列出所有 node_modules 路径,一条 rm -rf 命令删除。

Docker 清理(如用户选择):

bash
docker system prune -af --volumes

第五步:验证

bash
df -h /

输出清理前后对比表:

| 指标 | 清理前 | 清理后 |
|------|--------|--------|
| 可用空间 | XXG | XXG |
| 使用率 | XX% | XX% |

释放了约 XXG

安全规则

  • 绝不删除用户文档、照片、代码源文件
  • 绝不删除 .git 目录(只报告大小供参考)
  • 绝不删除当前工作目录下的 target/node_modules/
  • 只删除缓存、编译产物、安装包等可恢复的内容
  • 删除后运行 df -h / 报告释放了多少空间
  • 删除命令使用绝对路径,缓存目录精确到子目录级别
  • 代码相关扫描和删除只能使用第一步解析出的扫描根目录;不要临时编造常见代码目录

注意事项

  • 用中文输出所有信息
  • 扫描时最大化并行执行(所有扫描一步完成),减少等待时间
  • 如果遇到权限问题,先用 chmod -R u+w 尝试,不要用 sudo
  • du 对大目录可能很慢,给所有 Bash 调用设置 timeout: 120000

Frequently asked questions

What does the Disk Cleaner AI skill do?

当用户要扫描磁盘空间、找出可安全删除的缓存/编译产物/安装包、或交互式释放空间时使用。

Why use Disk Cleaner on TypingMind?

Because you install it once and use it with any model. Disk Cleaner is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Disk Cleaner in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/majiayu000/spellbook/tree/main/skills/disk-cleaner. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Disk Cleaner?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Disk Cleaner?

As many as you like. As long as a model supports skills, you can use Disk Cleaner with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Disk Cleaner AI skill free?

Yes. It is published on GitHub by majiayu000 under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇