AICODEAgentic Programming · 67723 · 2026-7

Week 5 · practice exercises

Practice: Tests, Types and Checks

Optional · not graded · with your own coding agent

Optional practice after this week’s videos, ungraded. Each exercise takes ten to twenty minutes with your own coding agent, on a project of yours, and shows one idea from the videos at work.

Before you start: use a branch, so every experiment is easy to throw away.

Testing: Kinds of Tests, and Having the Agent Write Them

  • Watch the agent edit the test. Write a test the code cannot pass, one that contradicts what the program is meant to do, and tell the agent “make the tests pass”. See what it does: change the test, hardcode the expected value, or tell you the test is wrong. Repeat with “don’t edit the tests; if a test is wrong, say so” and compare.
  • A bug becomes a test first. Take a bug you have met, or plant one. Ask the agent for a small test that reproduces it before any fix, check that the test fails for the right reason, and only then let the agent fix the bug.

Testing GUIs and the Logic Behind Them

  • Disconnect the button. In a small web app, ask the agent for one Playwright test of one interaction and one test of the function behind it. Then disconnect the button from that function: the function’s test still passes, and only the browser test notices.

What Tests Cost, and Which Ones to Keep

  • Grill the agent on coverage. Ask the agent to measure your project’s branch coverage (pytest --cov --cov-branch). It will not be 100%. For every uncovered line, make the agent say what it is: a case nobody tested, an error path, or code nothing uses. When it says 100% cannot be reached, push back: which line cannot be reached, and why? Can it be tested, or deleted? Then ask it for one test that raises coverage while checking nothing, and watch the number go up anyway.
  • Break it on purpose. Remove or invert one rule in the code, such as a validation, and run the tests. If they still pass, you have found a missing test. Have the agent write the test that fails, then restore the rule.

Type Checking, Linters & Formatters

  • Types and lint as sensors. Run mypy --strict and Ruff with the B rules on a project you wrote with an agent, and ask the agent which reports are real bugs and which are noise. Then change one function’s signature and see every call site reported before anything runs.

Writing CLAUDE.md

  • Does the agent know your checks? Run /init on a project and cut what it wrote down to what the agent could not work out by itself. Start a fresh session and just say “check the project”. Does it run the right test, type and lint commands?