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.
Refactors that quietly change behavior
card 5 of 6
A new error type that callers never catch
builds on: What the agent cannot see
The agent "unified error handling". Each `throw new IllegalArgumentException(...)` became `throw new InvalidOrderException(...)`, a new class extending `RuntimeException`. The tell: an exception type changed, but no catch sites appear in the diff. A controller the agent never opened catches `IllegalArgumentException` and returns 400. **Later cost:** the new type slips past that catch, so clients get 500. BETTER: extend `IllegalArgumentException`, or update every catch site and list each one.
Terms on this card
- tell
- An observable sign in a diff, transcript or summary that suggests a shortcut or an error.
- later cost
- The concrete damage a shortcut does after merge, such as a hidden bug, silent data corruption or a maintenance burden.
- IllegalArgumentException
- Standard Java unchecked exception for a bad argument. Code often catches it to return a client error such as HTTP 400.
- RuntimeException
- Java base class for unchecked exceptions. Methods need not declare them, so the compiler won't flag callers that miss them.
- controller
- The web-layer code that receives an HTTP request, calls the business logic and turns the result or error into a response.
Lesson goal: Spot 'pure cleanup' that changes behaviour: reordered side effects, a different error type, lost short-circuit evaluation, changed iteration order or null handling. Explain why callers who depend on that old behaviour break. ·
the whole lesson