/agent-skills:pythonfrom agent-skills
Provides guidance for Python project setup, tool selection, virtual environments, type hints, async programming, and packaging strategy across the ecosystem.
Ships in agent-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
A comprehensive collection of guidance for Python software development, covering project configuration, dependency management, CLI tooling, and best practices across the modern Python ecosystem.
Python is one of the most widely-used programming languages, powering web backends, data science, machine learning, DevOps automation, CLI tools, and scripting. The Python ecosystem has undergone significant modernization in recent years with pyproject.toml replacing setup.py, type hints becoming standard, and new high-performance tooling like uv transforming the developer experience.
This skill tree provides structured guidance for navigating the Python ecosystem effectively.
python/
project-system/ pyproject.toml, build backends, setuptools, hatch, flit, maturin
package-management/ pip, uv, poetry, pdm, conda, pipx, virtual environments
cli/ argparse, click, typer, rich, textual
packages/ Popular libraries and frameworks (Flask, FastAPI, Django, pytest, etc.)
| Category | Sub-Skill | What It Covers |
|---|---|---|
| Project System | project-system | pyproject.toml anatomy, build backends (setuptools, hatchling, flit-core, maturin), PEP 517/518/621/660, entry points, versioning, publishing |
| Package Management | package-management | pip, uv, poetry, pdm, conda, pipx, virtual environments, lockfiles, private indexes |
| CLI Development | cli | argparse, click, typer, rich, textual, output formatting, testing CLI apps |
| Packages | packages | Popular Python libraries and frameworks for web, data, testing, and more |
| I need to... | Use this sub-skill |
|---|---|
Set up a new Python project with pyproject.toml | project-system |
| Choose between setuptools, hatch, flit, or poetry for building | project-system |
| Configure entry points or console scripts | project-system |
| Publish a package to PyPI | project-system |
| Install dependencies or manage a lockfile | package-management |
| Choose between pip, uv, poetry, pdm, or conda | package-management |
| Set up virtual environments | package-management |
| Configure private package indexes | package-management |
| Build a command-line application | cli |
| Add rich terminal output (colors, tables, progress bars) | cli |
| Build a terminal UI (TUI) | cli |
| Choose between argparse, click, and typer | cli |
| Version | Status | Key Features |
|---|---|---|
| 3.9 | Security fixes | Dict union operators (|, |=), str.removeprefix()/removesuffix(), type hinting generics in standard collections |
| 3.10 | Security fixes | Structural pattern matching (match/case), parenthesized context managers, TypeAlias, better error messages |
| 3.11 | Maintained | Exception groups and except*, tomllib in stdlib, significant performance improvements (10-60% faster), TaskGroup for asyncio |
| 3.12 | Maintained | Type parameter syntax (type X = ...), f-string improvements, per-interpreter GIL (subinterpreters), pathlib improvements |
| 3.13 | Latest stable | Free-threaded mode (experimental, no GIL), JIT compiler (experimental), improved typing module, better REPL |
| 3.14+ | In development | Deferred evaluation of annotations (PEP 649), further JIT/free-threading improvements |
Recommendation: Target Python 3.11+ for new projects. Use 3.12+ if you need the new type parameter syntax. Use 3.13 to experiment with free-threaded mode.
# Basic type annotations
def greet(name: str) -> str:
return f"Hello, {name}"
# Generic collections (3.9+ -- no need for typing.List, typing.Dict)
def process(items: list[int]) -> dict[str, int]:
return {str(i): i for i in items}
# Union types (3.10+ -- use | instead of Union)
def parse(value: str | int) -> str:
return str(value)
# Optional is shorthand for X | None
def find(key: str) -> str | None:
...
# TypeVar and generics (3.12+ type parameter syntax)
type Comparable = int | float | str
def maximum[T: Comparable](a: T, b: T) -> T:
return a if a >= b else b
# TypedDict for structured dictionaries
from typing import TypedDict
class UserConfig(TypedDict):
name: str
age: int
email: str | None
import asyncio
async def fetch_data(url: str) -> dict:
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
return await response.json()
# TaskGroup (3.11+) -- structured concurrency
async def fetch_all(urls: list[str]) -> list[dict]:
results = []
async with asyncio.TaskGroup() as tg:
for url in urls:
tg.create_task(fetch_data(url))
return results
# Async generators
async def stream_lines(path: str):
async with aiofiles.open(path) as f:
async for line in f:
yield line.strip()
from dataclasses import dataclass, field
@dataclass
class Config:
host: str = "localhost"
port: int = 8080
tags: list[str] = field(default_factory=list)
# Frozen (immutable) dataclass
@dataclass(frozen=True)
class Point:
x: float
y: float
# Slots for memory efficiency (3.10+)
@dataclass(slots=True)
class Measurement:
timestamp: float
value: float
unit: str
def handle_command(command: dict) -> str:
match command:
case {"action": "quit"}:
return "Goodbye"
case {"action": "greet", "name": str(name)}:
return f"Hello, {name}"
case {"action": "move", "x": int(x), "y": int(y)} if x > 0:
return f"Moving right to ({x}, {y})"
case _:
return "Unknown command"
# Raising multiple exceptions
def validate(data: dict) -> None:
errors = []
if "name" not in data:
errors.append(ValueError("Missing name"))
if "age" not in data:
errors.append(ValueError("Missing age"))
if errors:
raise ExceptionGroup("Validation failed", errors)
# Handling exception groups
try:
validate({})
except* ValueError as eg:
for exc in eg.exceptions:
print(f"Validation error: {exc}")
except* TypeError as eg:
for exc in eg.exceptions:
print(f"Type error: {exc}")
from contextlib import contextmanager, asynccontextmanager
@contextmanager
def managed_resource(name: str):
print(f"Acquiring {name}")
try:
yield name
finally:
print(f"Releasing {name}")
# Parenthesized context managers (3.10+)
with (
open("input.txt") as fin,
open("output.txt", "w") as fout,
):
fout.write(fin.read())
Never install project dependencies into the system Python. Use venv, uv venv, or let your package manager (poetry, pdm) handle environment creation.
# Standard library
python -m venv .venv
source .venv/bin/activate # Linux/macOS
.venv\Scripts\activate # Windows
# Using uv (faster)
uv venv
source .venv/bin/activate
Use type hints throughout your codebase. They improve readability, enable IDE support, and catch bugs early with mypy or pyright.
# Type checking with mypy
pip install mypy
mypy src/
# Type checking with pyright (faster, used by Pylance in VS Code)
pip install pyright
pyright src/
Ruff is an extremely fast Python linter and formatter written in Rust. It replaces flake8, isort, black, and many other tools.
# Install
pip install ruff
# Lint
ruff check src/
# Format (replaces black)
ruff format src/
# Fix auto-fixable issues
ruff check --fix src/
Minimal ruff configuration in pyproject.toml:
[tool.ruff]
target-version = "py311"
line-length = 88
[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"UP", # pyupgrade
"B", # flake8-bugbear
"SIM", # flake8-simplify
"TCH", # flake8-type-checking
]
[tool.ruff.lint.isort]
known-first-party = ["mypackage"]
pyproject.toml for All ConfigurationConsolidate tool configuration in pyproject.toml instead of scattering it across setup.cfg, tox.ini, .flake8, etc.
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "-ra -q"
[tool.mypy]
python_version = "3.11"
strict = true
[tool.coverage.run]
source = ["src"]
branch = true
Use pytest as your test runner. It is the de facto standard in the Python ecosystem.
pip install pytest pytest-cov
# Run tests
pytest
# Run with coverage
pytest --cov=src --cov-report=term-missing
__all__ for Public API ControlDefine __all__ in __init__.py files to make your public API explicit:
# src/mypackage/__init__.py
__all__ = ["Client", "Config", "process_data"]
from .client import Client
from .config import Config
from .processing import process_data
AGENTS.md (opens in a new tab)README.md (opens in a new tab)cli/AGENTS.md (opens in a new tab)cli/README.md (opens in a new tab)cli/metadata.json (opens in a new tab)cli/rules/_sections.md (opens in a new tab)cli/rules/_template.md (opens in a new tab)cli/rules/cli-add-shell-completion.md (opens in a new tab)cli/rules/cli-provide-verbose-and-quiet-flags.md (opens in a new tab)cli/rules/cli-respect-no-color.md (opens in a new tab)cli/rules/cli-support-json-output.md (opens in a new tab)cli/rules/cli-test-with-clirunner.md (opens in a new tab)cli/rules/cli-use-annotated-parameters-in-typer.md (opens in a new tab)cli/rules/cli-use-exit-codes-consistently.md (opens in a new tab)cli/rules/cli-version-flag.md (opens in a new tab)cli/rules/cli-write-help-for-everything.md (opens in a new tab)cli/rules/cli-write-to-stderr-for-diagnostics.md (opens in a new tab)metadata.json (opens in a new tab)package-management/AGENTS.md (opens in a new tab)package-management/README.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
python, python-development, pyproject, virtual-environments, type-hints, packaging
npx claudepluginhub tyler-r-kendrick/agent-skills --plugin agent-skills13 skills in this plugin
/aiUse when working with AI agent protocols, standards, interoperability specifications, evaluation contracts, synthetic simulation data, improvement pipelines, and agent steering workflows. Covers MCP, A2A, ACP, Agent Skills, AGENTS.md, ADL, Improve, x402, AP2, MCP Apps, cagent, and learn.
USE FOR: agent protocol selection, comparing MCP vs A2A vs ACP, understanding agent standards ecosystem, choosing payment protocols, choosing eval standards, choosing improvement techniques, choosing synthetic data simulation techniques, steering from user feedback
DO NOT USE FOR: specific protocol, eval, or improvement implementation details (use the sub-skills: mcp, a2a, acp, improve, learn, x402, etc.)
/design-systemUse when building or maintaining a design system — the coordinated set of design tokens, component libraries, documentation, and tooling that ensures visual and behavioral consistency across products.
USE FOR: design system architecture, choosing token formats vs component frameworks, connecting Figma to code, design-to-development workflows, multi-platform consistency
DO NOT USE FOR: specific token authoring (use design-tokens), Figma workflows (use figma), component cataloging (use storybook), token transformation (use style-dictionary), cross-framework components (use mitosis)
/devUse when working with fundamental software development knowledge — patterns, algorithms, architecture, and craftsmanship principles drawn from canonical published works.
USE FOR: development fundamentals, pattern selection, architecture decisions, algorithm choice, code quality principles, choosing between architectural styles
DO NOT USE FOR: specific pattern implementations (use sub-skills: design-patterns, integration-patterns, algorithms, etc.), testing strategy (use testing), infrastructure (use iac)
/devcontainerUse when configuring dev containers or GitHub Codespaces. Covers devcontainer.json schema, features, lifecycle hooks, port forwarding, and customizations.
USE FOR: devcontainer.json configuration, GitHub Codespaces setup, lifecycle hooks, port forwarding, VS Code customizations, dev container features
DO NOT USE FOR: specific language setup (use the sub-skills: dotnet, python, typescript), Docker-in-Docker configuration (use docker-in-docker), sidecar services (use multi-container-workspaces)
/dotnetUse when working with C#, F#, .NET libraries, ASP.NET Core, Blazor, Entity Framework Core, and the broader .NET ecosystem.
USE FOR: .NET language features, choosing libraries and frameworks, project structure, package selection, architecture decisions
DO NOT USE FOR: specific library configuration details (use the sub-skills: web, data, testing, eventing, cloud, etc.)
/iacUse when working with Infrastructure as Code tools and platforms. Covers Terraform, Pulumi, CloudFormation, Bicep, ARM, Kubernetes, Helm, Docker, Crossplane, and Dagger.
USE FOR: choosing IaC tools, comparing Terraform vs Pulumi vs CloudFormation, infrastructure strategy
DO NOT USE FOR: specific tool syntax (use the sub-skills: terraform, pulumi, bicep, etc.)
Other plugins' skills for the same job