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
-
Add a linter and a type checker and fix what they find
Run this to check
uv run ruff check . && uv run pyrightYou pass when
Both exit 0.
Files you write
- pyproject.toml
-
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=80You pass when
Tests pass and the coverage line shows 80 percent or more.
Files you write
- tests/
-
Run all three before every commit
Run this to check
lefthook install && lefthook run pre-commitYou pass when
The hook runs lint, types and tests and passes.
Files you write
- lefthook.yml
-
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.