python-containers

python-containers is a skill for Claude Code from laurigates/claude-plugins. It costs 50 tokens per session (2,198 once invoked), scanned C, original, MIT.

A guide to reducing the size of Docker images for Python applications using slim images, virtual environments, multi-stage builds, and modern package managers.

In plain words
What is it for?
Writing and reviewing Python Dockerfiles, managing pip, Poetry, or uv dependencies, and handling compiled extensions.
Why use it?
It helps remove unnecessary packages while avoiding common Python compatibility problems caused by unsuitable base images.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: names the TodoWrite tool.

Part of the container-plugin plugin — 7 skills, 1 agent shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/laurigates/claude-plugins/python-containers
Any agent
npx skills add laurigates/claude-plugins --skill python-containers
Clone the repo
git clone --depth 1 https://github.com/laurigates/claude-plugins

Made for: Claude Code.

Or install container-plugin, the plugin that ships this one along with the rest of its 7 skills, 1 agent.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for python-containers

README.md
[![agentmods](https://agentmods.dev/badge/skills/laurigates/claude-plugins/python-containers.svg)](https://agentmods.dev/skills/laurigates/claude-plugins/python-containers)
Your own site
<a href="https://agentmods.dev/skills/laurigates/claude-plugins/python-containers"><img src="https://agentmods.dev/badge/skills/laurigates/claude-plugins/python-containers.svg" alt="Measured on agentmods" height="20"></a>
Per session 50 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,198 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 2 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00050 $0.02198
Opus 5 $0.00025 $0.01099
Sonnet 5 $0.00010 $0.00440
Haiku 4.5 $0.00005 $0.00220

Measured yesterday against content hash 76d0476afd84, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade C, and why

python-containers scanned grade C with 2 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

&& rm -rf /var/lib/apt/lists/*

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

HEALTHCHECK --interval=30s CMD python -c "import requests; requests.get('http://localhost:8000/health')" || exit 1
container-plugin/skills/python-containers/SKILL.md · 227 lines

How it starts

The opening of the file, as written. The whole thing — 227 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Python Container Optimization

Expert knowledge for building optimized Python container images using slim base images, virtual environments, modern package managers (uv, poetry), and multi-stage build patterns.

When to Use This Skill

Use this skill when... Use container-development instead when...
Building Python-specific Dockerfiles General multi-stage build patterns
Optimizing Python image sizes Language-agnostic container security
Handling pip/poetry/uv in containers Docker Compose configuration
Dealing with musl/glibc issues Non-Python container optimization

Core Expertise

Python Container Challenges:

  • Large base images with unnecessary packages (~1GB)
  • Critical: Alpine causes issues with Python (musl vs glibc)
  • Complex dependency management (pip, poetry, pipenv, uv)
  • Compiled C extensions requiring build tools
  • Virtual environment handling in containers

Key Capabilities:

  • Slim-based images (NOT Alpine for Python)
  • Multi-stage builds with modern tools (uv recommended)
  • Virtual environment optimization
  • Compiled extension handling
  • Non-root user configuration

Why NOT Alpine for Python

Use slim instead of Alpine for Python containers. Alpine uses musl libc which causes:

  • Many wheels don't work (numpy, pandas, scipy)
  • Forces compilation from source (slow builds)
  • Larger final images due to build tools
  • Runtime errors with native extensions

Optimized Dockerfile Pattern (uv)

The recommended pattern achieves ~80-120MB images:

# Both stages MUST share this interpreter version — see below.
ARG PYTHON_VERSION=3.11

# Build stage
FROM python:${PYTHON_VERSION}-slim AS builder
WORKDIR /app

RUN pip install --no-cache-dir uv

# Copy dependency files
COPY pyproject.toml uv.lock ./

# Install dependencies with uv (much faster than pip)
RUN uv sync --frozen --no-dev

COPY . .

# Runtime stage
FROM python:${PYTHON_VERSION}-slim
WORKDIR /app

# Install only runtime dependencies (if needed)
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    libpq5 \
    && rm -rf /var/lib/apt/lists/*

# Create non-root user
RUN addgroup --gid 1001 appgroup && \
    adduser --uid 1001 --gid 1001 --disabled-password appuser

# Copy only what's needed
COPY --from=builder --chown=appuser:appgroup /app/.venv /app/.venv
COPY --chown=appuser:appgroup app/ /app/app/
COPY --chown=appuser:appgroup pyproject.toml /app/

ENV PATH="/app/.venv/bin:$PATH" \
    PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1

USER appuser
EXPOSE 8000

HEALTHCHECK --interval=30s CMD python -c "import requests; requests.get('http://localhost:8000/health')" || exit 1

CMD ["python", "-m", "app"]

Read the full file on GitHub · 227 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 227 lines · 50 tokens per session scan C 76d0476afd84

Subscribe to this mod's changes

python-containers is a skill published in the GitHub repository laurigates/claude-plugins (58 stars, last pushed yesterday), licensed MIT. It adds 50 tokens to every session and 2,198 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it C with 2 findings (recursive force delete, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.