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

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

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

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.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.svg" alt="Measured on agentmods" 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. Scan, not verified.
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 $0.00065 $0.04051
Opus 5 $0.00032 $0.02025
Sonnet 5 $0.00013 $0.00810
Haiku 4.5 $0.00006 $0.00405

Measured 4d ago against content hash 7a7c19073f7c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 4d 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. 4d 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 (85 stars, last pushed 1mo ago), licensed MIT. It adds 65 tokens to every session and 4,051 once invoked, about $0.0003 per session on Opus 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

playwright

Use when the task requires capturing or automating a real browser from the terminal.

openai/openai-agents-python · 19 tokens

implementation-final-review

Perform the repository's risk-tiered independent final review before implementation completion. Use only when explicitly invoked or when repository instructions require it after behavior-impacting implementation work; audit the complete task diff, supported contracts, lifecycle and security boundaries, complexity, and…

openai/openai-agents-python · 58 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

cuopt-install

Install cuOpt for Python, C, or server via pip, conda, or Docker; verify the install. For building cuOpt from source, see cuopt-developer.

NVIDIA/skills · 40 tokens

pdf-processing

Process and extract information from PDF documents. Use this skill when the user asks to read, analyze, or extract data from PDF files.

MervinPraison/PraisonAI · 30 tokens

document-service

This skill should be used when the user asks to "analyze this codebase", "document this service", "generate technical docs", "I inherited this code", "help me understand this system", "create docs for this project", "what does this system look like", "onboard me to this codebase", "this codebase has no docs"…

awslabs/agent-plugins · 141 tokens