一键导入
dockerfile-review
Reviews Dockerfiles for build performance, image size, and security issues. Use when optimizing, validating, or improving Dockerfiles.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Reviews Dockerfiles for build performance, image size, and security issues. Use when optimizing, validating, or improving Dockerfiles.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | dockerfile-review |
| description | Reviews Dockerfiles for build performance, image size, and security issues. Use when optimizing, validating, or improving Dockerfiles. |
icon: 🐳
Dependency files (package.json, requirements.txt, go.mod) must be copied and installed BEFORE application source code. Violations cause full dependency reinstalls on every code change.
Anti-pattern: COPY . . followed by RUN pip install or RUN npm ci. The entire dependency layer rebuilds on any source change.
Impact: builds that should take seconds take minutes. With frequent builds, this compounds to hours per week.
Three tiers exist: full (includes compilers, tools), slim (minimal OS, basic tooling), distroless (application only, no shell).
Anti-patterns:
Without .dockerignore, COPY . . sends everything to the build context: node_modules (50-500MB), .git (100MB+), coverage reports, IDE configs, .env files.
Anti-patterns:
Build tools, compilers, and dev dependencies should not exist in the final image. Multi-stage builds separate construction from execution.
Anti-patterns:
Tags like latest or unpinned package versions create non-reproducible builds.
Anti-patterns:
FROM ubuntu:latest or FROM node:ltsapt-get install -y curl without version pinningEach RUN, COPY, ADD creates a layer. Deletions in later layers don't reduce image size — the previous layer still contains the data.
Anti-pattern: separate RUN instructions for install and cleanup. RUN apt-get update then RUN rm -rf /var/lib/apt/lists/* preserves the cache in the first layer.
Fix direction: combine install and cleanup in a single RUN with &&.
Credentials, API keys, and tokens embedded in layers are permanently accessible via docker history or registry inspection.
Anti-patterns:
ENV API_KEY=... or ARG with secrets passed at build timeFix direction: use --mount=type=secret with BuildKit for build-time secrets. Never bake secrets into layers.
Running as root means a container escape or application vulnerability grants full system access.
Anti-patterns:
Fix direction: create a dedicated user with useradd, chown application files, then switch with USER — placed after all file operations that need root.
Applies Domain-Driven Design with hexagonal (ports & adapters) architecture. Use when designing backend application structure, separating domain from infrastructure, creating testable boundaries, or when user mentions DDD, ports, adapters, hexagonal, or clean architecture.
Designs systems using Event Modeling.
Implement code with TDD following a deterministic state machine (understand → scout → architecture → tdd → simplify → test_quality → complexity → commit). Driven by issues in plan.md.
Design before code. Runs the Discovery state machine (clarify → model → architecture → slice) to produce issues in plan.md. Use when designing a new project, feature, or system.
Applies feature-based architecture for React frontends. Use when designing frontend structure, organizing components, hooks, and features, or when user mentions frontend architecture, React structure, or feature-based design.
Test-driven development (TDD) process used when writing code. Use whenever you are adding any new code, unless the user explicitly asks to skip TDD or the code is exploratory/spike.