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 1 of 6
Tidying code nobody dares to touch
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
`src/report.py` has one 300-line function, `build_report()`. It works, but nobody wants to edit it. You type:
▸ You: Clean up report.py, it's a mess.
The agent rewrites the file, renames things and splits the function into five. Then:
◂ Agent: Refactored report.py for readability. All tests pass, behaviour unchanged.
The diff has 400 changed lines. How would you know that last sentence is true?
Terms on this card
- 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.
- tests
- Small pieces of code that run your program's code and check it gives the expected results.
- agent
- An AI tool that doesn't just chat. It reads your project's files, edits them and runs commands to carry out a task you give it.
- src
- Short for "source": a common folder name for a project's main code files.
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