agentleFS
cyberphorcyberphor/skills/skills/write-dockerfile/SKILL.md

write-dockerfile

Skill4 starsChanged 48 days agoMITView on GitHub

Writes or updates Dockerfiles and their build contexts. Use when asked to create or update container image builds or runtime packaging.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    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. Very specific:

    Read and apply write-text from the active skill catalog or sibling skill when drafting comments or explanations.

    line 10
  2. Distinctive:

    Use named multi-stage builds when build tools or intermediate artifacts are unnecessary at runtime.

    line 16
  3. Distinctive:

    Put dependency manifests and their installation before frequently changing source files when that preserves correct cache invalidation.

    line 18
  4. Distinctive:

    Prefer a nonroot runtime user when compatible with application permissions and mounted files.

    line 22
  5. Very specific:

    Never put secrets in ARG, ENV, copied files, or image layers.

    line 24

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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

How to Write a Dockerfile

Inspect the existing Dockerfile, build context, dependency manifests, image consumers, and runtime requirements before editing. Preserve required entrypoints, ports, architecture support, and artifact paths. Apply changes to the requested image rather than imposing a new deployment workflow.

Read and apply write-text from the active skill catalog or sibling skill when drafting comments or explanations. Reuse it if already loaded.

Image Design

Choose a maintained base image compatible with the application's runtime and native dependencies. Preserve the project's tag or digest policy. A smaller image is useful only when it still supplies required libraries, certificates, and runtime files.

Use named multi-stage builds when build tools or intermediate artifacts are unnecessary at runtime. Copy only required outputs into the final stage. Inspect linking requirements before choosing a minimal runtime image.

Put dependency manifests and their installation before frequently changing source files when that preserves correct cache invalidation. Use build cache mounts when useful and supported. Keep .dockerignore aligned with the actual context, excluding secrets, local environments, and unnecessary artifacts without excluding required inputs.

Runtime and Secrets

Prefer a nonroot runtime user when compatible with application permissions and mounted files. Set ownership for required writable paths instead of granting broad permissions. Use exec-form entrypoints and commands when the application should receive process signals directly.

Never put secrets in ARG, ENV, copied files, or image layers. Use BuildKit secret or SSH mounts for build credentials and the deployment's existing mechanism for runtime secrets. Removing a file in a later layer does not remove it from earlier layers.

Verification

Build the actual Dockerfile with its intended context, target, and platform. Run a disposable container with representative required configuration and check startup, the relevant command or endpoint, permissions, and shutdown. Keep credentials out of logs. A successful build alone does not verify runtime behavior.

Report the image changes and checks actually completed. If Docker or required dependencies are unavailable, identify the missing runtime checks. Do not push images or change a deployment unless the task authorizes it.

Official References

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.