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.
Verify an agent change instead of trusting it
card 5 of 6
The test that could not fail vs. one that can
builds on: Mocks that test nothing, Tests that restate the implementation, See it fail: red before green and break-it checks, Pin behavior before a refactor, Let the toolchain check first
BAD is the agent's test. BETTER is the one you asked for. Both expect 90. That value comes from the spec ("10% off, once"), not from the code's own formula. The difference is the second call. Only BETTER repeats the action that triggered the bug, so only BETTER turns red when the guard is missing.
// Python
# BAD
def test_coupon():
o = Order(total=100)
apply_coupon(o, "TEN")
assert o.total == 90
# BETTER
def test_coupon_applies_once():
o = Order(total=100)
apply_coupon(o, "TEN")
apply_coupon(o, "TEN")
assert o.total == 90
Terms on this card
- spec
- Specification: the stated required behaviour, independent of how the code computes it.
- guard
- A check at the start of a code path that stops or skips the work when a condition holds, e.g. 'coupon already used'.
- the agent
- The AI coding system doing the work: a chat assistant, IDE agent or terminal agent.
- red
- A test or check that is failing. Green means passing.
Lesson goal: For a given change, build a short verification plan: reproduce the problem, see the tests fail and then pass, judge whether the tests could catch a real bug, pin behaviour before refactors and run the toolchain checks. Explain what evidence each step gives you. ·
the whole lesson