LernerPython

Keeping AI on a short leash: Types, tests, reviews, and CI for agentic code

Claude Code writes good code, but every change can break something that used to work, and an agent in a hurry can quietly weaken the checks meant to catch it. In this course, you’ll learn how to keep AI on a short leash: linting and formatting with Ruff, strict type checking with mypy and Pydantic, test-driven development with pytest, mutation and property-based testing, Playwright, CI with GitHub Actions, and code reviews, all enforced automatically through CLAUDE.md and hooks.

What you should know

Course Content

Course length

About 5¼ hours

Number of lessons

42

Training materials

5 projects, hooks, and AGENTS.md (zip)

Coding exercises

6

LEARN MORE

Claude Code writes good code. But every change can break something that used to work, and an agent in a hurry can quietly weaken the very checks meant to catch it. In this course, you’ll learn how to keep AI on a short leash, so you can trust what it writes: linters, type checkers, automated tests, CI, and code reviews, all enforced automatically through CLAUDE.md and hooks instead of hoping Claude remembers. It builds on Intro to agentic coding with Claude Code. You’ll need a paid Claude plan or API account to follow along.

  • How to enforce linting and formatting with Ruff, and run it automatically with hooks
  • How to use mypy, strict typing, and Pydantic so mistakes are caught before the code runs
  • How to have Claude Code use test-driven development with pytest and 100% coverage
  • How mutation testing and Hypothesis show whether your tests really catch bugs
  • How to test front-end code with Playwright, and what to watch out for with Docker
  • How to save time, money, and tokens by running only the tests a change can affect
  • How to set up CI with GitHub Actions and the gh client, and decide what to test there
  • How to review AI-written code, both by hand and with AI, and whether humans still need to

This course, like all others on LernerPython.com, is taught by Reuven Lerner.