agentleFS
abevzabevz/devops-skills/skills/dockerfile-review/SKILL.md

dockerfile-review

Skill0 starsChanged 41 days agoMITView on GitHub

Use when reviewing a Dockerfile or image build for size, security, caching, or reproducibility. Mention "review this dockerfile", "container image review", or "why is my image huge"; use supply-chain-security for signing/provenance after build and pr-review for a diff with no image-build focus.

  • Pipes a download into a shell
  • Reads credentials
  • Deletes or force-pushes

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 4 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read the Dockerfile, build context, lockfiles, and supplied image metadata.

    line 18
  2. Distinctive:

    Do not copy build-only tools or secrets into the final stage.

    line 22
  3. Distinctive:

    Follow the Workflow, Safety rules, and Quality checklist below.

    line 26
  4. Distinctive:

    Use when reviewing a Dockerfile (or Containerfile) before it ships — new images, base image changes, or "the image is too big / too slow to …

    line 36
  5. Very specific:

    Use supply-chain-security instead for signing and provenance after build, and pr-review for a diff without a specific image-build focus.

    line 38
  6. Very specific:

    Never echo a secret discovered in a Dockerfile, .env, or image history — describe the exposure and the fix without quoting the value.

    line 86

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Dockerfile Review

TL;DR checklist

  • Inspect base image, build stages, final user, and copied artifacts.
  • Check reproducibility, cache behavior, image size, and secret exposure.
  • Report concrete changes to the final image or build.

Key read-only checks

  • Read the Dockerfile, build context, lockfiles, and supplied image metadata.

Common pitfalls

  • Do not copy build-only tools or secrets into the final stage.

Agent procedure

Follow the Workflow, Safety rules, and Quality checklist below.

Quick references

  • references/examples.md

Last verified: unverified

When to use

Use when reviewing a Dockerfile (or Containerfile) before it ships — new images, base image changes, or "the image is too big / too slow to build / flagged by the scanner" complaints. Use supply-chain-security instead for signing and provenance after build, and pr-review for a diff without a specific image-build focus.

Goal

Catch image-build mistakes that cause bloated images, broken caching, security findings, or non-reproducible builds — with the concrete fix for each.

Workflow

  1. Base image — pinned to a specific version (ideally a digest), not latest; minimal variant where practical (-slim, distroless, alpine — noting musl caveats for Go/CGO and native deps); official or org-approved source.
  2. Multi-stage builds — build toolchain (compilers, dev headers, npm/go caches) stays in a builder stage; final stage copies only artifacts. A Go/Java/Node app shipping its compiler is the most common bloat finding.
  3. Non-root user — final stage sets USER to a non-root UID; file ownership (COPY --chown) matches. Flag images that only work as root.
  4. Layer hygiene — related RUN commands chained where it saves layers; package-manager caches cleaned in the same layer they're created (apt-get clean/rm -rf /var/lib/apt/lists/*, --no-cache for apk); no "delete in a later layer" pattern (the data is still in the earlier layer).
  5. Cache ordering — dependency manifests (go.mod, package.json, requirements.txt) copied and installed before copying the full source, so code changes don't bust the dependency cache.
  6. Secrets — no secrets via ARG/ENV/COPY (all end up readable in image history or layers); build-time secrets use BuildKit --mount=type=secret; .dockerignore excludes .env, .git, credentials.
  7. COPY vs ADD — COPY unless the auto-extract/URL behavior of ADD is genuinely needed (it almost never is).
  8. Runtime contract — EXPOSE documents the port; HEALTHCHECK present where the orchestrator doesn't provide probes (plain Docker/Compose); ENTRYPOINT/CMD use exec form (JSON array) so signals reach the process (PID 1 must handle SIGTERM for graceful shutdown).
  9. Reproducibility — dependency versions pinned (lockfiles used in the build); no curl | sh of unpinned installers mid-build.

References

  • references/examples.md — bad → good multi-stage pairs for Go/Node/Python with the mechanics behind each finding (signal handling, layer additivity, BuildKit secret/cache mounts, digest pinning, HEALTHCHECK applicability).
  • Optional tooling: hadolint (Dockerfile lint) and trivy image / grype (CVE scan of the built image) can supplement this review if the user already has them — suggest, never install, and only run them with the user's confirmation.

Safety rules

  • This is a review skill: do not build, push, or publish images.
  • Never echo a secret discovered in a Dockerfile, .env, or image history — describe the exposure and the fix without quoting the value.
  • Alpine/distroless recommendations must note compatibility caveats (musl vs glibc, no shell for debugging) rather than being suggested unconditionally.

Output format

## Critical (security / broken behavior)
## Major (bloat, cache-busting, reproducibility)
## Minor / style
## Suggested Dockerfile changes
<concrete diff-style snippets for the top findings>

Quality checklist

  • Base image pinning and final-stage USER were checked
  • Build-time secret exposure (ARG/ENV/history) was checked
  • Cache ordering (deps before source) was checked
  • Signal handling (exec-form ENTRYPOINT) was checked
  • No image was built or pushed

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.