agentleFS
jimtinjimtin/production-ai/skills/docker-disk-cleanup/SKILL.md

docker-disk-cleanup

Skill1 starsChanged 5 months agoMITView on GitHub

Conservative Docker-native disk cleanup for developer machines and local PR-gate hosts. Use when asked to clean Docker disk usage, reclaim Docker image/build-cache/volume space, run daily Docker cleanup, diagnose Docker disk pressure, or safely prune containers, networks, images, BuildKit cache, and unused volumes while preserving active services and gate work.

The file

Show its rules and text

We split this skill into the rules it gives an agent

14 rules. About 0 are common, 8 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill to reclaim Docker disk space without damaging active local services, test databases, or PR-gate runs.

    line 10
  2. Very specific:

    Start with an audit: filesystem free space, docker info, docker system df, containers, and volumes.

    line 15
  3. Very specific:

    Use scripts/docker-disk-cleanup.mjs.

    line 17
  4. Very specific:

    Do not use sudo.

    line 19
  5. Distinctive:

    Do not delete named project volumes manually.

    line 20
  6. Distinctive:

    Do not run overlapping cleanup jobs.

    line 22
  7. Distinctive:

    Treat Docker race errors such as containers disappearing between list and prune as recheck-and- continue signals unless the script reports …

    line 25
  8. Distinctive:

    Keep reports sanitized: do not print env values, tokens, auth files, or secret-looking strings.

    line 27
  9. Distinctive:

    Run a dry run first:

    line 31
  10. Distinctive:

    When volume risk is unclear:

    line 50
  11. Very specific:

    Audit first: Run audit or cleanup --dry-run.

    line 61
  12. Very specific:

    Use --active-gate-mode when a PR gate, test gate, or build is active.

    line 64
  13. Distinctive:

    Use a report directory under the local agent home, for example:

    line 84
  14. Very specific:

    Read references/safety-policy.md before changing cleanup behavior, adding new destructive operations, or adapting the skill to a …

    line 94

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Docker Disk Cleanup

Purpose

Use this skill to reclaim Docker disk space without damaging active local services, test databases, or PR-gate runs. Prefer the bundled script over ad hoc prune commands.

Operating Rules

  • Start with an audit: filesystem free space, docker info, docker system df, containers, and volumes.
  • Use scripts/docker-disk-cleanup.mjs; do not hand-roll prune order unless the script is missing or cannot run.
  • Do not use sudo.
  • Do not delete named project volumes manually. Let Docker remove only volumes it reports as dangling, after attachment checks.
  • Do not run overlapping cleanup jobs. The script uses a lock in the report directory.
  • Preserve active services. If gate-like containers are running, or the user says a gate is active, run active-gate mode so image and builder pruning use an age filter.
  • Treat Docker race errors such as containers disappearing between list and prune as recheck-and- continue signals unless the script reports a hard failure.
  • Keep reports sanitized: do not print env values, tokens, auth files, or secret-looking strings.

Quick Start

Run a dry run first:

node ~/.codex/skills/docker-disk-cleanup/scripts/docker-disk-cleanup.mjs audit
node ~/.codex/skills/docker-disk-cleanup/scripts/docker-disk-cleanup.mjs cleanup --dry-run

Run cleanup:

node ~/.codex/skills/docker-disk-cleanup/scripts/docker-disk-cleanup.mjs cleanup

For a known active PR gate or long validation run:

node ~/.codex/skills/docker-disk-cleanup/scripts/docker-disk-cleanup.mjs cleanup --active-gate-mode

When volume risk is unclear:

node ~/.codex/skills/docker-disk-cleanup/scripts/docker-disk-cleanup.mjs cleanup --skip-volumes

Workflow

  1. Confirm the target path. Probe the filesystem that actually holds Docker data or the active workspace. Pass it with --workspace <path> or set DOCKER_DISK_CLEANUP_WORKSPACE. If unsure, use the current working directory and say so.
  2. Audit first. Run audit or cleanup --dry-run. Read docker system df before deciding how aggressive cleanup should be.
  3. Check active work. Inspect running containers and the script's activeGateMode decision. Use --active-gate-mode when a PR gate, test gate, or build is active.
  4. Run serialized cleanup. The script plans commands in this order:
    • docker container prune -f
    • docker network prune -f
    • docker image prune -a ... -f
    • docker builder prune -a ... -f
    • dangling volume attachment checks
    • docker volume prune -a -f when supported, otherwise docker volume prune -f
    • final docker image prune -a ... -f
  5. Report the outcome. Include initial/final disk usage, Docker usage, mode, commands run, report path, removed-space summary when Docker provides one, skipped steps, and blockers.

Daily Automation Contract

A daily cleanup automation should run:

node ~/.codex/skills/docker-disk-cleanup/scripts/docker-disk-cleanup.mjs cleanup --workspace <workspace-path>

Use a report directory under the local agent home, for example:

--report-dir ~/.codex/automations/daily-docker-cleanup

Schedule dry runs first when moving the automation to a new machine.

Safety Policy

Read references/safety-policy.md before changing cleanup behavior, adding new destructive operations, or adapting the skill to a non-Docker-Desktop host.

The threat model lives in docker-disk-cleanup-threat-model.md; review it before publishing changes to cleanup behavior, report sinks, or scheduler integration.

Completion Blockers

  • Cleanup ran without a prior audit or dry-run-level evidence.
  • A second cleanup was launched while one was already running.
  • Active gate work was detected but broad image/build-cache pruning ran without an age filter.
  • Volumes were deleted manually by name instead of through Docker's unused-volume prune with attachment checks.
  • The report omits skipped steps, blockers, or whether active-gate mode was used.
  • Secret material or local auth paths were printed in a report or chat response.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.