Package manager: uv for all Python operations (uv run python ... instead of python, uv add instead of pip install)
Project config: pyproject.toml with uv add <pkg> (never uv pip install or pip install)
Type checking: uv run ty check (not mypy)
Linting: uv run ruff check and uv run ruff format
Testing: uv run pytest
Task running: uv run <command> for all script execution
Virtual Environments
Let uv manage virtual environments automatically
Never manually create or activate .venv directories
Use uv run to execute within the project environment
Preferred Libraries
When applicable, prefer these libraries over alternatives:
Purpose
Library
Instead of
Logging
loguru
logging
Retries
tenacity
manual retry loops
Progress bars
tqdm
print statements
Web APIs
fastapi
flask
CLI tools
typer
argparse, click
DB migrations
alembic
manual SQL
DB ORM
sqlmodel
sqlalchemy raw
UI/demos
gradio
streamlit
Numerics
numpy
manual math
MCP servers
fastmcp
raw MCP protocol
Project Structure
Use pyproject.toml for all project metadata and dependencies
Place source code in a package directory matching the project name
Use uv workspace members for monorepo sub-packages
Run uv run ruff check, uv run ruff format, and uv run ty check before committing
Performance Conventions
Profile before optimizing — use cProfile or py-spy to find real bottlenecks
Prefer list comprehensions over for + append loops
Use generators / yield for large datasets to avoid memory spikes
Use str.join() instead of += concatenation in loops
Use dict / set for membership tests instead of list
Use functools.lru_cache for expensive pure functions
Use __slots__ on data classes instantiated at high volume
Batch database writes — avoid per-row commits
Prefer asyncio / aiohttp for I/O-bound concurrency; multiprocessing for CPU-bound
See references/performance-tips.md for profiling tool quick-reference
Testing Conventions
Follow AAA (Arrange / Act / Assert) structure in every test
One behavior per test function — if the name needs "and", split it
Name tests: test_<unit>_<scenario>_<expected_outcome>
Use pytest.raises(ExType, match=...) for exception testing
Use pytest.mark.parametrize instead of copy-pasting test variants
Use fixtures (conftest.py) for shared setup; prefer narrow scope
Use monkeypatch over unittest.mock.patch for env vars and attributes
Use tmp_path fixture for file I/O tests
Use freezegun or time-machine for time-dependent tests
Use @pytest.mark.slow / @pytest.mark.integration markers and run with -m
Configure pytest in pyproject.toml under [tool.pytest.ini_options]
Set coverage thresholds: --cov-fail-under=80
See references/testing-patterns.md for fixture scope cheat sheet and conftest skeleton
Critical Rules
Always use uv for package management — never pip install or pip
Use uv add to add dependencies — never uv pip install
Use uv run ty check for type checking — never mypy
Run uv run pytest before committing any Python changes
Run uv run ruff check and uv run ruff format before committing
Check references/exceptions.md before breaking any convention
Prefer libraries from the preferred table over their alternatives
Canonical terms (use these exactly):
uv -- the required package manager and task runner
ty -- the required type checker (not mypy)
uv run ty check -- the required type-check command
ruff -- the required linter and formatter
pyproject.toml -- the single source of project configuration
uv run -- prefix for all Python command execution
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: wyattowalsh-agents-python-conventions3description: Python Conventions4---56# Python Conventions78Apply these conventions when working on Python files or projects.910## Dispatch1112| $ARGUMENTS | Action |13|------------|--------|14| Active (auto-invoked when working on Python files) | Apply all conventions below |15| Empty | Display convention summary |16| `check` | Verify tooling compliance only |1718## References1920| File | Purpose |21|------|---------|22| `references/exceptions.md` | When to break conventions (legacy, corporate) |23| `references/performance-tips.md` | Profiling tools, optimization patterns quick-reference |24| `references/testing-patterns.md` | Fixture scopes, markers, conftest skeleton |2526## Tooling2728- **Package manager**: `uv` for all Python operations (`uv run python ...` instead of `python`, `uv add` instead of `pip install`)29- **Project config**: `pyproject.toml` with `uv add <pkg>` (never `uv pip install` or `pip install`)30- **Type checking**: `uv run ty check` (not `mypy`)31- **Linting**: `uv run ruff check` and `uv run ruff format`32- **Testing**: `uv run pytest`33- **Task running**: `uv run <command>` for all script execution3435### Virtual Environments3637- Let `uv` manage virtual environments automatically38- Never manually create or activate `.venv` directories39- Use `uv run` to execute within the project environment4041## Preferred Libraries4243When applicable, prefer these libraries over alternatives:4445| Purpose | Library | Instead of |46|---------|---------|------------|47| Logging | `loguru` | `logging` |48| Retries | `tenacity` | manual retry loops |49| Progress bars | `tqdm` | print statements |50| Web APIs | `fastapi` | flask |51| CLI tools | `typer` | argparse, click |52| DB migrations | `alembic` | manual SQL |53| DB ORM | `sqlmodel` | sqlalchemy raw |54| UI/demos | `gradio` | streamlit |55| Numerics | `numpy` | manual math |56| MCP servers | `fastmcp` | raw MCP protocol |5758## Project Structure5960- Use `pyproject.toml` for all project metadata and dependencies61- Place source code in a package directory matching the project name62- Use `uv` workspace members for monorepo sub-packages63- Run `uv run ruff check`, `uv run ruff format`, and `uv run ty check` before committing6465## Performance Conventions66671. Profile before optimizing — use `cProfile` or `py-spy` to find real bottlenecks682. Prefer list comprehensions over `for` + `append` loops693. Use generators / `yield` for large datasets to avoid memory spikes704. Use `str.join()` instead of `+=` concatenation in loops715. Use `dict` / `set` for membership tests instead of `list`726. Use `functools.lru_cache` for expensive pure functions737. Use `__slots__` on data classes instantiated at high volume748. Batch database writes — avoid per-row commits759. Prefer `asyncio` / `aiohttp` for I/O-bound concurrency; `multiprocessing` for CPU-bound7610. See `references/performance-tips.md` for profiling tool quick-reference7778## Testing Conventions79801. Follow AAA (Arrange / Act / Assert) structure in every test812. One behavior per test function — if the name needs "and", split it823. Name tests: `test_<unit>_<scenario>_<expected_outcome>`834. Use `pytest.raises(ExType, match=...)` for exception testing845. Use `pytest.mark.parametrize` instead of copy-pasting test variants856. Use fixtures (`conftest.py`) for shared setup; prefer narrow scope867. Use `monkeypatch` over `unittest.mock.patch` for env vars and attributes878. Use `tmp_path` fixture for file I/O tests889. Use `freezegun` or `time-machine` for time-dependent tests8910. Use `@pytest.mark.slow` / `@pytest.mark.integration` markers and run with `-m`9011. Configure pytest in `pyproject.toml` under `[tool.pytest.ini_options]`9112. Set coverage thresholds: `--cov-fail-under=80`9213. See `references/testing-patterns.md` for fixture scope cheat sheet and conftest skeleton9394## Critical Rules95961. Always use `uv` for package management — never `pip install` or `pip`972. Use `uv add` to add dependencies — never `uv pip install`983. Use `uv run ty check` for type checking — never `mypy`994. Run `uv run pytest` before committing any Python changes1005. Run `uv run ruff check` and `uv run ruff format` before committing1016. Check `references/exceptions.md` before breaking any convention1027. Prefer libraries from the preferred table over their alternatives103104**Canonical terms** (use these exactly):105- `uv` -- the required package manager and task runner106- `ty` -- the required type checker (not mypy)107- `uv run ty check` -- the required type-check command108- `ruff` -- the required linter and formatter109- `pyproject.toml` -- the single source of project configuration110- `uv run` -- prefix for all Python command execution111112---113> Converted and distributed by [TomeVault](https://tomevault.io/claim/wyattowalsh) — claim your Tome and manage your conversions.114<!-- tomevault:4.0:skill_md:2026-04-15 -->
Run npx skillmds@latest add tomevault-io/wyattowalsh-agents-python-conventions in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Python Conventions It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
tomevault-io (@tomevault-io) published this skill. Their other Agent Skills are listed on their SkillMD profile.