Work effectively with AI coding agents. Understand them as language models running in a tool loop with limited context, which is why they guess, game the visible signal and report confidently. Recognise the shortcut and correctness tells in their code across Python, TypeScript/JavaScript, Rust, Java and Go, and know the damage each one does later. Verify changes instead of trusting them, review diffs fast for quality and security, judge when work is truly finished, and choose, design and steer tasks so agents can finish them well.
Patching the symptom instead of the cause
card 4 of 6
A guard a few lines below the cause
builds on: Agents optimise the signal they can see
The crash happens on `user.email`, so the agent guarded there. The cause is a few lines up: `load_users(active=True)` leaves out deactivated customers, but their invoices still arrive.
Now `continue` skips those invoices. **Later cost:** the report finishes and under-counts revenue, with no error anywhere.
The fix at the cause: load every user the invoices reference, including inactive ones. If a user is truly missing, fail loudly.
// Python
--- a/billing/report.py
+++ b/billing/report.py
@@ -3,7 +3,9 @@ def build_rows(invoices):
users = {u.id: u for u in
load_users(active=True)}
rows = []
for inv in invoices:
user = users.get(inv.user_id)
+ if user is None:
+ continue
rows.append((user.email, inv.total))
return rows
Terms on this card
- later cost
- The concrete damage a shortcut does after merge, such as a hidden bug, corrupted data or extra maintenance.
- guard
- An early check that returns, skips or branches when a condition holds, so the code below never runs on that input.
- continue
- Python keyword that skips the rest of the current loop iteration and moves on to the next item.
- the agent
- The AI coding system doing the work: a chat assistant, IDE agent or terminal agent.
Lesson goal: Spot fixes applied where the error surfaces rather than where it originates: a null check at the crash site, a special case for the failing input, a catch around the throwing line. Explain why the error disappears but the cause keeps producing bad results. ·
the whole lesson