Skip to content
Back to skills

Docker Space Optimizer

ASecurity

Trigger: docker ocupa mucho, liberar espacio docker, build cache, prune, docker disk usage. Diagnose and reclaim Kiri Docker space safely.

  • 3 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 9, 2026
ai-agentsdocker

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned November 20, 2026

npx -y skills add alvaroofernaandez/dotfiles --skill docker-space-optimizer --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Docker Space Optimizer?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Docker Space Optimizer
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/alvaroofernaandez-docker-space-optimizer/badge)](https://www.skillsdirectory.com/skills/alvaroofernaandez-docker-space-optimizer)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: docker-space-optimizer
description: "Trigger: docker ocupa mucho, liberar espacio docker, build cache, prune, docker disk usage. Diagnose and reclaim Kiri Docker space safely."
metadata:
  author: "alvaroofernaandez"
  version: "2.0"
---

## Activation Contract

Load when Docker images, build cache, volumes or Kiri's disk use too much space, after large builds, or when free space on `/` is low.

## Hard Rules

- Kiri is the only runtime. Act only when `docker context show` is `kiri`; refuse any other context (the script exits non-zero).
- Measure BEFORE and AFTER, and report the difference.
- Safe cleanup needs no confirmation: `docker container prune -f`, `docker image prune -f`, `docker builder prune -af`, `docker buildx prune --builder multiarch -af`.
- Destructive cleanup (`docker system prune -af --volumes`, `docker volume rm/prune`, `docker image prune -a`, `docker rmi`) runs ONLY after listing exactly what will be removed, with sizes, and getting explicit approval.
- Measure Kiri's real usage with `du -sh ~/Library/Application\ Support/Kiri` before and after, and report the measured number.
- Kiri's `vm/data.img` does NOT shrink by itself after deletes. `scripts/cleanup.sh` ends with `fstrim` on the VM's ext4 through a throwaway volume (`kiri-fstrim-probe`), which returns freed blocks to macOS (verified 2026-11-19: 49.4 → 25.2 GB real). Never mount `/dev/vda` directly. Report the measured `du -h vm/data.img` before/after, never an assumed number.
- Manual trim without pruning: `docker volume create kiri-fstrim-probe && docker run --rm --privileged -v kiri-fstrim-probe:/v alpine:3 fstrim -v /v; docker volume rm kiri-fstrim-probe`.

## Decision Gates

| Finding | Action |
|---|---|
| Build cache large | Safe cleanup (script) |
| Dangling images / stopped containers | Safe cleanup (script) |
| Unused tagged images | List `repo:tag`, size, age → ask |
| Unused volumes | List name, size, owning compose project → ask; never prune DB volumes silently |
| Context ≠ kiri | Stop; load `kiri-health` |

## Execution Steps

1. Diagnose: `df -h /`, `docker system df`, `docker system df -v`, `du -sh ~/Library/Application\ Support/Kiri`.
2. Run `scripts/cleanup.sh` (checks context, safe prunes incl. the `multiarch` builder cache, before/after report).
3. If more space is needed, present destructive candidates as a table and wait for approval.
4. Re-measure with step 1 commands.

## Output Contract

Return a table: free space on `/` before/after, Kiri data size before/after (measured), total reclaimed, what was removed, what was kept and why.

## References

- `scripts/cleanup.sh` — safe cleanup with before/after report.

Files in this skill

  • SKILL.md2.2 KB
  • scripts/cleanup.sh924 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.