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.
git status and reading a diff
card 5 of 6
The diff behind "fixed the crash"
builds on: Git commits as snapshots you can return to
Skip the `diff --git` and `index` lines: they are git's bookkeeping. `--- a/` names the old `src/cart.py` and `+++ b/` names the new one. These two lines are file names, not removed or added lines. The text after the second `@@` is git naming the function this section sits in. A changed line usually appears as a `-` line followed by its `+` replacement.
diff --git a/src/cart.py b/src/cart.py
index 3b18e51..a1c2d4f 100644
--- a/src/cart.py
+++ b/src/cart.py
@@ -2,5 +2,6 @@ def total(items):
"""Sum item prices."""
s = 0
for it in items:
- s += it.price
+ if it.price is not None:
+ s += it.price
return s
Terms on this card
- function
- A named, reusable block of code, like `get_data`, that other parts of the program call.
- git
- A tool that records versions of a project's files over time. Its data lives in the hidden `.git` folder.
- src
- Short for "source": a common folder name for a project's main code files.
- diff
- A listing of exactly which lines were removed (-) and added (+) between two versions of files.
Lesson goal: Use `git status` to see which files changed and `git diff` to see exactly how. Read a unified diff's '-', '+' and '@@' lines without help. ·
the whole lesson