This folder contains the sample code for the Real Python tutorial How to Set Up a Python Project for Agentic Coding.
It is the finished project from the tutorial: a small Python package wired up with the automated feedback an AI coding agent needs, namely Ruff for linting and formatting, mypy in strict mode for type checking, pytest with a coverage gate for behavior, and pre-commit to run those checks before every commit.
Install uv, then install the dependencies and the pre-commit hooks:
$ uv sync
$ uv run pre-commit installEach tool can be run on its own:
$ uv run ruff check .
$ uv run mypy .
$ uv run pytestOr run everything the way the agent is told to in AGENTS.md:
$ uv run pre-commit run --all-files| File | Purpose |
|---|---|
pyproject.toml |
Dependencies plus the Ruff, mypy, and pytest configuration |
AGENTS.md |
Workflow conventions an agent should follow |
.pre-commit-config.yaml |
Checks that run before each commit |
tests/ |
Executable specification of the expected behavior |
.env.example |
Documents required environment variables without exposing secrets |