dockerfile-best-practices

dockerfile-best-practices is a skill for Claude Code from KhaledSaeed18/dotclaude. It costs 107 tokens per session (1,484 once invoked), scanned C, original, MIT.

A guide for writing and reviewing Dockerfiles and Docker Compose setups for production services. Docker packages an application and its runtime into an image that can run consistently in different environments.

In plain words
What is it for?
Use it to create multi-stage builds, run as a non-root user, pin base images, improve build caching, add health checks, handle process signals, and keep secrets out of image layers.
Why use it?
It helps keep runtime images small and reproducible while reducing security and operational problems. It also prevents secrets, build tools, and unnecessary files from being shipped with the service.

Skill for Claude Code

Written for Claude Code: argument-hint in frontmatter.

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is HEALTHCHECK --interval=30s --timeout=3s --start-period=10s CMD node dist/healthcheck.js.

Part of the engineering plugin — 22 skills, 2 commands, 7 agents shipped together

Good fit Use it to create multi-stage builds, run as a non-root user, pin base images, improve build caching, add health checks, handle process signals, and keep secrets out of image layers.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/KhaledSaeed18/dotclaude
agentmods
npx agentmods add skills/khaledsaeed18/dotclaude/dockerfile-best-practices

Made for: Claude Code.

Or install engineering, the plugin that ships this one along with the rest of its 22 skills, 2 commands, 7 agents.

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 dockerfile-best-practices

README.md
[![agentmods](https://agentmods.dev/badge/skills/khaledsaeed18/dotclaude/dockerfile-best-practices/github.svg)](https://agentmods.dev/skills/khaledsaeed18/dotclaude/dockerfile-best-practices)
Your own site
<a href="https://agentmods.dev/skills/khaledsaeed18/dotclaude/dockerfile-best-practices"><img src="https://agentmods.dev/badge/skills/khaledsaeed18/dotclaude/dockerfile-best-practices/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for dockerfile-best-practices

Your own site · 80×15
<a href="https://agentmods.dev/skills/khaledsaeed18/dotclaude/dockerfile-best-practices"><img src="https://agentmods.dev/badge/skills/khaledsaeed18/dotclaude/dockerfile-best-practices.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 107 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,484 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00107 $0.01484
Opus 5.5 $0.00043 $0.00594
Sonnet 5.5 $0.00021 $0.00297
Haiku 4.5 $0.00011 $0.00148

Measured 4d ago against content hash ae06546e23f5, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade C, and why

dockerfile-best-practices scanned grade C with 1 finding 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.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

- `RUN` steps combined with `&&` and cleanup in the same step (`apt-get install ... && rm -rf /var/lib/apt/lists/*`); a later `rm` does not shrink an earlier layer.
.claude-plugin/plugins/engineering/skills/dockerfile-best-practices/SKILL.md · 82 lines

How it starts

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

A production image contains exactly what the process needs to run, built reproducibly, running as a non-root user, and stopping cleanly when asked. Everything below follows from those four properties.

Structure: multi-stage

# syntax=docker/dockerfile:1.7
FROM node:22.11-bookworm-slim AS deps
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN corepack enable && pnpm install --frozen-lockfile --prod=false

FROM deps AS build
COPY . .
RUN pnpm build && pnpm prune --prod

FROM node:22.11-bookworm-slim AS runtime
ENV NODE_ENV=production
WORKDIR /app
RUN groupadd -r app && useradd -r -g app -d /app app
COPY --from=build --chown=app:app /app/node_modules ./node_modules
COPY --from=build --chown=app:app /app/dist ./dist
COPY --chown=app:app package.json ./
USER app
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s CMD node dist/healthcheck.js
ENTRYPOINT ["node", "dist/server.js"]

Build stages hold compilers and dev dependencies; the runtime stage copies artifacts only.

Rules

Base images

  • Pin to a specific version tag (22.11-bookworm-slim), and for reproducible builds pin the digest (@sha256:...) with a tool (Renovate, Dependabot) to bump it.
  • Prefer -slim or distroless over alpine for glibc-dependent runtimes (Node native modules, Python wheels); alpine for Go static binaries is fine.
  • One process per container; no supervisord.

Layers and cache

  • Order from least to most frequently changed: base, system packages, dependency manifests, dependency install, source, build. Copy lockfiles before source so dependency layers cache.
  • RUN steps combined with && and cleanup in the same step (apt-get install ... && rm -rf /var/lib/apt/lists/*); a later rm does not shrink an earlier layer.
  • .dockerignore with .git, node_modules, build output, .env*, tests, docs; without it the build context and the cache invalidation are both wrong.
  • BuildKit cache mounts for package managers: RUN --mount=type=cache,target=/root/.npm npm ci.

Read the full file on GitHub · 82 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 Changed · +1 lines ae06546e23f5
  2. 2mo ago First seen · 81 lines · 107 tokens per session scan C d7a07860e992

Subscribe to this mod's changes

dockerfile-best-practices is a skill published in the GitHub repository KhaledSaeed18/dotclaude (8 stars, last pushed today), licensed MIT. It adds 107 tokens to every session and 1,484 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-22.

Related

dockerfile-best-practices compared with skills from other repositories

dockerfile-best-practices next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
dockerfile-best-practicesKhaledSaeed18/dotclaudeSkill8todayMITC107Claude Code
docker-debuggerOneWave-AI/claude-skillsSkill458yesterdayMITA35Claude Code, Codex
agents-v2-pylingxling/awesome-skills-cnSkill3431mo agoMITA39Claude Code
factory-environment-setupcurie-eng/curieSkill54todayApache-2.0A38Claude Code
factory-environment-maintenancecurie-eng/curieSkill54todayApache-2.0A46Claude Code
devopsMindrally/skillsSkill3251mo agoApache-2.0A25Claude Code
dockerMindrally/skillsSkill3251mo agoApache-2.0A16Claude Code