Docker Image Optimizer Devops
Skill4 starsChanged 8 months agoMITView on GitHub
Audits and refactors Dockerfiles to reduce image size, improve security and speed up build times.
- Deletes or force-pushes
- Installs packages
In this repository2 other files it gives its agents.
- Draw.io ArchitectSkill
- rest-api-architectSkill
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 5 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 7
Use this skill when:
- Distinctive: line 15
Separate Build from Runtime: Use a heavy image (with compilers/SDKs) for building, but copy ONLY the final binary/artifacts into a minimal …
- Very specific: line 16
Named Stages: Use FROM base AS builder for readability.
- Very specific: line 19
Prefer Minimal: Default to alpine (≈5MB) or debian-slim (≈30MB) over ubuntu:latest (≈75MB).
- Very specific: line 23
Order Matters: Place instructions that change least often (like RUN apt-get update) at the top.
- Very specific: line 28
No-Install-Recommends: Always use --no-install-recommends with apt.
- Distinctive: line 29
Cache Cleaning: Remove package manager caches in the *same* layer as the installation.
- Very specific: line 30
Production Only: Ensure devDependencies or build-only headers never reach the final stage.
- Very specific: line 33
Exclusion: Every Docker project MUST have a .dockerignore to prevent .git, node_modules, tests/, and local logs from leaking into the build …
- Distinctive: line 36
When a user provides a Dockerfile, perform a Size Audit first.
- Distinctive: line 37
If the image is single-stage, provide a Refactored Multi-Stage Version.
- Very specific: line 38
Check for "Magic Versions" and suggest pinning specific tags (e.g., node:22.1.0-alpine instead of node:latest).
≈ “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.
Files
Context
Use this skill when:
- Creating a new
Dockerfile - A user complains about "slow builds" or "large images"
- Reviewing container security (reducing attack surface)
Optimization Pillars
1. Multi-Stage Strategy (The 2026 Standard)
- Separate Build from Runtime: Use a heavy image (with compilers/SDKs) for building, but copy ONLY the final binary/artifacts into a minimal runtime image (Alpine or Scratch).
- Named Stages: Use
FROM base AS builderfor readability.
2. Base Image Selection
- Prefer Minimal: Default to
alpine(≈5MB) ordebian-slim(≈30MB) overubuntu:latest(≈75MB). - Distroless: For production, suggest
gcr.io/distrolessto remove all shells and package managers.
3. Layer Management & Caching
- Order Matters: Place instructions that change least often (like
RUN apt-get update) at the top. Place source codeCOPYcommands at the bottom. - Atomic RUNs: Combine related commands using
&&and\to prevent intermediate layer bloat. Example:RUN apt-get update && apt-get install -y --no-install-recommends pkg && rm -rf /var/lib/apt/lists/*
4. Dependency Hygiene
- No-Install-Recommends: Always use
--no-install-recommendswithapt. - Cache Cleaning: Remove package manager caches in the same layer as the installation.
- Production Only: Ensure
devDependenciesor build-only headers never reach the final stage.
5. The .dockerignore File
- Exclusion: Every Docker project MUST have a
.dockerignoreto prevent.git,node_modules,tests/, and local logs from leaking into the build context.
Instructions for the Agent
- When a user provides a Dockerfile, perform a Size Audit first.
- If the image is single-stage, provide a Refactored Multi-Stage Version.
- Check for "Magic Versions" and suggest pinning specific tags (e.g.,
node:22.1.0-alpineinstead ofnode:latest).
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.

