docker-optimizer
Skill1 starsChanged 8 days agoMITView on GitHub
Audit and optimize Docker and Compose projects (Docker Engine 29, BuildKit/Buildx, Compose v2) for image size and layer count, build cache and multi-stage builds, runtime security (non-root, read-only, capabilities, secrets), supply-chain provenance/SBOM/scanning, compose healthchecks/resource limits/networking, startup and pull performance, with real before/after measurement. Always produces a written findings report and a fix plan for approval before touching code. Use this whenever the user mentions a huge/slow Docker image, Dockerfile review, multi-stage builds, BuildKit cache mounts, docker compose, container security, rootless Docker, image scanning/SBOM, `docker buildx`, or "optimize my Docker setup" -- even if they never say audit or optimize.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- nek1987/auto-agent-harnesstheir own version, first seen Oct 11, 2026
- BGLuis/skillstheir own version, first seen Oct 7, 2026
- impeto-ai/claude-skills-impetotheir own version, first seen May 18, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- nek1987/auto-agent-harness★ 4same name
- BGLuis/skills★ 1same name
- impeto-ai/claude-skills-impeto★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository44 other files it gives its agents.
- AGENTS.mdAGENTS.md
- architecture-optimizerSkill
- csharp-optimizerSkill
- cpp-optimizerSkill
- c-optimizerSkill
- go-optimizerSkill
- node-service-optimizerSkill
- ruby-optimizerSkill
- rust-optimizerSkill
- kubernetes-optimizerSkill
- terraform-optimizerSkill
- animate-cssSkill
- animejsSkill
- auto-animateSkill
- gsapSkill
- lenisSkill
- magicuiSkill
- motionSkill
- react-moveSkill
- react-springSkill
- react-three-fiberSkill
- theatrejsSkill
- threejsSkill
- optimizer-routerSkill
- bootstrap-optimizerSkill
- pandacss-optimizerSkill
- sass-scss-optimizerSkill
- stylex-optimizerSkill
- tailwindcss-optimizerSkill
- twind-optimizerSkill
- unocss-optimizerSkill
- vanilla-extract-optimizerSkill
- angular-optimizerSkill
- astro-optimizerSkill
- ui-components-optimizerSkill
- nextjsSkill
- node-optimizerSkill
- nuxt-optimizerSkill
- react-optimizerSkill
- remix-optimizerSkill
- solid-optimizerSkill
- svelte-optimizerSkill
- tanstack-start-optimizerSkill
- vue-optimizerSkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 1 is distinctive, and 4 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 15
Run python <skill-dir>/scripts/audit.py <repo-root> -- static scan for floating tags, missing users/healthchecks, apt/npm cache waste, …
- Very specific: line 17
Read references/tooling.md once: what can be measured here (docker buildx build, docker image history, dive, docker scout/Trivy/Grype, …
- Very specific: line 41
Use plan mode: EnterPlanMode (load with ToolSearch if deferred), write the plan, present with ExitPlanMode.
- Distinctive: line 60
Run as non-root: No secrets in layers; read-only rootfs where possible.
- Very specific: line 65
Docs move: Check the Engine 29/BuildKit/Compose docs for the installed version.
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Docker Optimizer
Audit a Docker/Compose setup, report what is slow, large or unsafe and why, agree a plan, then change it. Order: evidence, approval, edits. Image and runtime changes affect deployability and security; nothing is edited before approval.
Workflow
1. Scope (quick)
- Find the Dockerfiles/compose files and record: Docker Engine/BuildKit version, base images, build context, target platforms, registry, runtime user, orchestrator (Compose/K8s/PaaS), and deploy command.
- Run
python <skill-dir>/scripts/audit.py <repo-root>-- static scan for floating tags, missing users/healthchecks, apt/npm cache waste, secrets, privileged/host mounts, docker.sock exposure, compose limits and build-cache gaps, with file:line evidence. Use--jsonto post-process. - Classify the pain: image size/pull time, build time/cache, startup, runtime security, compose reliability, or supply chain. Ask which hurts if unclear.
- Read
references/tooling.mdonce: what can be measured here (docker buildx build,docker image history,dive,docker scout/Trivy/Grype, Compose logs).
2. Audit
The script finds cheap leads; you find the rest by reading the Dockerfile, .dockerignore, compose file and runtime entrypoint. Load only what applies:
| Area | Reference |
| Base images, multi-stage, layers, cache mounts, Buildx | references/build-images.md |
| Compose services, healthchecks, limits, networking, entrypoints | references/compose-runtime.md |
| Non-root, secrets, capabilities, rootless, provenance/SBOM/scanning | references/security-supply-chain.md |
| Pull/start performance, image size, registry/cache, observability | references/performance-observability.md |
| Measurement and honest reporting | references/tooling.md |
Measure, never guess. Build the real target with BuildKit, compare docker image history/dive and cold-pull times, run the container with production limits and measure startup/health. A clean build cache hides transfer and layer costs; report cold and warm.
Mark each finding Confirmed (build/image inspect/runtime evidence) or Suspected (needs measuring).
3. Report
Fill assets/report-template.md, save it as DOCKER_OPTIMIZATION_REPORT.md in the project root, and show the user. Five-line summary, findings table by impact/effort, then per-finding detail (evidence, why it hurts, fix, risk, rollback). Group near-duplicates.
4. Plan -- then stop for approval
Use plan mode: EnterPlanMode (load with ToolSearch if deferred), write the plan, present with ExitPlanMode; if unavailable show it in chat and wait for an explicit "go". Structure:
- Quick wins -- pin images, add
.dockerignore, reorder layers,npm ci/pip --no-cache-dir, clean apt lists, non-root USER, exec-form CMD, healthcheck, compose limits. Low risk. - Structural -- multi-stage build, distroless/slim runtime, cache mounts, Buildx cache import/export, compose healthchecks/depends_on, read-only rootfs/cap drop, secrets mounts, split build/runtime images. Name each behavior change.
- Heavy -- base-image family change, rootless/userns-remap, multi-arch, registry/SBOM policy, orchestrator migration. Separately approved. Each step: files touched, expected effect, how to verify, how to roll back.
5. Fix
Only approved items, in small groups. After each: docker buildx build for the target platform, docker run health/startup check, compose config/up, and the relevant scan. A break must trace to one change. Do not mix a base-image migration with optimization edits. If a change alters the runtime user, entrypoint, exposed ports or secrets, stop and ask.
6. Verify and wrap up
Re-measure the same target: image size (compressed/uncompressed), layer count, cold build/pull/start, cache hit, CPU/memory under load, scan findings and SBOM/provenance. State plainly what could not be measured. End with deferred items and one suggested next step.
Principles
- The smallest image is the one without build tools. Multi-stage + minimal runtime.
- Cache is layer order. Copy manifests/lockfiles before source; use BuildKit cache mounts.
- Run as non-root. No secrets in layers; read-only rootfs where possible.
- Pin what you ship. Tags/digests, not
latest; reproducible builds. - Compose is production config too. Healthchecks, limits, dependencies and networks are not optional.
- Scan and sign. SBOM/provenance and a scanner in CI; a clean image is part of the artifact.
- Measure cold and warm. Build cache, pull time and startup are different costs.
- Docs move. Check the Engine 29/BuildKit/Compose docs for the installed version.
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
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.

