docker-expert
Advanced Docker: multi-stage builds, BuildKit, image optimization, security scanning, layer caching, and production patterns.
What this skill does
# Docker Expert
Advanced Docker patterns beyond basic container operations.
## Multi-Stage Builds
```dockerfile
# Stage 1: Build
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
# Stage 2: Production (minimal image)
FROM node:20-alpine AS production
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./
USER node
EXPOSE 3000
CMD ["node", "dist/index.js"]
```
## Image Optimization
```bash
# Check image size
docker images --format "table {{.Repository}}:{{.Tag}}\t{{.Size}}" | sort -k2 -h
# Analyze image layers
docker history myapp:latest --format "table {{.CreatedBy}}\t{{.Size}}" --no-trunc
# Dive — interactive layer explorer
docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock wagoodman/dive myapp:latest
```
### Size reduction techniques
```dockerfile
# Use alpine base images
FROM node:20-alpine # ~180MB vs node:20 ~1GB
# Install only production dependencies
RUN npm ci --production
# Clean up in the same layer
RUN apk add --no-cache build-base python3 \
&& npm ci \
&& apk del build-base python3
# Use .dockerignore
# .dockerignore:
# node_modules
# .git
# .env
# *.md
# dist
```
## BuildKit Features
```bash
# Enable BuildKit
export DOCKER_BUILDKIT=1
# Build with cache mount (speeds up dependency install)
docker build --build-arg BUILDKIT_INLINE_CACHE=1 -t myapp .
# Secret mounting (don't bake secrets into layers)
docker build --secret id=npmrc,src=$HOME/.npmrc -t myapp .
# In Dockerfile: RUN --mount=type=secret,id=npmrc,target=/root/.npmrc npm ci
# SSH forwarding for private repos
docker build --ssh default -t myapp .
# Cache export/import for CI
docker build --cache-from myapp:cache --cache-to type=inline -t myapp .
```
## Security
```bash
# Scan image for vulnerabilities
docker scout cves myapp:latest
# Trivy scan
trivy image myapp:latest
# Run as non-root (in Dockerfile)
# USER node or USER 1001:1001
# Read-only filesystem
docker run --read-only --tmpfs /tmp myapp:latest
# Drop capabilities
docker run --cap-drop ALL --cap-add NET_BIND_SERVICE myapp:latest
# No new privileges
docker run --security-opt no-new-privileges myapp:latest
```
## Health Checks
```dockerfile
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
CMD curl -f http://localhost:3000/health || exit 1
```
```bash
# Check health status
docker inspect --format='{{.State.Health.Status}}' myapp
```
## Compose Patterns
```yaml
# docker-compose.yml — production patterns
services:
app:
build:
context: .
target: production # Multi-stage target
restart: unless-stopped
deploy:
resources:
limits:
memory: 512M
cpus: '0.5'
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 30s
timeout: 5s
retries: 3
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
```
## Notes
- Order Dockerfile instructions by change frequency: OS packages → dependencies → app code.
- Each `RUN`, `COPY`, `ADD` creates a layer. Combine related operations.
- Never store secrets in environment variables in Dockerfiles — they're visible in `docker history`.
- Pin base image versions: `node:20.11-alpine` not `node:latest`.
- `.dockerignore` is critical — without it, `docker build` copies your entire directory including `node_modules` and `.git`.
Related in Image & Video
watch
IncludedWatch a video (URL or local path). Downloads with yt-dlp, extracts auto-scaled frames with ffmpeg, pulls the transcript from captions (or Whisper API fallback), and hands the result to Claude so it can answer questions about what's in the video.
physical-ai-defect-image-generation
IncludedUse when the user wants to orchestrate defect image generation, run associated setup, or handle outputs on OSMO. The Day 0 path handles cold-start with USD-to-ROI, image-edit augmentation, and AnomalyGen to create initial PCBA datasets. The Day 1 path performs inference and labeling on real images. This skill helps with first-time asset setup, creation of finetuning checkpoints, and configuring deployment. Trigger keywords: defect image generation, dig workflow, dig pipeline, defect image detection workflow, aoi pipeline, aoi anomalygen, usd2roi anomalygen, day 0 pcba, day 1 pcba, day 1 real-photo alignment, day 1 manual roi, metal surface anomaly, glass defect, anomalygen finetune, setup_pcb, setup_metal, setup_glass, setup_pretrained, dig setup, dig datasets, dig pretrained checkpoint, dig image-edit endpoint.
accelint-react-best-practices
IncludedReact performance optimization and best practices. ALWAYS use this skill when working with any React code - writing components, hooks, JSX; refactoring; optimizing re-renders, memoization, state management; reviewing for performance; fixing hydration mismatches; debugging infinite re-renders, stale closures, input focus loss, animations restarting; preventing remounting; implementing transitions, lazy initialization, effect dependencies. Even simple React tasks benefit from these patterns. Covers React 19+ (useEffectEvent, Activity, ref props). Triggers - useEffect, useState, useMemo, useCallback, memo, inline components, nested components, components inside components, re-render, performance, hydration, SSR, Next.js, useDeferredValue, combined hooks.
elevenlabs-agents
IncludedBuild conversational AI voice agents with ElevenLabs Platform using React, JavaScript, React Native, or Swift SDKs. Configure agents, tools (client/server/MCP), RAG knowledge bases, multi-voice, and Scribe real-time STT. Use when: building voice chat interfaces, implementing AI phone agents with Twilio, configuring agent workflows or tools, adding RAG knowledge bases, testing with CLI "agents as code", or troubleshooting deprecated @11labs packages, Android audio cutoff, CSP violations, dynamic variables, or WebRTC config. Keywords: ElevenLabs Agents, ElevenLabs voice agents, AI voice agents, conversational AI, @elevenlabs/react, @elevenlabs/client, @elevenlabs/react-native, @elevenlabs/elevenlabs-js, @elevenlabs/agents-cli, elevenlabs SDK, voice AI, TTS, text-to-speech, ASR, speech recognition, turn-taking model, WebRTC voice, WebSocket voice, ElevenLabs conversation, agent system prompt, agent tools, agent knowledge base, RAG voice agents, multi-voice agents, pronunciation dictionary, voice speed control, elevenlabs scribe, @11labs deprecated, Android audio cutoff, CSP violation elevenlabs, dynamic variables elevenlabs, case-sensitive tool names, webhook authentication
humanizer
IncludedHumanize AI-generated text by detecting and removing patterns typical of LLM output. Rewrites text to sound natural, specific, and human. Uses 28 pattern detectors, 560+ AI vocabulary terms across 3 tiers, and statistical analysis (burstiness, type-token ratio, readability) for comprehensive detection. Use when asked to humanize text, de-AI writing, make content sound more natural/human, review writing for AI patterns, score text for AI detection, or improve AI-generated drafts. Covers content, language, style, communication, and filler categories.
generating-mermaid-diagrams
IncludedSalesforce architecture diagrams using Mermaid with ASCII fallback. Use this skill when generating text-based diagrams for Salesforce architecture, OAuth flows, ERDs, integration sequences, or Agentforce structure. TRIGGER when: user says "diagram", "visualize", "ERD", or asks for sequence diagrams, flowcharts, class diagrams, or architecture visualizations in Mermaid. DO NOT TRIGGER when: user wants PNG/SVG image output (use generating-visual-diagrams), or asks about non-Salesforce systems.