pattern-engineer-container
Skill0 starsChanged 5 months agoMITView on GitHub
Containerized setups: every Dockerfile is multi-stage (`base`/`build`/`final`), pinned (no `:latest`) and vetted via `docker scout`, non-root with writable paths redirected, no in-image virtualenvs, `.dockerignore` required. Backends `alembic upgrade head` in entrypoint before exec'ing the server; expose fast `/healthz`. Frontend nginx puts API `location` blocks ABOVE the SPA `try_files` fallback. Secrets are runtime env vars. Activate on Dockerfile, compose, `.dockerignore`.
- Reads credentials
- Installs packages
In this repository74 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- create-bug-issueSkill
- create-enhancement-issueSkill
- create-feature-issuesSkill
- dream-summary-memorySkill
- memory-conventionSkill
- operation-gitSkill
- pattern-architect-api-endpointSkill
- pattern-architect-data-modelSkill
- pattern-architect-deep-moduleSkill
- pattern-e2e-coding-standardSkill
- pattern-engineer-apiSkill
- pattern-engineer-backend-standardSkill
- pattern-engineer-coding-standardSkill
- pattern-engineer-databaseSkill
- pattern-engineer-fastapiSkill
- pattern-engineer-frontend-standardSkill
- pattern-engineer-goSkill
- pattern-engineer-javaSkill
- pattern-engineer-kotlinSkill
- pattern-engineer-nodeSkill
- pattern-engineer-non-functionalSkill
- pattern-engineer-observabilitySkill
- pattern-engineer-pythonSkill
- pattern-engineer-rustSkill
- pattern-engineer-securitySkill
- pattern-engineer-ssrSkill
- pattern-engineer-swiftSkill
- pattern-engineer-typescriptSkill
- pattern-engineer-viteSkill
- pattern-exploratory-testingSkill
- pattern-reviewer-apiSkill
- pattern-reviewer-backend-standardSkill
- pattern-reviewer-coding-standardSkill
- pattern-reviewer-containerSkill
- pattern-reviewer-contractSkill
- pattern-reviewer-databaseSkill
- pattern-reviewer-fastapiSkill
- pattern-reviewer-frontend-standardSkill
- pattern-reviewer-goSkill
- pattern-reviewer-javaSkill
- pattern-reviewer-kotlinSkill
- pattern-reviewer-nodeSkill
- pattern-reviewer-non-functionalSkill
- pattern-reviewer-observabilitySkill
- pattern-reviewer-pythonSkill
- pattern-reviewer-rustSkill
- pattern-reviewer-securitySkill
- pattern-reviewer-ssrSkill
- pattern-reviewer-swiftSkill
- pattern-reviewer-test-coverageSkill
- pattern-reviewer-typescriptSkill
- pattern-reviewer-viteSkill
- pattern-test-coverageSkill
- principle-engineer-tddSkill
- scaffold-projectSkill
- workflow-architect-interviewSkill
- workflow-designer-sample-pagesSkill
- workflow-design-interviewSkill
- workflow-e2e-authorSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 0 are distinctive, and 9 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.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
After loading this skill, also check $MAIN_ROOT/.claude/memory/patterns/pattern-engineer-container.md in the consuming project (resolve …
- Very specific: line 21
Pinned tags, never
:latest: Use immutable tags (node:20.11.1-alpine, python:3.12.4-slim, nginx:1.27.0-alpine). - Very specific: line 22
Vet base images with
docker scout: before pinning. Reject any image with MEDIUM+ CVEs that have a fix available. - Very specific: line 31
Run alembic upgrade head (or framework equivalent) in the entrypoint script, BEFORE exec'ing the server.
- Very specific: line 33
Use exec on the server line so PID 1 is the server (not the shell) and SIGTERM forwards correctly.
- Very specific: line 37
Every backend exposes HTTP /healthz: 200 on normal boot, no auth, no DB / external-dep call, <100ms.
- Very specific: line 56
Read from .env (gitignored) or host environment / secret manager.
- Very specific: line 61
Default to internal-only. ports: publishes to the host (use sparingly, user-facing only).
- Very specific: line 73
Prefer docker compose (V2 plugin) over the legacy docker-compose binary.
≈ “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.
Files
pattern-engineer-container
When to activate
Activate when editing Dockerfile, docker-compose.yaml / .yml, compose.yaml / .yml, .dockerignore, or scaffolding container artifacts. Skip for Kubernetes / Helm / non-Docker runtimes without an explicit Docker tie-in.
Project memory overlay
After loading this skill, also check $MAIN_ROOT/.claude/memory/patterns/pattern-engineer-container.md in the consuming project (resolve MAIN_ROOT="$(dirname "$(git rev-parse --path-format=absolute --git-common-dir)")"). If present, load it as an additive overlay to the rules below; if absent, skip silently. See memory-convention for the full contract (additivity, severity floor, conflict surfacing).
Patterns
Dockerfile shape
- Multi-stage, always at least three:
base(system deps + runtime),build(compile / bundle),final(minimal runtime). - Pinned tags, never
:latest. Use immutable tags (node:20.11.1-alpine,python:3.12.4-slim,nginx:1.27.0-alpine). Digest pinning (@sha256:...) for production base images. - Vet base images with
docker scoutbefore pinning. Reject any image with MEDIUM+ CVEs that have a fix available; switch to the fixed tag. - Run as non-root in
final:RUN addgroup -S app && adduser -S app -G appthenUSER app. - Every writable path is user-writable. Redirect PID files, cache, nginx
*_temp_path(andclient_body_temp_path,proxy_temp_path,fastcgi_temp_pathwhen in use) to/tmp/...via config, AND recursivelychownthe app directory in the build stage beforeUSER. - No virtual environments inside images. Install Python deps system-wide (
uv pip install --system); no.venv/uv venvin the Dockerfile. .dockerignoreis mandatory. Exclude.git,node_modules,.env*,dist/,build/,coverage/,*.log, IDE folders.- Layer ordering: copy dep manifests + install deps before copying source, so dep layers cache across source edits.
Backend entrypoint
- Run
alembic upgrade head(or framework equivalent) in the entrypoint script, BEFOREexec'ing the server. - Copy the migration CLI into the final stage explicitly (or copy from build stage);
alembicin the build stage is not enough. - Use
execon the server line so PID 1 is the server (not the shell) and SIGTERM forwards correctly.
/healthz endpoint
- Every backend exposes HTTP
/healthz: 200 on normal boot, no auth, no DB / external-dep call, <100ms. - Separate
/readyzpath (different URL) for readiness checks that DO touch the DB.
Frontend nginx
- API
locationblocks go ABOVE the SPAtry_filesfallback. Puttingtry_files $uri $uri/ /index.htmlat the top catches/api/...too and returnsindex.htmlas the response body. - Order:
/healthz→ API prefixes (each with its ownlocation) → rootlocation /withtry_files. try_files $uri $uri/ /index.htmlis mandatory for any SPA — without$uri/, directory-path requests 404.- Pre-push hook's
container:smoke-api-proxyprobe catches misconfig byContent-Type(text/htmlon an API probe = SPA catch-all intercepted).
External-dependency doubles (for E2E)
- Compose includes a stand-in for every external dependency the E2E flow touches — mail catcher, object-store emulator, fake gateway, broker. A spec can't verify an integration whose counterpart was never started.
- Connection scheme matches the client's requirement (e.g. an async vs sync driver prefix), and every service that builds the client applies the same transformation — a rewrite present in the worker but missing in the web server fails only once a real connection is opened.
- Reverse-proxy ordering (restated from Frontend nginx): API / upstream
locationblocks sit ABOVE the SPAtry_filesfallback, or client routes 404 and API calls return the app shell.
Secrets
- Runtime env vars only. Never
COPY/ARG/ENVbaked into the image. - Read from
.env(gitignored) or host environment / secret manager. - For prod:
secrets:(file-based) in Swarm; platform secret store (Vercel / Railway / Fly / SSM) on managed hosts.
Networking
- Default to internal-only.
ports:publishes to the host (use sparingly, user-facing only). expose:documents intra-network ports (optional but useful).- Bind to
127.0.0.1("127.0.0.1:5432:5432") when publishing dev-only ports.
Volumes
- Named volume (
db_data:/var/lib/postgresql/data): persistent state across restarts (DBs, queues, caches). - Bind mount (
./src:/app/src): development source for live reload. - Anonymous volume (
/app/node_modules): preserve container-generated content from bind-mount shadowing.
docker compose commands
Prefer docker compose (V2 plugin) over the legacy docker-compose binary.
| Operation | Command |
| Follow logs | docker compose logs -f <service> |
| Exec shell | docker compose exec <service> sh |
| Rebuild changed images | docker compose up --build |
| Force full rebuild | docker compose build --no-cache <service> |
| Stop + remove | docker compose down |
| Stop + remove + wipe named volumes (DESTRUCTIVE) | docker compose down -v |
Templates
| Asset | Purpose |
templates/Dockerfile | Three-stage Node Dockerfile (base + build + final), pinned node:20.11.1-alpine, non-root app user, tini as PID 1. |
templates/docker-compose.yaml | app + db (Postgres 16.3-alpine) services with healthcheck, named db_data volume, host-bound 127.0.0.1:3000 mapping. |
templates/.dockerignore | Excludes .git, node_modules, .env*, build outputs, IDE folders, and Dockerfile* / docker-compose* from the build context. |
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
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.

