agentleFS
kakarot-oncloudkakarot-oncloud/claude-dev-skills/skills/dockerfile-doctor/SKILL.md

dockerfile-doctor

Skill0 starsChanged 7 months agoMITView on GitHub

Reviews and optimizes Dockerfiles for image size, build speed, security, and reproducibility. Suggests multi-stage builds, layer caching, non-root users, and pinned versions. Use this skill when the user pastes a Dockerfile and asks for review, says "make this image smaller", needs help with multi-stage builds, or asks about Docker best practices.

  • Installs packages

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 0 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use a small base (-slim, -alpine, distroless) when compatible.

    line 13
  2. Very specific:

    Use .dockerignore to exclude node_modules, .git, build outputs.

    line 27
  3. Very specific:

    Use --platform=$BUILDPLATFORM for multi-arch.

    line 39
  4. Very specific:

    Use exec form (JSON array), not shell form, for proper signal handling (SIGTERM → graceful shutdown).

    line 45
  5. Very specific:

    Don't run tini or init unless you need PID 1 reaping.

    line 46
  6. Very specific:

    Don't remove functionality: If the original installs curl for a healthcheck, keep it (or replace with wget if smaller).

    line 67
  7. Very specific:

    Test assumptions: If you suggest alpine, note that musl can break native deps (e.g.

    line 68

≈ “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 Doctor

You review Dockerfiles and produce optimized versions, explaining each change.

What you check

1. Size

  • Use a small base (-slim, -alpine, distroless) when compatible.
  • Multi-stage builds — compile/install in a builder stage, copy only artifacts to runtime.
  • Combine RUN commands to reduce layers, but keep them logically grouped.
  • --no-install-recommends for apt; --no-cache for apk; pip install --no-cache-dir.
  • Clean package manager caches in the same layer as the install.

2. Build speed (cache hits)

  • Order layers from least-changing to most-changing.
  • Copy dependency manifests first, install, then copy source:
    COPY package*.json ./
    RUN npm ci
    COPY . .
  • Use .dockerignore to exclude node_modules, .git, build outputs.

3. Security

  • Pin base image by digest or at minimum minor version (node:20.11-slim, not node:latest).
  • Run as non-root — create a user, USER appuser.
  • No secrets in layers — use BuildKit secrets or build args that aren't persisted.
  • Drop capabilities at runtime, don't bake setuid binaries in.
  • Scan with docker scout or trivy; flag known CVEs in the base image.

4. Reproducibility

  • Pin all dependency versions (lockfiles, exact versions in apt-get install).
  • Set SOURCE_DATE_EPOCH if reproducible builds matter.
  • Use --platform=$BUILDPLATFORM for multi-arch.

5. Runtime correctness

  • EXPOSE the right port.
  • HEALTHCHECK for long-running services.
  • ENTRYPOINT vs CMD — use ENTRYPOINT for the binary, CMD for default args.
  • Use exec form (JSON array), not shell form, for proper signal handling (SIGTERM → graceful shutdown).
  • Don't run tini or init unless you need PID 1 reaping; many runtimes (k8s, ECS) handle this.

Output format

## Findings
🔴 <critical issue> — <why it matters>
🟠 <major issue>
🟡 <minor>

## Optimized Dockerfile
<full rewritten Dockerfile in a code block, with brief inline comments where non-obvious>

## Expected impact
- Image size: <before> → <after estimate>
- Build cache: <what's now cacheable>
- Security: <what changed>

Rules

  1. Don't remove functionality. If the original installs curl for a healthcheck, keep it (or replace with wget if smaller).
  2. Test assumptions. If you suggest alpine, note that musl can break native deps (e.g. node-gyp, some Python wheels) — recommend -slim if unsure.
  3. Don't over-engineer. A 10-line app doesn't need a 4-stage build.
  4. Explain trade-offs. Distroless = smallest + most secure, but no shell for debugging.

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.