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 bad shortcuts in a change
card 5 of 6
Three shortcuts in eight lines
builds on: Reviewing the diff the agent made
`except Exception: pass` hides the error. For a bad row, `price` silently keeps the previous row's value, so the totals are wrong. If the very first row is bad, `price` was never set and the script crashes at `totals.append(price)` anyway. `if path == "march.csv"` is a special case for the one file the agent tried. `9.99` is a hardcoded, made-up price for that file's empty cells, so that one run finishes and looks right.
@@ -12,3 +12,8 @@ def load_prices(path):
for row in rows:
- price = float(row["price"])
+ try:
+ price = float(row["price"])
+ except Exception:
+ pass # ignore bad rows
+ if path == "march.csv" and row["price"] == "":
+ price = 9.99
totals.append(price)
Terms on this card
- CSV
- Comma-separated values: a plain text file holding a table, one row per line, with columns separated by commas.
- except Exception
- Python syntax that catches almost any error raised in the `try` block above it. Followed by `pass`, it ignores that error completely.
- pass
- A Python statement that does nothing. It fills a spot where code is required but no work is done.
- Special case
- Code that behaves differently for one specific input, such as a single file name or customer ID, instead of handling the general situation.
- script
- A small program, usually one file, that you run to do a task, like `report.py`.
Lesson goal: Recognise typical shortcuts: hardcoded values, swallowed errors (empty catch blocks), disabled checks or linters, special cases for one input, and 'TODO' stubs presented as finished work. ·
the whole lesson