write-dockerfile

A guide for creating or improving a Dockerfile, the recipe used to build an application's container image. It covers the build process, runtime setup, caching, image size, and safer execution.

In plain words
What is it for?
Use it when creating a production Docker image, improving an existing image build, or preparing an application to run in a container.
Why use it?
It helps avoid unnecessarily large images, slow rebuilds, unsafe permissions, and accidentally including secrets in the image.

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/soulcodex/agentic/write-dockerfile
Any agent
npx skills add soulcodex/agentic --skill write-dockerfile
Clone the repo
git clone --depth 1 https://github.com/soulcodex/agentic

Made for: Claude Code, Codex.

Per session 61 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 712 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 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.00061 $0.00712
Opus 5 $0.00030 $0.00356
Sonnet 5 $0.00012 $0.00142
Haiku 4.5 $0.00006 $0.00071

Measured yesterday against content hash 02743cc4d1f3, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

write-dockerfile scanned grade A with 0 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 yesterday.

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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/devops/write-dockerfile/SKILL.md · 97 lines

How it starts

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

Write Dockerfile Skill

Create a production-ready Dockerfile for the current project. Scope boundary: Dockerfile and image concerns only. For local multi-service orchestration (compose.yaml, service dependencies/readiness, env files, volumes, migrations/seeds), use docker-compose-local-setup.

Step 1 — Detect Language and Framework

Read: package.json, go.mod, pyproject.toml, composer.json, or other manifest files. Identify:

  • Runtime and version (Node 22, Go 1.26, Python 3.12, PHP 8.3)
  • Build process (compile, bundle, install dependencies)
  • Entry point / start command

Step 2 — Apply Dockerfile Build and Runtime Best Practices

Multi-stage build: separate build stage from runtime stage to keep the final image small.

Layer caching: copy dependency manifests first, install, then copy source. This caches the dependency install layer and only invalidates it when dependencies change.

Non-root user: run the application as a non-root user in the final stage.

Minimal base image: use official slim/alpine variants for the runtime stage.

Health check: include a HEALTHCHECK instruction when the runtime supports it.

No secrets in the image: all secrets come from environment variables at runtime.

Step 3 — Write the Dockerfile

Structure:

# syntax=docker/dockerfile:1
# Stage 1: Build
FROM {build-image} AS builder
WORKDIR /app
# Copy manifests first (cache layer)
COPY {manifest-files} ./
RUN {install-dependencies}
# Copy source and build
COPY . .
RUN {build-command}

# Stage 2: Runtime
FROM {runtime-image}
WORKDIR /app
RUN addgroup --system app && adduser --system --ingroup app app
# Copy only what is needed to run
COPY --from=builder /app/{output} .
USER app
EXPOSE {port}
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
  CMD {health-check-command}
CMD ["{start-command}"]

Step 4 — Write .dockerignore

Also create or update .dockerignore to exclude:

  • .git/
  • node_modules/ (for Node projects)
  • test files, coverage reports
  • .env files
  • *.md documentation files

Read the full file on GitHub · 97 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. yesterday First seen · 97 lines · 61 tokens per session scan A 02743cc4d1f3

Subscribe to this mod's changes

write-dockerfile is a skill published in the GitHub repository soulcodex/agentic (10 stars, last pushed yesterday), licensed MIT. It adds 61 tokens to every session and 712 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

research-repository

Build a repository that makes findings findable, reusable, and cumulative across teams. Use when the same research keeps getting redone. For synthesising one study, use affinity-diagram.

Owl-Listener/designer-skills · 43 tokens

survey-design

Design unbiased survey instruments — question wording, scales, and sampling — to measure attitudes at scale. Use when you need quantitative breadth. For behavioural experiments, use a-b-test-design (prototyping-testing).

Owl-Listener/designer-skills · 47 tokens

localization-design

Design for multiple languages, writing directions, and cultural contexts — text expansion, RTL mirroring, and locale formats. Use when shipping beyond one locale. For the words themselves, use ux-writing (designer-toolkit).

Owl-Listener/designer-skills · 49 tokens

design-negotiation

Advocate for design quality, scope, and timeline with partners and leadership using evidence and shared goals. Use in the conversation itself. For the commercial vocabulary behind it, use business-design (ux-strategy).

Owl-Listener/designer-skills · 48 tokens

design-debt-audit

Inventory and prioritise accumulated design inconsistencies across a product. Use when drift has built up over time. For token coverage specifically use design-token-audit (designer-toolkit); for WCAG gaps use accessibility-audit (design-systems).

Owl-Listener/designer-skills · 59 tokens

design-impact-reporting

Communicate design's contribution to business and user outcomes in stakeholder language. Use when reporting results upward. For choosing the metrics in the first place, use metrics-definition (ux-strategy).

Owl-Listener/designer-skills · 44 tokens