1---2name: mastering-python-skill3description: Modern Python coaching covering language foundations through advanced production patterns. Use when asked to "write Python code", "explain Python concepts", "set up a Python project", "configure Poetry or PDM", "write pytest tests", "create a FastAPI endpoint", "run uvicorn server", "configure alembic migrations", "set up logging", "process data with pandas", or "debug Python errors". Triggers on "Python best practices", "type hints", "async Python", "packaging", "virtual environments", "Pydantic validation", "dependency injection", "SQLAlchemy models".4context: fork5agent: senior-python-engineer6allowed-tools:7 - Read8 - Write9 - Bash10 - Edit11 - Glob12 - Grep13metadata:14 version: 2.2.015 domains:16 - python17 - testing18 - packaging19 - web-development20 - async21 - security22---2324# Mastering Python Skill2526Production-ready Python patterns with runnable code examples.2728## Contents2930- [Workflow](#workflow)31- [Reference Files](#reference-files)32- [Sample CLI Tools](#sample-cli-tools)33- [When NOT to Use](#when-not-to-use)34- [Full Table of Contents](TOC.md)3536---3738## Workflow3940### Phase 1: Setup41421. Verify Python version43 ```bash44 python --version # Require 3.10+, prefer 3.12+45 ```46472. Create and activate virtual environment48 ```bash49 python -m venv .venv && source .venv/bin/activate50 ```51523. Install dependencies53 ```bash54 poetry install # or: pip install -r requirements.txt55 ```5657### Phase 2: Develop58594. Reference appropriate patterns:60 - Types → [type-systems.md](references/foundations/type-systems.md)61 - Async → [async-programming.md](references/patterns/async-programming.md)62 - APIs → [fastapi-patterns.md](references/web-apis/fastapi-patterns.md)63 - DB → [database-access.md](references/web-apis/database-access.md)64655. Follow project structure from [project-structure.md](references/foundations/project-structure.md)6667### Phase 3: Validate68696. Run quality checks70 ```bash71 ruff check . && ruff format --check .72 mypy src/73 ```74757. Run tests with coverage76 ```bash77 pytest -v --cov=src --cov-report=term-missing78 ```7980### Phase 4: Deploy81828. Build and verify package83 ```bash84 python -m build && twine check dist/*85 ```86879. Deploy per [docker-deployment.md](references/packaging/docker-deployment.md) or [ci-cd-pipelines.md](references/production/ci-cd-pipelines.md)8889**Pre-Completion Checklist:**90```91- [ ] All tests pass92- [ ] mypy reports no errors93- [ ] ruff check clean94- [ ] Coverage ≥80%95- [ ] No security warnings in dependencies96```9798---99100## Reference Files101102| Category | Files | Key Topics |103|----------|-------|------------|104| **Foundations** | [syntax-essentials](references/foundations/syntax-essentials.md), [type-systems](references/foundations/type-systems.md), [project-structure](references/foundations/project-structure.md), [code-quality](references/foundations/code-quality.md) | Variables, type hints, generics, src layout, ruff, mypy |105| **Patterns** | [async-programming](references/patterns/async-programming.md), [error-handling](references/patterns/error-handling.md), [decorators](references/patterns/decorators.md), [context-managers](references/patterns/context-managers.md), [generators](references/patterns/generators.md) | async/await, exceptions, Result type, with statements, yield |106| **Testing** | [pytest-essentials](references/testing/pytest-essentials.md), [mocking-strategies](references/testing/mocking-strategies.md), [property-testing](references/testing/property-testing.md) | Fixtures, parametrize, unittest.mock, Hypothesis |107| **Web APIs** | [fastapi-patterns](references/web-apis/fastapi-patterns.md), [pydantic-validation](references/web-apis/pydantic-validation.md), [database-access](references/web-apis/database-access.md) | Dependencies, middleware, validators, SQLAlchemy async |108| **Packaging** | [poetry-workflow](references/packaging/poetry-workflow.md), [pyproject-config](references/packaging/pyproject-config.md), [docker-deployment](references/packaging/docker-deployment.md) | Lock files, PEP 621, multi-stage builds |109| **Production** | [ci-cd-pipelines](references/production/ci-cd-pipelines.md), [monitoring](references/production/monitoring.md), [security](references/production/security.md) | GitHub Actions, OpenTelemetry, OWASP, JWT |110111See [TOC.md](TOC.md) for detailed topic lookup.112113---114115## Sample CLI Tools116117Runnable examples demonstrating production patterns:118119| Tool | Demonstrates | Reference |120|------|-------------|-----------|121| [async_fetcher.py](sample-cli/async_fetcher.py) | Async HTTP, rate limiting, error handling | [async-programming.md](references/patterns/async-programming.md) |122| [config_loader.py](sample-cli/config_loader.py) | Pydantic settings, .env files, validation | [pydantic-validation.md](references/web-apis/pydantic-validation.md) |123| [db_cli.py](sample-cli/db_cli.py) | SQLAlchemy async CRUD, repository pattern | [database-access.md](references/web-apis/database-access.md) |124| [code_validator.py](sample-cli/code_validator.py) | Run→check→fix with ruff and mypy | [code-quality.md](references/foundations/code-quality.md) |125126```bash127# Test examples128python sample-cli/async_fetcher.py https://httpbin.org/get129python sample-cli/config_loader.py --show-env130python sample-cli/db_cli.py init --sample-data && python sample-cli/db_cli.py list131python sample-cli/code_validator.py src/132```133134---135136## When NOT to Use137138- **Non-Python languages**: Use language-specific skills139- **ML/AI model internals**: Use PyTorch/TensorFlow skills140- **Cloud infrastructure**: Use AWS/GCP skills for infra (this covers code)141- **Legacy Python 2**: Focus is Python 3.10+