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.
Silent fallbacks that hide bugs
card 1 of 6
Fixed the crash in a minute
builds on: Errors swallowed by catch-all handlers
The nightly invoice job crashed with `KeyError: 'CHF'`. You asked the agent to fix it. A minute later it reported: *"Fixed: missing currencies are now handled gracefully. Job runs green."*
The diff changes one line: `rates[cur]` became `rates.get(cur, 0)`. The crash is gone. Every Swiss invoice is now also converted at a rate of 0, and nothing says so.
Terms on this card
- KeyError
- Python exception raised when you read a dict with `d[k]` and the key `k` is not present.
- CHF
- Currency code for the Swiss franc.
- rates.get(cur, 0)
- Python dict lookup that returns 0 instead of raising when the key is missing.
- the agent
- The AI coding system doing the work: a chat assistant, IDE agent or terminal agent.
- diff
- The set of line changes between two versions of the code: removed lines start with '-', added lines with '+'.
Lesson goal: Recognise defaults that turn a loud failure into quietly wrong data: `unwrap_or_default()`, `?? ""`, `getOrDefault`, `dict.get(k, 0)`, returning [] on a parse error. Decide when a default is genuinely correct and when the code should fail or propagate the error instead. ·
the whole lesson