multi-stage-dockerfile: Claude Code Skill & Agent Tool
An open-source skill by github (opens in a new tab), published in the github/awesome-copilot (opens in a new tab) repository on GitHub. Creates optimized multi-stage Dockerfiles for any language or framework, with lean base images, layer caching and hardened security practices built in.
Install multi-stage-dockerfile
Requires Node.jsnpx skills add github/awesome-copilot --skill multi-stage-dockerfileRun this command in your project terminal to install this skill for Claude Code.
What this skill does
multi-stage-dockerfile helps your agent write efficient multi-stage Dockerfiles that produce smaller, more secure container images, whatever the language or framework. The core idea is separation: a builder stage compiles code and installs dependencies, and a separate runtime stage contains only what the application needs to run, with only the necessary artifacts copied across. Stages get meaningful names and follow a logical order — dependencies, build, test, runtime.
For base images, the skill favors official, minimal images pinned to exact version tags for reproducible builds, distroless runtimes where they fit, and Alpine when the application is compatible. Layers are ordered from least to most frequently changing so the build cache does its job, related RUN commands are combined, a .dockerignore keeps the build context small, and COPY --chown sets permissions in one step.
Security is built in: containers run as a non-root user, build tools are removed from the final image, file permissions are restrictive, the image is scanned for vulnerabilities, and build secrets never reach the runtime stage. The agent also adds build arguments, production environment variables and a HEALTHCHECK. Use it with Claude Code to containerize a new service or slim down an existing image.
Key Capabilities
- Separate builder and runtime stages, copying only the artifacts needed
- Minimal official base images pinned to exact tags, distroless or Alpine where they fit
- Layer ordering for the build cache, combined RUN steps and a .dockerignore
- Non-root user, with no build tools or secrets in the final image
- Build arguments, production environment variables and a HEALTHCHECK
How to use with Claude Code & AI Agents
Install the skill
Run the command above at the root of your project. The CLI asks which agents to set up — Claude Code, Cursor and other supported agents — and adds multi-stage-dockerfile to the project, so teammates who pull the repository get it too. Add-gto install it for your user account across every project.Open a new agent session
Start a fresh Claude Code session in that project so the agent loads the new skill. Have ready: Docker (to build and test the image).Ask in plain words
Describe the task, for example:“Write a multi-stage Dockerfile for this Node.js app with a non-root runtime.”The agent matches your request to the skill's description and follows its SKILL.md instructions step by step. Read them on GitHub before using the skill on a system that matters.