磁盘空间使用分析
system.analyze_disk_space_use
分析磁盘使用情况,找出占用空间最大的项目以及可释放空间的方案
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-02
- Stars
- ★ 155
- Forks
- 170
01 前言 Front Matter
- model
- haiku
- description
- Analyze disk usage to find the largest space consumers and reclaim options
02 资源文件 1
- 参考文档report.template.md1.4 KB
03 SKILL.md 正文
Goal
- Find what is consuming the most disk space, identify what is safely reclaimable (unused container/VM images, caches, logs) versus what needs manual review, and report the findings
- Never delete, move, or modify anything: analysis only
Workflow
Check Overall Disk Usage
- Run
df -hto see total/used/available space per volume - On macOS, the volume that actually holds user data is
/System/Volumes/Data, not/: use itsCapacity/Availcolumns to judge how urgent the situation is
Survey the Home Directory
-
List top-level home directory usage, largest first:
> du -sh ~/* 2>/dev/null | sort -rh -
Recurse one level at a time into whichever directory dominates (on macOS this is typically
~/Library), always sorting by size, until you reach the actual large items instead of just a big parent directory name:> /usr/bin/du -sh ~/Library/* 2>/dev/null | sort -rh | head -30 -
Track every directory measured along the way: it feeds the top-10 list in "Rank Findings And Write The Report"
Check Container and VM Engines First
- On a dev machine these are usually the single biggest consumer, because they cache every pulled/built image and rarely self-prune
- For every engine that is installed, check its own usage report before digging into
raw directory sizes:
- Docker: if
dockerexists, rundocker system df -vfor a per-image/per-volume breakdown; images withCONTAINERS= 0 are unused and reclaimable - Apple
containerCLI (native macOS containers): ifcontainerexists, runcontainer system df; its data lives under~/Library/Application Support/com.apple.containerand Docker's VM disk lives under~/Library/Containers/com.docker.docker - Other engines present (
podman,colima,lima,nerdctl): use their equivalentsystem df/ usage-report command
- Docker: if
- A builder container (e.g. Docker's
buildxstate volume, Apple'sbuildkitbuilder container) can be reported as "active" and excluded fromRECLAIMABLEby the tool even when it has grown very large- Size it directly with
/usr/bin/du -sh <PATH>and report it as a manual candidate, along with the reset command that would reclaim it (docker buildx prune --all, orcontainer builder stop && container builder delete)
- Size it directly with
Check Common Cache/Log Locations
- MacOS:
~/Library/Caches~/Library/Logs- Per-app
Cache/Code Cachefolders under~/Library/Application Support/<App> ~/.Trashtmutil listlocalsnapshots /: flag any entry that is not a normalcom.apple.os.update-*system snapshot
- Linux: use the equivalents instead:
~/.cache,/var/cache,/var/log, and package-manager caches (apt,dnf,pacman)
Spot-Check Dev Artifacts
- Look for large, likely-stale developer artifacts:
venv/.venvdirectories,node_modules, old or duplicate repo clones, and suspiciously named directories (backups,ancient_*,old_*) - Report these as "needs manual review", not as auto-recommended deletions: they can hold unique, irreplaceable data
Rank Findings and Write the Report
- For every candidate record: path, size, and whether it is safely reclaimable (rebuildable / re-pullable / re-cacheable) or needs manual review (may hold unique data)
- Fill in the template
.claude/skills/system.analyze_disk_space_use/report.template.md, formatted per.claude/skills/markdown.rules.md - Save the file in the current dir
- List the top 10 directories measured in "Survey The Home Directory" and "Check
Container And VM Engines First" by size, largest first; prefer the most specific
directory that explains the bytes over a vague ancestor (e.g. list the Docker VM
disk itself, not just
~/Library) - Every reclaim command in the report must come from the tool's own output (e.g
docker system df), never be guessed, and must be paired with the size it frees - Because the report describes commands, lead with a summary table of every command
and its estimated savings, then give the full nested breakdown per
.claude/skills/markdown.rules.md"List of Items" convention: one bold-labeled bullet per reclaimable item, with the command and size nested underneath it - Rank the breakdown by impact (space freed) first, then by risk
Create a Script to Perform the Cleanup
- Create a Bash script
cleanup.shin the current dir to perform the clean up but don't make it executable since the user needs to review it - For each potential space saving operation add a comment
- how safe it is to perform,
- how much space will be saved
- what is the command
# SAFETY: low (cache rebuilds automatically on next use) # SPACE FREED: ~20GB # COMMAND: delete uv package manager cache # rm -rf ~/.cache/uv
Constraints
- Only run read-only commands:
df,du,*system df,*ls,tmutil listlocalsnapshots,find(without-delete) - Never run a destructive command:
docker system prune,docker image rm,container image rm,rm -rf,container builder delete, etc.: only list them in the report as candidates for the user to run themselves - If a read-only command errors with an unexpected
usage:message, suspect a shell-hook rewrite and retry with the command's full binary path (e.g/usr/bin/du) - Do not enumerate every file: stop recursing into a directory once its largest child no longer meaningfully explains the space gap
Verification
- [ ] The report accounts for most of the gap between disk size and free space (the sum of reported items roughly explains where the used space went)
- [ ] No file was created, deleted, or modified other than the report itself
04 同仓库更多 Skills
Docker 文件同步与模板对齐
tutorial_in_60_mins.propagate_docker_changes
同步教程和课程项目的 Docker 文件,使其与 project_template 保持一致。
Markdown 合并至 Jupyter Notebook
tutorial_in_60_mins.merge_markdown
将 Markdown 文件的内容合并到 Jupyter Notebook 中。
60 分钟教程格式规范化
tutorial_in_60_mins.format
格式化目录,使其遵循「Learn X in 60 Minutes」(60 分钟学会 X)教程约定。
60 分钟教程目录创建
tutorial_in_60_mins.create
按照「Learn X in 60 Minutes」(60 分钟学会 X)约定创建教程目录。
todo.reorg_in_progress
Reorganize ai_task_queue.md so in-progress tasks, not-started tasks, and mislabeled topic headers sit under the right H1 stage
todo.reorg_headers
Reorganize ai_task_queue.md .md so every H2 topic matches ALL TOPICS and every H3 task sits under the right topic, keeping its H1 stage