dockerfile-best

dockerfile-best is a skill for Claude Code, Codex from cass-2003/local-workflow-skill. It costs 166 tokens per session (3,595 once invoked), scanned C, original, MIT.

Guidance for writing Dockerfiles, the recipe files used to build container images. It covers smaller images, cached build layers, non-root execution, health checks, security scanning, and builds for different processor types.

In plain words
What is it for?
Use it when creating or optimizing a Dockerfile, fixing slow builds, running containers safely, adding health checks, or preparing images for CI and multiple architectures.
Why use it?
It helps reduce image size and build time while avoiding common container security and process-management problems.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is -o /out/app ./cmd/server.

Good fit Use it when creating or optimizing a Dockerfile, fixing slow builds, running containers safely, adding health checks, or preparing images for CI and multiple architectures.

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/cass-2003/local-workflow-skill
agentmods
npx agentmods add skills/cass-2003/local-workflow-skill/dockerfile-best

Made for: Claude Code, Codex.

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/cass-2003/local-workflow-skill/dockerfile-best/github.svg)](https://agentmods.dev/skills/cass-2003/local-workflow-skill/dockerfile-best)
Your own site
<a href="https://agentmods.dev/skills/cass-2003/local-workflow-skill/dockerfile-best"><img src="https://agentmods.dev/badge/skills/cass-2003/local-workflow-skill/dockerfile-best/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

Your own site · 80×15
<a href="https://agentmods.dev/skills/cass-2003/local-workflow-skill/dockerfile-best"><img src="https://agentmods.dev/badge/skills/cass-2003/local-workflow-skill/dockerfile-best.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 166 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,595 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 2 findings. 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.00166 $0.03595
Opus 5.5 $0.00066 $0.01438
Sonnet 5.5 $0.00033 $0.00719
Haiku 4.5 $0.00017 $0.00360

Measured 3mo ago against content hash 35994a22bf23, 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 scanned grade C with 2 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 3mo 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.

gcc libffi-dev && rm -rf /var/lib/apt/lists/*

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

CMD wget --quiet --spider http://localhost:8080/healthz || exit 1
skills/backend-api/ours/dockerfile-best/SKILL.md · 399 lines

How it starts

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

Dockerfile Best Practices Skill — 镜像构建实战

何时使用

  • 写新 Dockerfile / 优化现有镜像
  • 镜像太大(> 1GB)需要瘦身
  • 排查 layer 缓存命中率低 / 构建慢
  • 容器以 root 跑 / 信号收不到 / 僵尸进程
  • CI 集成 SBOM / CVE 扫描 / 镜像签名

一、十条铁律

  1. Multi-stage build — build 阶段与运行阶段分离
  2. 最小 base image — distroless / scratch / alpine(按需)
  3. non-root user — 永不以 root 运行
  4. .dockerignore — 比 .gitignore 更严格
  5. 指令排序按变化频率 — 不变的在前,常变的在后(layer 缓存)
  6. 复制依赖清单先于源码 — package.json 先 COPY + install,再 COPY .
  7. COPY 不用 ADD(除非要解压 / URL)
  8. 明确 EXPOSE / HEALTHCHECK — 不依赖默认
  9. exec form CMD —CMD ["node","app.js"] 而非 CMD node app.js
  10. pin 版本 — node:20.11.1-alpine3.19 而非 node:latest

二、Multi-stage 标准模板(Node.js)

# ================ Stage 1: deps ================
FROM node:20.11.1-alpine AS deps
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN corepack enable && pnpm install --frozen-lockfile --prod=false

# ================ Stage 2: build ================
FROM node:20.11.1-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN corepack enable && pnpm build && pnpm prune --prod

# ================ Stage 3: runner ================
FROM node:20.11.1-alpine AS runner
WORKDIR /app

# non-root
RUN addgroup -S app && adduser -S app -G app
USER app

# 仅拷贝运行时所需
COPY --from=builder --chown=app:app /app/node_modules ./node_modules
COPY --from=builder --chown=app:app /app/dist ./dist
COPY --from=builder --chown=app:app /app/package.json ./

ENV NODE_ENV=production
ENV PORT=8080
EXPOSE 8080

HEALTHCHECK --interval=30s --timeout=3s --retries=3 \
  CMD wget --quiet --spider http://localhost:8080/healthz || exit 1

CMD ["node", "dist/server.js"]

三、Go 应用(极致小)

# ================ build ================
FROM golang:1.22-alpine AS build
WORKDIR /src

# 缓存 modules(独立 layer)
COPY go.mod go.sum ./
RUN go mod download

COPY . .
# 静态链接 + strip
RUN CGO_ENABLED=0 GOOS=linux go build \
    -ldflags="-s -w" \
    -trimpath \
    -o /out/app ./cmd/server

# ================ runtime ================
FROM gcr.io/distroless/static-debian12:nonroot
COPY --from=build /out/app /app
EXPOSE 8080
USER nonroot:nonroot
ENTRYPOINT ["/app"]

Read the full file on GitHub · 399 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. 3mo ago First seen · 399 lines · 166 tokens per session scan C 35994a22bf23

Subscribe to this mod's changes

dockerfile-best is a skill published in the GitHub repository cass-2003/local-workflow-skill (12 stars, last pushed 4mo ago), licensed MIT. It adds 166 tokens to every session and 3,595 once invoked, about $0.0007 per session on Opus 5.5. A static security scan graded it C with 2 findings (recursive force delete, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

dockerfile-best compared with skills from other repositories

dockerfile-best next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
dockerfile-bestcass-2003/local-workflow-skillSkill124mo agoMITC166Claude Code, Codex
deploy-docker-composeomnigent-ai/omnigentSkill12ktodayApache-2.0A84Claude Code, Codex
bdd-container-updateNVIDIA-AI-Blueprints/video-search-and-summarizationSkill2.0ktodayApache-2.0A117Cursor
securing-kubernetes-on-cloudxalgorix/xalgorixSkill1.6ktodayApache-2.0A80Claude Code, Codex
detecting-privilege-escalation-in-kubernetes-podsxalgorix/xalgorixSkill1.6ktodayApache-2.0A40Claude Code, Codex
docker-socket-mountPurpleAILAB/DecepticonSkill6.9k14d agoApache-2.0B67Claude Code
managing-astro-local-envastronomer/agentsSkill466yesterdayApache-2.0A63Claude Code