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: fixing a bug from an error message
card 5 of 6
What the agent does, and what you check
builds on: Giving the right context: files, errors, examples, Tests as the definition of done
⚙ Edit: `tests/test_report.py` adds `test_empty_category`, which expects "n/a". ⚙ Run: `pytest tests/test_report.py` fails with `ZeroDivisionError` at line 14. That is your failure, so the bug is captured. ◂ Agent: 'Root cause: `average` divides by `len(values)` and gets an empty list for categories with no rows.' This matches the trace. The fix makes `average` return "n/a" for an empty list. ⚙ Run: `pytest` shows all tests pass. The diff touches only `average` and the new test. Finally you run `python src/report.py data/march.csv` yourself, and the empty category shows `n/a`.
Terms on this card
- root cause
- The underlying reason a bug happens, as opposed to the line where it finally shows up as a crash.
- ZeroDivisionError
- Python error raised when code divides a number by zero.
- pytest
- A popular Python tool that finds and runs automated tests and reports which passed and which failed.
- diff
- A line-by-line listing of what changed in files: removed lines marked '-', added lines marked '+'.
- CSV
- Comma-separated values: a plain text file of table data, one row per line, with columns separated by commas.
Lesson goal: Fix a bug end to end. Give the exact error and how to reproduce it, have it reproduce the failure as a test first, review the root-cause explanation, apply the minimal fix, and confirm the test passes and nothing else broke. ·
the whole lesson