All labs · Lab 33 · intermediate · 40 min

Make AI-written code safe to merge

Set up the checks that catch a coding agent's mistakes before a person has to: lint, types, tests with a coverage floor, and a commit hook.

You build: A repo where a bad commit is refused on your machine, by tools rather than by review.

  • Python 3.11 or newer and uv
  • Any small Python project (the harness from lab 30 works)
  1. 01Add a linter and a type checker and fix what they find

    uv run ruff check . && uv run pyright

    You pass when: Both exit 0.

  2. 02Write tests until coverage reaches 80 percent, and make less than that a failure

    uv run pytest --cov --cov-fail-under=80

    You pass when: Tests pass and the coverage line shows 80 percent or more.

  3. 03Run all three before every commit

    lefthook install && lefthook run pre-commit

    You pass when: The hook runs lint, types and tests and passes.

  4. 04Try to commit a file with an unused import

    Checks a machine runs are the only review that scales with the amount of code an agent writes.

    git commit -am "should fail"; echo "exit $?"

    You pass when: The commit is refused and the exit code is not 0. Add the three commands to AGENTS.md so the agent runs them itself.

The check runs on the computer, not on your word: a step passes when its command exits with 0 there.

Your computer · Fleet · off

Computers are not set up on this site yet. Run each command on your own machine and compare with "You pass when".