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 4 of 6
Pin, step, commit, then check the tests
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
▸ You: Refactor `build_report` in `src/report.py`. Behaviour must not change. First add tests pinning its current output, odd inputs included, then stop so I can commit them. Then work in small steps: run `pytest` after each, then stop so I can commit. Never edit existing tests. Keep `build_report`'s name, parameters and return value.
Steps 1–3 go green.
◂ Agent: All 12 tests pass, behaviour unchanged.
You check the tests folder anyway:
Terms on this card
- refactor
- Changing how code is organised (names, structure, splitting functions) without changing what it does for anyone using it.
- commit
- A saved snapshot of your project in git that you can compare against or return to later.
- `pytest`
- A common command that runs a Python project's automated tests and reports which pass and fail.
- green
- Slang for 'all tests pass'. 'Go green' means the test run ends with no failures.
- parameters
- The named inputs a function takes, e.g. `user_id` in `get_user(user_id)`.
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