agentsclimarketplace

Dockerfile optimizer

Skill Aryan1718/developer-agent-skills/skills/dockerfile-optimizer

A curated collection of reusable agent skills designed to streamline common development workflows, enabling modular automation, improved productivity, and consistent task execution across projects.

Install
npx -y skills add Aryan1718/developer-agent-skills --skill dockerfile-optimizer

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Use this skill when the user wants to audit, optimize, or fix a Dockerfile or docker-compose.yml. Triggers on: "optimize Dockerfile", "audit docker", "image too large", "docker security", "check docker-compose", or when Dockerfile or docker-compose.yml files are present in context.

SKILL.md

5.9 KB, ~1.0k tokens by cl100k_base, as published. Nobody here has run it

Dockerfile & Docker Compose Optimizer

What This Skill Does

Reads existing Dockerfile and docker-compose.yml files, identifies all issues across security, performance, caching, and size, then produces a full rewritten version with a detailed explanation of every change.

Step-by-Step Instructions

Step 1 — Read Files

  • Read the Dockerfile if present
  • Read docker-compose.yml or docker-compose.yaml if present
  • If neither exists, ask the user to paste or provide the file

Step 2 — Analyze Dockerfile for These Exact Issues

LAYER CACHING ISSUES:

  • COPY . . placed before npm install / pip install / apt-get (breaks cache on every code change)
  • Multiple RUN commands that should be chained with && to reduce layers
  • Static assets copied before dependency files

SECURITY VULNERABILITIES:

  • No USER directive (container runs as root)
  • Hardcoded secrets in ENV (passwords, API keys, tokens)
  • Using :latest tag instead of pinned version
  • COPY . . without .dockerignore (copies .git, .env, node_modules)
  • Packages installed without version pinning
  • ARG values that leak into image metadata

IMAGE SIZE BLOAT:

  • Large base image (ubuntu/debian when alpine works)
  • apt-get without --no-install-recommends flag
  • Missing cleanup: && rm -rf /var/lib/apt/lists/*
  • Dev dependencies bundled in production image
  • No multi-stage build for compiled or build-heavy apps

BEST PRACTICE VIOLATIONS:

  • Missing WORKDIR directive
  • Missing HEALTHCHECK directive
  • Wrong use of CMD vs ENTRYPOINT
  • ENV used for build-time values that should be ARG

Use scripts/analyze_dockerfile.py when a deterministic issue scan is useful. Read references/best_practices.md before rewriting unfamiliar stacks.

Step 3 — Analyze docker-compose.yml for These Exact Issues

DEPENDENCY ORDERING:

  • Missing depends_on between services
  • depends_on without condition: service_healthy
  • Services referencing each other without declared dependency

ENV VARIABLE LEAKS:

  • Hardcoded secrets in environment: block
  • No env_file alternative suggested
  • Missing .env.example recommendation

RELIABILITY ISSUES:

  • Missing restart policy
  • No memory or CPU limits
  • Unnamed volumes
  • Ports bound to 0.0.0.0 unnecessarily

NETWORKING:

  • All services on default network without isolation
  • Missing explicit network blocks

Use scripts/analyze_compose.py when you need a structured compose audit. Load references/best_practices.md for rewrite patterns and hardening guidance.

Step 4 — Score the Files

Start at 100. Deduct:

  • 20 points per critical security issue
  • 10 points per warning
  • 5 points per suggestion Minimum score is 0.

Step 5 — Output This Exact Report Format

───────────────────────────────────────── 🐳 DOCKERFILE OPTIMIZER REPORT ─────────────────────────────────────────

📋 SUMMARY Critical Issues : X Warnings : X Suggestions : X Score : XX / 100

───────────────────────────────────────── 🔴 CRITICAL ISSUES ───────────────────────────────────────── [1] <Issue Title> Line : <line number> Problem : <why this is dangerous or broken> Fix : <exactly what to change>

───────────────────────────────────────── 🟡 WARNINGS ───────────────────────────────────────── [same format]

───────────────────────────────────────── 🟢 SUGGESTIONS ───────────────────────────────────────── [same format]

───────────────────────────────────────── ✅ OPTIMIZED DOCKERFILE ───────────────────────────────────────── <full rewritten Dockerfile with a comment on every changed line explaining why>

───────────────────────────────────────── ✅ OPTIMIZED DOCKER-COMPOSE.YML ───────────────────────────────────────── <full rewritten docker-compose.yml — skip this section if no compose file was provided>

───────────────────────────────────────── 📚 WHAT CHANGED & WHY ─────────────────────────────────────────

  1. <change><one line reason>
  2. <change><one line reason> ...

Use scripts/generate_report.py to render the report. Pass it JSON outputs from the analyzers and, when available, the original file paths so it can synthesize complete rewritten files.

Step 6 — After Report

Ask the user: "Would you like me to generate an optimized .dockerignore file for this project?"

Rules

  • Always read the actual file, never assume content
  • Always output the complete rewritten file, never just diffs
  • Never remove functionality, only improve implementation
  • If multi-stage build is needed, write the full multi-stage version
  • If no docker-compose.yml exists, skip that section silently

What ships with it: 5 files

47.3 KB alongside SKILL.md, 3 of them executable

references/

scripts/

Gives 1 of the 12 instructions most containers cloud skills give in ~1.0k tokens

Counted across 607 of the 657 authors here whose files we hold, read 2026-08-07

  • Run containers as a non-root userin 66 of 607, across 46 files
  • Use multi-stage buildsin 53 of 607, across 44 files
  • Use Promise.all for independent operationsin 47 of 607, across 13 files
  • Import directly instead of barrel filesin 46 of 607, across 12 files
  • Use ternary instead of AND for conditionalsin 45 of 607, across 12 files
  • Use Set or Map for O(1) lookupsin 42 of 607, across 10 files
  • Create a .dockerignore filehere, and in 41 of 607, across 31 files
  • Read individual rule files for detailsin 39 of 607, across 9 files
  • Copy dependency files before source codein 36 of 607, across 23 files
  • Authenticate server actions like API routesin 35 of 607, across 7 files
  • Use next/dynamic for heavy componentsin 34 of 607, across 9 files
  • Use React.cache for per-request deduplicationin 34 of 607, across 10 files

Said here and by no other author read

  • read the Dockerfile if present
  • ask the user to provide missing files
  • analyze docker-compose files for exact issues
  • score the files from one hundred
  • output the complete rewritten file

Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.