Python Master Plugin
Comprehensive Python expertise for Claude Code, covering modern Python 3.13+ development, async programming, type hints, FastAPI, testing, Cloudflare deployment, and GitHub Actions optimization.
Features
This plugin provides expertise in:
- Python 3.13+ Features - Free-threading, JIT, pattern matching, type parameters
- Asyncio Mastery - TaskGroup, semaphores, uvloop, async patterns
- Type Hints - Protocols, TypedDict, generics, mypy/pyright
- Package Management - uv, pyproject.toml, src layout, Ruff
- FastAPI - Production patterns, Pydantic, async handlers
- Testing - pytest, fixtures, mocking, coverage, async tests
- Cloudflare - Python Workers, Containers, cold start optimization
- GitHub Actions - uv CI/CD, caching, matrix builds, PyPI publishing
- Security - OWASP compliance, input validation, secrets management
- Performance - Memory profiling, optimization techniques
- OpenCV - Computer vision, image/video processing, BGR gotchas, DNN inference
- FFmpeg - Video/audio processing, encoding, streaming, ffmpeg-python, PyAV
- Video Pipelines - FFmpeg + OpenCV + Modal.com integration, parallel processing, GPU acceleration
Skills
| Skill | Description |
|---|
python-fundamentals-313 | Python 3.13+ features, syntax, memory optimizations |
python-asyncio | Async/await patterns, TaskGroup, performance |
python-type-hints | Modern type hints, Protocols, generics |
python-package-management | uv, pyproject.toml, Ruff, project structure |
python-fastapi | FastAPI production patterns, Pydantic, deployment |
python-testing | pytest, fixtures, mocking, coverage |
python-cloudflare | Workers, Containers, optimization |
python-github-actions | CI/CD workflows, caching, publishing |
python-gotchas | Common pitfalls and how to avoid them |
python-opencv | Computer vision, image/video processing, BGR handling |
python-ffmpeg | Video/audio encoding, streaming, ffmpeg-python, PyAV |
python-video-pipeline | FFmpeg + OpenCV + Modal integration, parallel GPU processing |
Commands
| Command | Description |
|---|
/python-init | Initialize a new Python project with best practices |
/python-test | Run tests with coverage report |
Quick Reference
Modern Python (3.12+)
# Type parameters
def first[T](items: list[T]) -> T:
return items[0]
# Pattern matching
match command:
case {"action": "create", "name": str(name)}:
return create(name)
case _:
return error()
# Type alias
type JsonValue = str | int | float | bool | None | list["JsonValue"]
Async Patterns
import asyncio
async def fetch_all(urls: list[str]) -> list[dict]:
async with asyncio.TaskGroup() as tg:
tasks = [tg.create_task(fetch(url)) for url in urls]
return [task.result() for task in tasks]
FastAPI
from fastapi import FastAPI, Depends
from pydantic import BaseModel
app = FastAPI()
class Item(BaseModel):
name: str
price: float
@app.post("/items/")
async def create_item(item: Item):
return item
uv Package Management
# Create project
uv init my-project
# Add dependencies
uv add fastapi pydantic
# Run with virtual env
uv run python main.py
# Sync from lockfile
uv sync
pytest Testing
import pytest
@pytest.fixture
def sample_data():
return {"key": "value"}
@pytest.mark.asyncio
async def test_async_function(sample_data):
result = await process(sample_data)
assert result is not None
Cloudflare Workers
from workers import Response, WorkerEntrypoint
class Default(WorkerEntrypoint):
async def fetch(self, request):
return Response("Hello from Python Worker!")
GitHub Actions
- uses: astral-sh/setup-uv@v4
with:
enable-cache: true
- run: uv sync
- run: uv run pytest
OpenCV
import cv2
import numpy as np
# CRITICAL: OpenCV uses BGR, not RGB!
img = cv2.imread("image.jpg") # BGR format
# Convert to RGB for Matplotlib/PIL
rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
# Coordinate gotcha: img[y, x] not img[x, y]
pixel = img[100, 200] # row=100 (y), col=200 (x)
# Always check if image loaded
if img is None:
raise FileNotFoundError("Image not found")
# Video capture with proper cleanup
cap = cv2.VideoCapture(0)
try:
while cap.isOpened():
ret, frame = cap.read()
if not ret:
break
# Process frame...
finally:
cap.release()
cv2.destroyAllWindows()
FFmpeg
import ffmpeg
# CRITICAL: Video filters can drop audio!
# BAD: Audio is lost
ffmpeg.input('input.mp4').filter('scale', 1280, 720).output('out.mp4').run()