Go from never having used a coding agent to working productively and safely with one. The learner should understand what an agent is and how it differs from a chat assistant. They should choose a tool, set up a protected first project, describe tasks the agent can do well, and follow and verify its work. They should recover from bad changes, manage context, and plan bigger changes. They should also use tests as the definition of done and run everyday workflows (bug fixes, features, writing tests, codebase exploration, scripts, small tools, refactors). Throughout, they should keep secrets and systems safe and keep their own understanding growing instead of outsourcing it.
Spotting tests bent to pass
card 5 of 6
Forbid it up front, then check anyway
builds on: Spotting bad shortcuts in a change, What automated tests are and how to run them
▸ You: Fix the bug in `src/prices.py` so `test_discount` passes. Don't edit, skip or delete any test, don't loosen assertions, don't mock `apply_discount`, and add no special cases for test values. If you think a test is wrong, stop and explain why.
The agent can still break the rule, so check it. `git diff --stat` should list only `src/` files. The `src/` diff should have no `if` on exact test values like `"SAVE10"`. Your own `pytest` run should show no new `skipped`.
Terms on this card
- pytest
- A popular Python tool that finds and runs a project's tests, then reports how many passed, failed or were skipped.
- mock
- A fake stand-in for a real piece of code, used in tests. It returns whatever answer it was told to, without running the real code.
- skipped
- A test the runner was told not to run. It is reported as skipped, not as failed, so a skipped test can hide a bug.
- git diff --stat
- A git command that lists which files changed and how many lines were added or removed in each, without showing the full changes.
- diff
- A listing of what changed between two versions of files: removed lines start with '-', added lines start with '+'.
Lesson goal: Recognise when an agent makes tests pass by changing or deleting the tests, loosening assertions, mocking away the real code, or special-casing test inputs. Know how to forbid this in the task. ·
the whole lesson