Docker Optimize
Analyze and optimize Docker images for size and build speed
- Type
- Slash Command
- Repository
- jeremylongshore/tons-of-skills-marketplace
- GitHub stars
- 2.8k
- License
- MIT
- Repo last updated
- Sep 27, 2026
What Docker Optimize is
Docker Optimize is a slash command published in the jeremylongshore/tons-of-skills-marketplace repository on GitHub, which has about 2.8k stars. The repository describes itself as: “Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com.”
A slash command is a reusable prompt saved as a markdown file and run by typing its name after a slash. In Claude Code, custom commands have been merged into skills: a file in .claude/commands/ and a skill folder in .claude/skills/ both create the same kind of command, and existing command files keep working.
Docker Optimize gives you a repeatable way to run the same instructions without retyping them, optionally with arguments.
How to install Docker Optimize
Claude Code
- Download docker-optimize.md from the repository.
- Save it to ~/.claude/commands/ (all projects) or .claude/commands/ (one project). As a skill, you can instead save it as ~/.claude/skills/<name>/SKILL.md.
- Run it by typing / followed by its name.
Claude Cowork
- Turn the command into a skill: create a folder with the file saved as SKILL.md and zip it.
- In Customize → Skills, click +, then upload the ZIP.
- Run it from any task with / and the skill name.
New to extending Cowork? Our plugins guide and Customize guide explain how skills, plugins, and connectors fit together.
Inside the source file
An excerpt from plugins/packages/devops-automation-pack/plugins/03-docker/commands/docker-optimize.md, shared under the repository's MIT license. Read the full file on GitHub.
Analyzes existing Docker images and Dockerfiles, identifying size/speed bottlenecks and providing specific optimizations with before/after metrics.
When to Use This
- Image is larger than expected (>500MB for simple app)
- Build times are slow (>5 minutes)
- Want to reduce infrastructure costs
- Deploying to bandwidth-limited environments
- Image already optimized (<200MB, multi-stage build)
How It Works
You are a Docker optimization expert. When user runs /docker-optimize or /do:
- Analyze current state:
# Read existing Dockerfile
# Check image layers with: docker history <image>
# Calculate current size with: docker images <image>- Identify issues:
- Using bloated base images (ubuntu vs alpine)
- Missing multi-stage builds
- Poor layer caching (dependencies installed after code copy)
- Dev dependencies in production
- Large build context (.dockerignore missing)
- Unnecessary files in image
- Inefficient RUN commands (multiple layers)
- Calculate potential savings:
Current Image Size: 1,200 MB
Optimized Size: 150 MB
Reduction: 87% (1,050 MB saved)
Current Build Time: 5 min
Optimized Time: 1 min
Speedup: 80% faster- Provide optimized Dockerfile:
- Multi-stage build implementation
- Minimal base image selection
- Optimal layer ordering
- .dockerignore additions
- Combined RUN commands
- Non-root user
- Show side-by-side comparison:
- Before vs After metrics
- Specific changes explained
- Validation commands
Output Format
## Current State Analysis
**Image:** [image-name:tag]
**Base Image:** [current-base]
**Total Size:** [X MB]
**Build Time:** [Y min]
**Layers:** [N layers]
## Issues Identified
1. **[Issue]** - Impact: [size/time impact]
2. **[Issue]** - Impact: [size/time impact]
3. **[Issue]** - Impact: [size/time impact]
## Optimization Plan
**Target:**
- Size: [X MB] (↓ [Y]% reduction)
…# Optimized Dockerfile
[Complete optimized version with inline comments]# Updated .dockerignore
[Additions to reduce build context]## Before vs After
| Metric | Before | After | Improvement |
|--------------|-----------|-----------|-------------|
| Image Size | [X MB] | [Y MB] | ↓ [Z]% |
| Build Time | [X min] | [Y min] | ↓ [Z]% |
| Layers | [N] | [M] | Optimized |
| Base Image | [old] | [new] | Smaller |
| Security | root ️ | non-root | Hardened |
## Key Optimizations
1. **[Optimization]** - Saves [X MB / Y sec]
2. **[Optimization]** - Saves [X MB / Y sec]
3. **[Optimization]** - Saves [X MB / Y sec]Examples
Example 1: Bloated Node.js Image
User: /do (with existing Dockerfile)
Current Dockerfile:
FROM node:20
WORKDIR /app
COPY . .
RUN npm install
EXPOSE 3000
CMD ["node", "index.js"]Analysis:
## Current State Analysis
**Image:** my-app:latest
**Base Image:** node:20 (full Debian-based, ~900MB)
**Total Size:** 1,200 MB
**Build Time:** 3 min
**Layers:** 6 layers
## Issues Identified
1. **Bloated base image (node:20)** - Impact: +900MB
- Using full Debian when Alpine works
- Includes unnecessary build tools
2. **No multi-stage build** - Impact: +200MB
- Dev dependencies in production image
- npm cache included in final image
…Optimized Dockerfile:
# Multi-stage build for Node.js
# Before: 1,200 MB | After: 150 MB (87% reduction)
# Stage 1: Build environment
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files FIRST (better caching)
# Changed: This layer only rebuilds when dependencies change
COPY package*.json ./
# Install ALL dependencies (dev + production)
RUN npm ci
# Copy source code AFTER installing deps
COPY . .
…Updated .dockerignore:
# Prevent unnecessary files in build context
node_modules
npm-debug.log
.git
.gitignore
.env
.env.local
README.md
.vscode
.idea
.DS_Store
dist
build
coverage
.nyc_output
*.mdBefore vs After:
Key Optimizations:
- Multi-stage build - Saves 200MB
- Separates build and runtime environments
- Excludes dev dependencies from production
- Alpine base image - Saves 860MB
Before you install
- Read the whole file first. Skills, commands, and subagents are instructions Claude will follow, so make sure they match what you want.
- Check which tools, scripts, or MCP servers it uses. Local servers and scripts run with your permissions.
- Try it in a test project or a copy of your files before pointing it at real work.
- Pin the version you tested, and review changes before updating.
- Watch for instructions that fetch web content or run shell commands; those are where prompt injection risks start. See our prompt injection guide.
FAQ
What is Docker Optimize?
Docker Optimize is a slash command for Claude Code and Claude Cowork from the jeremylongshore/tons-of-skills-marketplace repository on GitHub. Analyze and optimize Docker images for size and build speed
How do I install Docker Optimize in Claude Code?
Download docker-optimize.md from the repository. Save it to ~/.claude/commands/ (all projects) or .claude/commands/ (one project). As a skill, you can instead save it as ~/.claude/skills/<name>/SKILL.md. Run it by typing / followed by its name.
Can I use Docker Optimize in Claude Cowork?
Turn the command into a skill: create a folder with the file saved as SKILL.md and zip it. In Customize → Skills, click +, then upload the ZIP. Run it from any task with / and the skill name.
Is Docker Optimize safe to install?
It is a third-party community resource, not reviewed by Anthropic or this site. Read the source file first, check which tools and connectors it uses, and install only from sources you trust.
Similar resources
- Secops Team Security Operations Team — 10 agents: Red, Blue, Hunt, Patch, Chain, Sast, Siem, Resp, Zero, Phish Plugin · jeremylongshore/tons-of-skills-marketplace
- Secret Scanner Scan codebase for exposed secrets, API keys, passwords, and sensitive credentials Plugin · jeremylongshore/tons-of-skills-marketplace
- Security Audit Reporter Generate comprehensive security audit reports Plugin · jeremylongshore/tons-of-skills-marketplace
- Secrets Manager Integrator Integrate with secrets managers (Vault, AWS Secrets Manager, etc) Plugin · jeremylongshore/tons-of-skills-marketplace
- Docker Security Scan Scans Docker containers and images for security vulnerabilities Slash Command · jeremylongshore/tons-of-skills-marketplace
- Docker Compose Create Generate docker-compose.yml for multi-service applications Slash Command · jeremylongshore/tons-of-skills-marketplace
- Dockerfile Generate Generate optimized Dockerfile with multi-stage builds Slash Command · jeremylongshore/tons-of-skills-marketplace
- Detect Bottlenecks Detect performance bottlenecks in application Slash Command · jeremylongshore/tons-of-skills-marketplace