docker-optimization

docker-optimization is a skill for Claude Code, Codex from stefan-jansen/claude-code-toolkit. It costs 65 tokens per session (4,051 once invoked), scanned B, original, MIT.

A guide to making Docker images—the packaged files used to run applications in containers—smaller, faster to build, and safer.

In plain words
What is it for?
Use it when writing or improving Dockerfiles, setting up containers for production or microservices, speeding up builds, reducing image size, or applying container security practices.
Why use it?
It helps remove unnecessary tools, caches, source files, and development dependencies that make images large or builds slow. It also addresses common Docker security concerns.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is COPY src/ ./src/.

Good fit Use it when writing or improving Dockerfiles, setting up containers for production or microservices, speeding up builds, reducing image size, or applying container security practices.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/stefan-jansen/claude-code-toolkit
agentmods
npx agentmods add skills/stefan-jansen/claude-code-toolkit/docker-optimization

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for docker-optimization

README.md
[![agentmods](https://agentmods.dev/badge/skills/stefan-jansen/claude-code-toolkit/docker-optimization/github.svg)](https://agentmods.dev/skills/stefan-jansen/claude-code-toolkit/docker-optimization)
Your own site
<a href="https://agentmods.dev/skills/stefan-jansen/claude-code-toolkit/docker-optimization"><img src="https://agentmods.dev/badge/skills/stefan-jansen/claude-code-toolkit/docker-optimization/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for docker-optimization

Your own site · 80×15
<a href="https://agentmods.dev/skills/stefan-jansen/claude-code-toolkit/docker-optimization"><img src="https://agentmods.dev/badge/skills/stefan-jansen/claude-code-toolkit/docker-optimization.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 65 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,051 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 3 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00065 $0.04051
Opus 5.5 $0.00026 $0.01620
Sonnet 5.5 $0.00013 $0.00810
Haiku 4.5 $0.00006 $0.00405

Measured 1mo ago against content hash 7a7c19073f7c, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade B, and why

docker-optimization scanned grade B with 3 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Asks for rootlowPrivilege escalation

A mod that escalates privileges can change anything on the machine, not only the project.

### Don't Run as Root

Downgraded: this mod is about security review, or the phrase is quoted, so it is likely naming the pattern rather than instructing it.

Recursive force deletemediumDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

&& rm -rf /var/lib/apt/lists/*

Downgraded: this mod is about security review, or the phrase is quoted, so it is likely naming the pattern rather than instructing it.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

RUN apt-get update && apt-get install -y curl
skills/general-dev/docker-optimization/SKILL.md · 671 lines

How it starts

The opening of the file, as written. The whole thing — 671 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Docker Optimization Patterns

Comprehensive guide to optimizing Docker images for size, build speed, and security. Covers multi-stage builds, layer caching strategies, security hardening, and production deployment patterns.


Quick Reference

When to use this skill:

  • Building production Docker images
  • Optimizing image size (reducing from 500MB+ to <100MB)
  • Improving Docker build times
  • Implementing Docker security best practices
  • Debugging slow builds or large images
  • Setting up Docker for microservices

Common triggers:

  • "My Docker image is too large"
  • "Docker builds take forever"
  • "How do I optimize this Dockerfile"
  • "Docker security best practices"
  • "Multi-stage build pattern"

Part 1: Multi-Stage Builds

The Problem: Bloated Images

Typical single-stage Dockerfile (800MB+ image):

FROM python:3.11
WORKDIR /app
COPY . .
RUN pip install -r requirements.txt
CMD ["python", "app.py"]

Problems:

  • Includes build tools (gcc, make, etc.) - 300MB+
  • Includes pip cache - 100MB+
  • Includes source .git directory - 50MB+
  • Includes test files and dev dependencies - 50MB+
  • Total: 800MB+ for simple Python app

The Solution: Multi-Stage Pattern

Optimized multi-stage Dockerfile (120MB image):

# Stage 1: Builder
FROM python:3.11-slim AS builder
WORKDIR /app

# Install build dependencies in separate layer
RUN apt-get update && apt-get install -y --no-install-recommends \
    gcc \
    && rm -rf /var/lib/apt/lists/*

# Copy only requirements first (cache optimization)
COPY requirements.txt .
RUN pip install --user --no-cache-dir -r requirements.txt

# Stage 2: Runtime
FROM python:3.11-slim
WORKDIR /app

# Copy only Python packages from builder
COPY --from=builder /root/.local /root/.local

# Copy only application code
COPY app.py .
COPY src/ ./src/

# Make sure scripts in .local are usable
ENV PATH=/root/.local/bin:$PATH

# Run as non-root user
RUN useradd -m appuser && chown -R appuser:appuser /app
USER appuser

CMD ["python", "app.py"]

Read the full file on GitHub · 671 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 671 lines · 65 tokens per session scan B 7a7c19073f7c

Subscribe to this mod's changes

docker-optimization is a skill published in the GitHub repository stefan-jansen/claude-code-toolkit (89 stars, last pushed 3mo ago), licensed MIT. It adds 65 tokens to every session and 4,051 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it B with 3 findings (asks for root, recursive force delete, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

agent-cloud-architect

Specialist subagent: Multi-cloud architecture, cost optimization, serverless vs containers, disaster recovery, and infrastructure design specialist. Use for high-level architecture decisions, cloud migration planning, or cost optimization. Trigger phrases: cloud, AWS, GCP, Azure, serverless, containers, Kubernetes…

travisjneuman/.claude · 75 tokens

docker-image-hardening

Use when you need to review or author a Dockerfile for multi-stage builds, minimal or distroless base images, non-root runtime, layer caching, .dockerignore hygiene, pinned digests, image vulnerability scanning, and SBOM generation.

FluxonLab/Skillry · 54 tokens

multi-stage-dockerfile

Create optimized multi-stage Dockerfiles for any language or framework.

FluxonLab/Skillry · 17 tokens

sbom-syft

Software Bill of Materials (SBOM) generation using Syft for container images, filesystems, and archives. Detects packages across 28+ ecosystems with multi-format output support (CycloneDX, SPDX, syft-json). Enables vulnerability assessment, license compliance, and supply chain security. Use when: (1) Generating SBOMs…

AgentSecOps/SecOpsAgentKit · 133 tokens

container-grype

Container vulnerability scanning and dependency risk assessment using Grype with CVSS severity ratings, EPSS exploit probability, and CISA KEV indicators. Use when: (1) Scanning container images and filesystems for known vulnerabilities, (2) Integrating vulnerability scanning into CI/CD pipelines with severity…

AgentSecOps/SecOpsAgentKit · 134 tokens

deploy-docker-compose

Run the Omnigent server as a Docker compose stack (server + Postgres) on any Docker host — your laptop, a VPS, EC2 by hand, or as the base layer of any container-platform deploy. Invoke when the user wants to build the image, bring up the compose stack, debug the stack on a host they already have, or extend the stack…

omnigent-ai/omnigent · 84 tokens