Python project workflow and standards using Astral uv for environments/dependencies, ty for type checking, typer for CLI, ruff for lint/format, pytest and pytest-cov for tests/coverage, and loguru for logging. Use for Python project setup, dependency management, CLI/logging patterns, type checking, testing, linting/formatting, and packaging guidance.
/plugin marketplace add narumiruna/claude-marketplace/plugin install python-skills@narumiThis skill inherits all available tools. When active, it can use any tool Claude has access to.
references/cli-logging.mdreferences/packaging.mdreferences/quality.mdreferences/uv-scripts.mdBuild and maintain Python 3.12+ projects with modern tooling and best practices. Follow the steps below for project setup, dependency management, quality tools, CLI patterns, and packaging workflows.
Key tools:
For Python coding conventions, see the python-conventions skill.
uv init my-project
cd my-project
uv add loguru typer
uv add --dev ruff pytest pytest-cov ty
uv run python -V
# Confirm the expected Python version
Use a src/ layout for better import clarity and testing isolation:
my-project/
├── src/
│ └── my_project/
│ ├── __init__.py
│ ├── cli.py
│ └── core.py
├── tests/
│ ├── __init__.py
│ └── test_core.py
└── README.md
Benefits of a src/ layout:
Basic operations:
uv add <package>uv add --dev <package>uv add --group <name> <package>uv run <command>uv syncKey principles:
uv run <command> instead of plain python or tool commands.--dev for tools that are not needed in production (ruff, pytest, ty).Read references/uv-scripts.md for inline metadata, --no-project, and --with flags.
Lint and format with ruff:
uv run ruff check # Check for issues
uv run ruff check --fix # Auto-fix issues
uv run ruff format # Format code
Type check with ty:
uv run ty check # Type check all code
Test with pytest and coverage:
uv run pytest # Run tests
uv run pytest --cov=src --cov-report=term-missing # With coverage
uv run pytest -v tests/test_specific.py # Specific test file
Use this pre-commit quality gate:
uv run ruff check --fix
uv run ruff format
uv run ty check
uv run pytest
Read references/quality.md for tool configuration and recommended settings.
Use typer for CLIs:
import typer
app = typer.Typer()
@app.command()
def greet(name: str, count: int = 1) -> None:
"""Greet someone multiple times."""
for _ in range(count):
typer.echo(f"Hello, {name}!")
if __name__ == "__main__":
app()
Use loguru for logging:
from loguru import logger
logger.info("Application started")
logger.warning("Low disk space: {free} MB", free=512)
try:
# Some operation that might fail
connect_to_service()
except Exception as err:
logger.error("Failed to connect: {error}", error=err)
Read references/cli-logging.md for complete examples and advanced patterns.
Build distribution packages:
uv build # Build wheel and sdist
uv build --no-sources # Build wheel only (for publish checks)
Check outputs in dist/:
*.whl - Wheel package*.tar.gz - Source distributionRead references/packaging.md for publish workflows and checks.
references/uv-scripts.mdreferences/quality.mdreferences/cli-logging.mdreferences/packaging.mdpython-conventions skillreferences/uv-scripts.md - Running scripts with uvreferences/quality.md - Ruff, pytest, and ty configurationreferences/cli-logging.md - Typer and loguru patternsreferences/packaging.md - Build and publish workflowsMaster authentication and authorization patterns including JWT, OAuth2, session management, and RBAC to build secure, scalable access control systems. Use when implementing auth systems, securing APIs, or debugging security issues.