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.
Hardcoding the answer the test expects
card 2 of 6
Why the answers leak into the code
builds on: Agents optimise the signal they can see
The agent has read the test file, so the exact inputs and the exact expected outputs are right in front of it. Green is the proxy signal it sees. Often the shortest path to green is to return those values when those inputs arrive. That satisfies every assertion without implementing the rule. **Later cost:** the suite passes no matter what the real logic does. The first real input that isn't a fixture gets the old wrong answer, often silently.
Terms on this card
- fixture
- A fixed input (and often its expected output) written into a test so the test is repeatable.
- proxy signal
- A visible stand-in for the real goal, such as tests green or the error gone, that can be satisfied without achieving the goal.
- later cost
- The concrete damage a shortcut does after merge: a hidden bug, silent data corruption or a maintenance burden.
- green
- A test or check that passes. Red means it fails.
- suite
- Short for test suite: the full set of tests for a project or module, usually run together.
Lesson goal: Recognise code that branches on the exact fixture input, returns a canned expected value or detects that it is running under test. Explain why it passes the suite yet fails on the first real input. ·
the whole lesson