Sponsor Suno AI Music arrow_forward
Slash Command

Dockerfile Generate

Generate optimized Dockerfile with multi-stage builds

Type
Slash Command
GitHub stars
2.8k
License
MIT
Repo last updated
Sep 27, 2026

What Dockerfile Generate is

Dockerfile Generate 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.

Dockerfile Generate gives you a repeatable way to run the same instructions without retyping them, optionally with arguments.

How to install Dockerfile Generate

Claude Code

  1. Download dockerfile-generate.md from the repository.
  2. 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.
  3. Run it by typing / followed by its name.

Claude Cowork

  1. Turn the command into a skill: create a folder with the file saved as SKILL.md and zip it.
  2. In Customize → Skills, click +, then upload the ZIP.
  3. 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/dockerfile-generate.md, shared under the repository's MIT license. Read the full file on GitHub.

Automatically generates production-ready Dockerfiles with multi-stage builds, security hardening, and optimizations based on your project type.

When to Use This

  • Starting new project containerization
  • Existing image is bloated (>500MB for simple app)
  • Want production-ready Docker setup
  • Need security best practices (non-root user)
  • Complex multi-service setup (use /docker-compose-create instead)

How It Works

You are a Docker expert. When user runs /dockerfile-generate or /dg:

  1. Detect project type:
   # Check for language-specific files
   package.json     → Node.js
   requirements.txt → Python
   go.mod          → Go
   pom.xml         → Java
   Gemfile         → Ruby
   Cargo.toml      → Rust
  1. Ask key questions:
  • Application entry point? (main.js, app.py, etc.)
  • Exposed port? (default: 3000, 8000, 8080)
  • Build step required? (TypeScript, compiled languages)
  • Health check endpoint? (e.g., /health, /api/health)
  1. Generate optimized Dockerfile:
  • Multi-stage build (if applicable)
  • Minimal base image (alpine, slim, distroless)
  • Non-root user
  • Proper layer caching
  • Health check
  • Security best practices
  1. Create .dockerignore:
  • Exclude node_modules, venv, build artifacts
  • Exclude .git, .env, secrets
  • Reduce build context size
  1. Provide build instructions:
  • How to build image
  • How to run container
  • How to verify optimization

Output Format

# Dockerfile
[Complete optimized Dockerfile with comments]
# .dockerignore
[Complete file]
## Build Instructions

### Build:

docker build -t app-name:latest .


### Run:

docker run -p 3000:3000 app-name:latest


### Verify size:

docker images app-name:latest


## Expected Results

- Image Size: ~150-200MB (Node.js/Python)
- Image Size: ~10-50MB (Go/Rust)
- Build Time: <2 minutes
- Security: Non-root user, minimal base

Examples

Example 1: Node.js Express API

User: /dg (in Node.js project with package.json)

Questions:

  • Entry point? → src/index.js
  • Port? → 3000
  • Build step? → Yes, TypeScript compilation
  • Health endpoint? → /health

Output:

# Multi-stage Dockerfile for Node.js Express API
# Optimized for production: ~150MB final image

# Stage 1: Build environment
FROM node:20-alpine AS builder

WORKDIR /app

# Copy dependency files first (better caching)
COPY package*.json ./

# Install all dependencies (including dev deps for build)
RUN npm ci

# Copy source code
COPY . .

# Build TypeScript
…
# .dockerignore
node_modules
dist
build
npm-debug.log
.env
.env.local
.git
.gitignore
*.md
.vscode
.idea
.DS_Store
coverage
.nyc_output

Example 2: Python Flask API

User: /dg (in Python project with requirements.txt)

Questions:

  • Entry point? → app.py
  • Port? → 8000
  • Build step? → No
  • Health endpoint? → /api/health

Output:

# Optimized Dockerfile for Python Flask API
# Production-ready: ~120MB final image

FROM python:3.11-slim AS production

# Prevent Python from buffering stdout/stderr
ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1

# Create non-root user
RUN groupadd -g 1001 appuser && \
    useradd -r -u 1001 -g appuser appuser

WORKDIR /app

# Install system dependencies (if needed)
# RUN apt-get update && apt-get install -y --no-install-recommends \
#     gcc \
…
# .dockerignore
__pycache__
*.pyc
*.pyo
*.pyd
.Python
env
venv
.venv
.env
.git
.gitignore
*.md
.vscode
.pytest_cache
.coverage
htmlcov

Example 3: Go API (Static Binary)

User: /dg (in Go project with go.mod)

Questions:

  • Entry point? → cmd/api/main.go
  • Port? → 8080
  • Build step? → Yes, Go compilation
  • Health endpoint? → /health

Output:

# Multi-stage Dockerfile for Go API
# Produces tiny static binary: ~10-15MB

# Stage 1: Build environment
FROM golang:1.21-alpine AS builder

WORKDIR /app

# Copy go mod files first (better caching)
COPY go.mod go.sum ./
RUN go mod download

# Copy source code
COPY . .

# Build static binary
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o api ./cmd/api
…

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 Dockerfile Generate?

Dockerfile Generate is a slash command for Claude Code and Claude Cowork from the jeremylongshore/tons-of-skills-marketplace repository on GitHub. Generate optimized Dockerfile with multi-stage builds

How do I install Dockerfile Generate in Claude Code?

Download dockerfile-generate.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 Dockerfile Generate 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 Dockerfile Generate 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

Browse all skills, subagents, and plugins →

Listing data comes from the public GitHub repository and was last checked in September 2026. Excerpts are © their authors and shared under MIT. This directory is independent and not affiliated with Anthropic or the resource's authors.