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 1 of 6
Tidy diff, green tests, a broken caller
builds on: What the agent cannot see
You asked the agent to tidy `billing.py`: shorter functions, modern idioms. The diff reads well, tests are green, and the summary says "pure refactor, no behaviour change". You approve it. A week later, a payment path in another service starts failing, and nobody touched that service. The cleanup changed something a caller relied on. How could you have seen it in the diff before merging?
Terms on this card
- refactor
- A change to how code is written that is meant to leave its observable behaviour exactly the same.
- caller
- Any code that calls the function being changed. It may live in files the agent never opened.
- the diff
- The change under review in unified diff format: '-' lines removed, '+' lines added, unprefixed lines are unchanged context.
- 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: 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