home / skills / martinffx / claude-code-atelier / atelier-python-build-tools

atelier-python-build-tools skill

/plugins/atelier-python/skills/atelier-python-build-tools

This skill helps you set up Python projects with uv, mise, ruff, basedpyright, and pytest for faster builds, type checking, and testing.

npx playbooks add skill martinffx/claude-code-atelier --skill atelier-python-build-tools

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
2.9 KB
---
name: python:build-tools
description: Python project tooling with uv, mise, ruff, basedpyright, and pytest. Use when setting up pyproject.toml, running builds, typechecking, configuring tests, linting, formatting, or managing Python environments.
user-invocable: false
---

# Python Build Tools

Modern Python development tooling using uv, mise, ruff, basedpyright, and pytest.

## Quick Start

### Minimal pyproject.toml

```toml
[project]
name = "my-project"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = ["fastapi", "pydantic"]

[project.optional-dependencies]
dev = ["pytest>=8.0.0", "ruff>=0.8.0", "basedpyright>=1.0.0"]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.ruff]
target-version = "py312"

[tool.ruff.lint]
select = ["E", "F", "I", "N", "UP", "RUF"]

[tool.basedpyright]
typeCheckingMode = "strict"

[tool.pytest.ini_options]
testpaths = ["tests"]
```

### Setup Project

```bash
uv init my-project && cd my-project
uv sync
uv add fastapi pydantic
uv add --dev pytest ruff basedpyright
```

## Tool Overview

| Tool | Purpose | Replaces |
|------|---------|----------|
| **uv** | Package management | pip, virtualenv |
| **mise** | Version & tasks | pyenv, asdf |
| **ruff** | Lint & format | black, isort, flake8 |
| **basedpyright** | Type checking | mypy |
| **pytest** | Testing | unittest |

## Common Commands

### Lint and Format

```bash
uv run ruff check --fix .
uv run ruff format .
```

### Type Check

```bash
uv run basedpyright
uv run basedpyright src/main.py
```

### Test

```bash
uv run pytest
uv run pytest --cov=src --cov-report=html
```

### Manage Dependencies

```bash
uv add fastapi
uv add --dev pytest
uv lock --upgrade
uv tree
```

## Mise Configuration

Create `.mise.toml` for consistent development:

```toml
[tools]
python = "3.12"

[tasks.lint]
run = "uv run ruff check --fix ."

[tasks.format]
run = "uv run ruff format ."

[tasks.typecheck]
run = "uv run basedpyright"

[tasks.test]
run = "uv run pytest"

[tasks.check]
depends = ["lint", "format", "typecheck", "test"]
```

Usage:

```bash
mise install
mise run check
```

## Type Hints Example

```python
from decimal import Decimal
from typing import Optional

def calculate_discount(
    total: Decimal,
    rate: Optional[Decimal] = None
) -> Decimal:
    if rate is None:
        rate = Decimal("0.1")
    return total * rate
```

## Best Practices

1. Use uv for all package management (faster, reliable)
2. Pin Python version with mise
3. Configure tools in pyproject.toml
4. Enable strict type checking
5. Run checks before commit

## References

For detailed configuration and advanced patterns:

- **[references/uv.md](references/uv.md)** - Workspaces, scripts, dependency management
- **[references/ruff.md](references/ruff.md)** - Rules, per-file ignores, pre-commit integration
- **[references/basedpyright.md](references/basedpyright.md)** - Type patterns, generics, protocols

Overview

This skill provides a focused toolkit for modern Python projects using uv, mise, ruff, basedpyright, and pytest. It helps you create a minimal pyproject.toml, manage dependencies and environments, enforce linting/formatting, run strict type checks, and configure repeatable test runs. The goal is fast, opinionated developer workflows that prioritize code quality and reproducibility.

How this skill works

The skill scaffolds project configuration (pyproject.toml and .mise.toml) and exposes common commands run through uv and mise. It wires ruff for linting/formatting, basedpyright for strict type checking, and pytest for testing, and it maps tasks to mise so you can run composite checks. Dependency management, locking, and workspace commands are handled through uv to keep environments consistent and reproducible.

When to use it

  • Initializing a new Python project with modern tooling and locked dependencies
  • Standardizing linting, formatting, and type checking across a team
  • Setting up continuous quality checks (pre-commit, CI pipelines, or mise tasks)
  • Running fast local test and coverage reports with pytest
  • Pinning Python versions and project tasks using mise for consistent developer environments

Best practices

  • Keep configuration in pyproject.toml to centralize tool settings
  • Pin the Python runtime with .mise.toml to avoid “works on my machine” issues
  • Enable strict typeCheckingMode in basedpyright for earlier bug detection
  • Use ruff to replace multiple linters/formatters for a single fast toolchain
  • Run mise run check (lint, format, typecheck, test) before committing code

Example use cases

  • Create a minimal project: uv init, add runtime deps and dev tools, then uv sync and uv lock for reproducible installs
  • Automate developer checks: define lint/format/typecheck/test tasks in .mise.toml and run mise run check locally or in CI
  • Enforce types: add basedpyright to dev dependencies and run uv run basedpyright for strict type validation
  • Fast formatting and linting: run uv run ruff format . and uv run ruff check --fix . as part of pre-commit or CI
  • Run tests and coverage: uv run pytest --cov=src --cov-report=html to generate coverage reports for PRs

FAQ

Can I use these tools with existing projects?

Yes. Add the dev dependencies to your project, configure pyproject.toml and .mise.toml, then run uv sync and the appropriate mise tasks to adopt the toolchain incrementally.

What replaces my current linters and formatters?

ruff covers formatting and linting responsibilities typically handled by black, isort, flake8, and similar tools, simplifying configuration and speeding up checks.