Help us improve
Share bugs, ideas, or general feedback.
From dockercraft
Use when Docker images are too large, builds are slow, or layer caching is inefficient and needs optimization
npx claudepluginhub jugrajsingh/skillgarden --plugin dockercraftHow this skill is triggered — by the user, by Claude, or both
Slash command
/dockercraft:optimizingThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Analyze Docker image layers and apply optimizations for size and build performance.
Applies C++ Core Guidelines to write, review, or refactor C++ code. Enforces modern, safe, and idiomatic practices for C++17/20/23.
Share bugs, ideas, or general feedback.
Analyze Docker image layers and apply optimizations for size and build performance.
docker images {image_name} --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}"
docker history {image_name}:{tag} --no-trunc --format "table {{.Size}}\t{{.CreatedBy}}"
Glob: Dockerfile, Dockerfile.*
Read and analyze the current Dockerfile structure.
| Check | Optimization |
|---|---|
| Base image | Switch to alpine/slim/distroless |
| Multi-stage | Convert single-stage to multi-stage |
| Dev deps in runtime | Remove build tools from final stage |
| Package cache | Clean apt/apk cache in same RUN layer |
| Unnecessary files | Add to .dockerignore |
| Layer count | Combine related RUN commands |
| Check | Optimization |
|---|---|
| Layer ordering | Move frequently changing layers last |
| Cache mounts | Add --mount=type=cache for package managers |
| Dependency caching | Copy lock files before source code |
| BuildKit features | Enable DOCKER_BUILDKIT=1 |
| Check | Optimization |
|---|---|
| Lock file first | COPY package.json before COPY . |
| Source last | Application code copied last |
| Build cache | Use --mount=type=cache |
Gather image size, layer count, and Dockerfile content.
Compare against checklist and identify applicable improvements.
Show before/after comparison for each optimization with estimated impact.
Via AskUserQuestion:
If requested, rewrite Dockerfile with optimizations applied.
Use optimization-report.md template.
Before:
FROM python:3.12
COPY . .
RUN pip install -r requirements.txt
CMD ["python", "main.py"]
After:
FROM python:3.12-slim AS builder
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
FROM python:3.12-slim
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY . .
CMD ["python", "main.py"]
Before:
RUN pip install -r requirements.txt
After:
RUN --mount=type=cache,target=/root/.cache/pip \
pip install -r requirements.txt
| From | To | Savings |
|---|---|---|
| python:3.12 | python:3.12-slim | ~700MB |
| node:20 | node:20-slim | ~600MB |
| ubuntu:22.04 | debian:bookworm-slim | ~50MB |