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.
Errors swallowed by catch-all handlers
card 5 of 6
BETTER: report it, or recover on purpose
builds on: Error handling idioms across languages, Agents optimise the signal they can see
In Go, the agent "handled" a failing save in `func saveUser(...) error` with `if err != nil { return nil }`. The tell: a `nil` error means success, so the caller goes on to email a user who was never stored. BETTER: `return fmt.Errorf("save user %d: %w", id, err)`. For the Python job, BETTER means validating the address *before* `mark_paid`, logging the order id, and making the run fail visibly.
Terms on this card
- tell
- An observable sign in a diff, transcript or summary that suggests a shortcut or an error.
- %w
- Go `fmt.Errorf` verb that wraps an error inside a new one with added context. Callers can still inspect it with `errors.Is`/`errors.As`.
- nil
- Go's zero value for pointers, interfaces and errors. A `nil` error means "no error", i.e. success.
- the agent
- The AI coding system doing the work: a chat assistant, IDE agent or terminal agent.
- fmt.Errorf
- Go function that builds a new error from a format string; with %w it wraps an existing error.
Lesson goal: Spot `except Exception: pass`, an empty `catch (e) {}`, Java's `catch (Exception e) { e.printStackTrace(); }`, Go's `_ = err` or `if err != nil { return nil }`, and Rust's `.ok()` discarding errors. Explain the later cost: failures become invisible and state is left half-updated. ·
the whole lesson