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 2 of 6
Looks the same is not behaves the same
builds on: What the agent cannot see
The agent judges equivalence by reading. Two versions that *look* alike feel alike. But it opened the function, not its callers. It never saw production data with missing cards, or the reason one check came first. Tests usually cover the main path, so green is a proxy signal here: same results on easy inputs. **Later cost:** callers that relied on an error type, an order or a skipped call break far from the diff.
Terms on this card
- later cost
- The concrete damage a shortcut does after merge, such as a hidden bug, silent data corruption or a maintenance burden.
- proxy signal
- A visible stand-in for the real goal, such as tests passing or code compiling, that can be satisfied without reaching the goal.
- the diff
- The change under review in unified diff format: '-' lines removed, '+' lines added, unprefixed lines are unchanged context.
- diff
- The set of line changes between two versions of the code: removed lines start with '-', added lines with '+'.
- green
- A test or check that passes.
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