harness · 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.

HANDS-ON LAB · YOU RUN IT ON YOUR MACHINE · 4 STEPS
  1. Step 1 of 4

    Add a linter and a type checker and fix what they find

    Run this to check

    uv run ruff check . && uv run pyright

    You pass when

    Both exit 0.

    Files you write

    • pyproject.toml
  2. Step 2 of 4

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

    Run this to check

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

    You pass when

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

    Files you write

    • tests/
  3. Step 3 of 4

    Run all three before every commit

    Run this to check

    lefthook install && lefthook run pre-commit

    You pass when

    The hook runs lint, types and tests and passes.

    Files you write

    • lefthook.yml
  4. Step 4 of 4

    Try 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.

    Run this to check

    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.

    Files you write

    • AGENTS.md
No transcript here on purpose. This page does not show terminal output, because model answers differ from run to run. Each step says what a pass looks like; your own terminal is the proof.