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

build-tools skill

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

This skill helps you set up Python projects with uv, mise, ruff, basedpyright, and pytest for reliable builds, typing, linting, and tests.

This is most likely a fork of the atelier-python-build-tools skill from martinffx
npx playbooks add skill martinffx/claude-code-atelier --skill 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 packages a modern Python build toolchain around uv, mise, ruff, basedpyright, and pytest. It accelerates project setup, dependency management, linting/formatting, strict type checking, and test automation using pyproject.toml as the single configuration surface. The goal is reproducible, fast development workflows with sensible defaults for Python 3.12+.

How this skill works

The skill scaffolds a minimal pyproject.toml and a .mise.toml task file, then uses uv for dependency operations and environment management. Ruff performs linting and formatting (with auto-fix where available), basedpyright runs strict type checks, and pytest handles tests and coverage. Commands are executed through uv and orchestrated by mise tasks to create a single entry point for common CI and developer actions.

When to use it

  • Starting a new Python project targeting 3.12+ and wanting a fast, integrated toolchain
  • Standardizing linting, formatting, and type checking across a team
  • Automating test runs and coverage reporting in local development and CI
  • Replacing multiple tools (black, isort, mypy, pip/virtualenv) with a streamlined stack
  • Enforcing checks before commits or merges via mise tasks

Best practices

  • Pin the Python runtime in .mise.toml to ensure consistent environments
  • Keep all tooling configuration in pyproject.toml for a single source of truth
  • Enable strict type checking in basedpyright and fix issues early
  • Use uv lock and uv sync to reproduce environments across machines and CI
  • Run mise run check (lint, format, typecheck, test) in pre-commit or CI pipelines

Example use cases

  • Bootstrap a FastAPI project: uv init, add dependencies, sync, then run mise tasks to verify checks
  • Migrate an existing repo: replace black/isort/mypy with ruff and basedpyright, update pyproject.toml rules
  • Local CI mimic: use mise run check to run the identical sequence used in continuous integration
  • Incremental type adoption: enable strict basedpyright and progressively annotate code with type hints
  • Automated formatting: schedule uv run ruff format . as part of a pre-commit hook or CI job

FAQ

Do I need to switch from pip/virtualenv to use this toolchain?

No, but uv provides an integrated, faster workflow for dependency management and environments; you can adopt it incrementally.

Can I keep some existing tools (black, isort, mypy)?

Yes. Ruff can replace black/isort in most cases, and basedpyright offers a different type-checking model—mixing tools is possible during a transition.