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.
Workflow: refactoring safely with an agent
card 2 of 6
Passing tests only prove what they cover
builds on: Workflow: having the agent write tests, Tests as the definition of done, Doing a bigger change plan-first, step by step, Branches for risky or alternative attempts
A **refactor** changes the shape of code, not what it does. Your proof that behaviour didn't change is the tests, but only for the behaviour they actually check. Untested behaviour can change silently. Passing tests are also the agent's goal, so if one fails it may "fix" the test instead of the code. And if it renames a function other code calls, nothing may complain. A 400-line diff is too big to review well.
Terms on this card
- refactor
- Changing how code is organised (names, structure, splitting functions) without changing what it does for anyone using it.
- diff
- A listing of exactly which lines were removed (-) and added (+) between two versions of files.
- function
- A named, reusable block of code, like `get_data`, that other parts of the program call.
- test
- A small piece of code that runs part of your program and checks the result matches what's expected, reporting pass or fail.
- tests
- Small pieces of code that run your program's code and check it gives the expected results.
Lesson goal: Refactor safely by making sure tests cover the behaviour first, then asking for behaviour-preserving changes in small committed steps on a branch. Check that no test or public interface was quietly changed. ·
the whole lesson