/python-development:python-developmentfrom python-development
Guides modern Python development with tooling like uv, ruff, mypy, and pytest. Covers scripts, libraries, async patterns, CLI apps, and MicroPython.
Ships in python-development. 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.
Expert guidance for modern Python development (Python 3.11-3.14+), covering everything from simple scripts to production-grade systems, library architecture, and embedded development.
Activate this skill when:
.py files, pyproject.toml, or uv.lockuv, pytest, ruff, or mypytypescript-developmentreact-developmenttest-driven-development (this skill covers pytest patterns but not the full TDD workflow)What are you building?
│
├─ Single-file script, one-off utility, quick data processing
│ └─ MINIMAL tier: PEP 723 inline metadata, no project scaffolding
│
├─ Multi-file project, team development, anything with tests
│ └─ STANDARD tier (default): src/ layout + uv + ruff + mypy + pytest
│
└─ PyPI package, production system requiring CI/CD
└─ FULL tier: Complete tooling + bandit + CI/CD + release workflow
Default to Standard — it covers most use cases.
Does the task involve I/O-bound operations (HTTP, DB, file, network)?
│
├─ No → Use synchronous code (simpler, easier to debug)
│
└─ Yes → Are operations concurrent (many requests at once)?
│
├─ No → Simple async/await with httpx.AsyncClient
│
└─ Yes → asyncio.Semaphore per resource + httpx.AsyncClient
with connection pooling + retry logic
Do you need structural subtyping (duck typing with type safety)?
│
├─ Yes → Protocol
│ └─ Enables dependency injection, avoids inheritance coupling
│
└─ No → Do you need runtime type checking or enforced method implementation?
│
├─ Yes → ABC with @abstractmethod
│
└─ No → Protocol (lighter weight, preferred default)
Will this code be imported by other projects?
│
├─ Yes → Library architecture:
│ - Protocol-based API surface
│ - py.typed marker
│ - Minimal public exports (__all__)
│ - Stable deprecation policy
│ - pyproject.toml with [project.optional-dependencies]
│
└─ No → Application architecture:
- Direct implementation (no Protocol overhead)
- Simpler project structure
- pyproject.toml with [project.scripts]
# Install Python 3.12+ and uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Create new project
uv init my-project
cd my-project
# Add dependencies
uv add requests pydantic httpx
# Add dev dependencies
uv add --dev pytest pytest-cov ruff mypy
# Run quality checks
uv run ruff check . # Linting
uv run ruff format . # Formatting
uv run mypy . # Type checking
uv run pytest --cov # Tests with coverage
uv.lock for reproducible buildsUse current tool documentation when exact flags matter; uv, ruff, mypy, and pytest move quickly. The defaults below are stable project-starting patterns, not a substitute for checking release notes during migrations.
uv init my-project && cd my-project # Initialize
uv add requests pandas numpy # Add deps
uv add --dev pytest ruff mypy # Add dev deps
uv sync # Sync with lockfile
uv lock --upgrade # Update lockfile
uv run python script.py # Run code
uv run pytest # Run tests
ruff check . # Check for issues
ruff check --fix . # Auto-fix issues
ruff format . # Format code
mypy . # Type check entire project
mypy --strict . # Strict mode
myproject/
├── src/
│ └── myproject/
│ ├── __init__.py
│ ├── main.py
│ └── utils.py
├── tests/
│ ├── __init__.py
│ ├── conftest.py
│ ├── test_main.py
│ └── test_utils.py
├── docs/
├── .gitignore
├── .python-version
├── pyproject.toml
├── uv.lock
└── README.md
[project]
name = "myproject"
version = "0.1.0"
requires-python = ">=3.11"
dependencies = ["requests>=2.31.0"]
[project.optional-dependencies]
dev = ["pytest>=8.0.0", "ruff>=0.8.0", "mypy>=1.13.0"]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.ruff]
line-length = 100
target-version = "py311"
[tool.ruff.lint]
select = ["E", "F", "I", "N", "W", "B", "Q"]
[tool.mypy]
python_version = "3.11"
strict = true
[tool.pytest.ini_options]
testpaths = ["tests"]
| Anti-Pattern | Problem | Solution |
|---|---|---|
Mutable default args def f(lst=[]) | Default value is shared across all calls; mutations persist unexpectedly | def f(lst: list | None = None) then lst = lst or [] inside |
requests.get in async | Blocks the event loop; all concurrent tasks stall | httpx.AsyncClient for async HTTP; requests only in sync code |
| Classes for data bags | Boilerplate __init__, mutable by default, no equality | @dataclass(frozen=True) for immutable value objects, or NamedTuple for lightweight records |
| Deep inheritance hierarchies | Tight coupling, fragile base class, hard to test | Protocol + composition; define behavior by what it does, not what it is |
| Mutating function args | Side effects make code unpredictable and hard to test | Return new values; use frozen dataclasses; prefer pure functions |
try/except Exception | Swallows all errors including KeyboardInterrupt, SystemExit | Catch specific types: except (ValueError, KeyError) |
| Blocking in async | time.sleep(), requests.get(), subprocess.run() freeze the event loop | await asyncio.to_thread(fn) or asyncio.sleep() for non-blocking alternatives |
from module import * | Pollutes namespace, makes dependencies invisible, breaks linters | Explicit imports: from module import ClassA, func_b |
Bare except: | Catches everything including SystemExit/KeyboardInterrupt; hides bugs | except (SpecificError, AnotherError): |
Using List[str] etc. | Legacy typing; deprecated since Python 3.9 | Use modern syntax: list[str], dict[str, int], tuple[int, ...] |
| Ignoring mypy errors | Type errors at compile time become runtime crashes | Fix the type; use # type: ignore[specific-code] with comment explaining why |
| Testing with production URLs | Tests hit real APIs, flaky, slow, depend on network | Mock HTTP calls with pytest-httpx or respx; test against fixtures |
Every Python task must pass:
uv run ruff format .uv run ruff check .uv run mypy .uv run pytest (>80% coverage)list[str] not List[str])For critical code (payments, auth, security):
uv run bandit -r src/See Extended Patterns for detailed code examples, testing patterns, async patterns, itertools/functools usage, library architecture, workflow routing, and complete reference file listings.
assets/CONTRIBUTING.md.template (opens in a new tab)assets/README.md.template (opens in a new tab)assets/example-config.py (opens in a new tab)assets/example-exceptions.py (opens in a new tab)assets/example.pre-commit-config.yaml (opens in a new tab)assets/hatch_build.py (opens in a new tab)assets/nested-typer-exceptions/README.md (opens in a new tab)assets/nested-typer-exceptions/nested-typer-exception-explosion.py (opens in a new tab)assets/nested-typer-exceptions/nested-typer-exception-explosion_corrected_rich_console.py (opens in a new tab)assets/nested-typer-exceptions/nested-typer-exception-explosion_corrected_typer_echo.py (opens in a new tab)assets/nested-typer-exceptions/nested-typer-exception-explosion_naive_workaround.py (opens in a new tab)assets/project-structure.txt (opens in a new tab)assets/pyproject-toml-template.toml (opens in a new tab)assets/pyproject.toml.template (opens in a new tab)assets/test-structure.txt (opens in a new tab)assets/typer_examples/console_containers_no_wrap.py (opens in a new tab)assets/typer_examples/console_no_wrap_example.py (opens in a new tab)assets/typer_examples/index.md (opens in a new tab)assets/version.py (opens in a new tab)best-practices-README.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub viktorbezdek/skillstack --plugin python-developmentOther plugins' skills for the same job