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 6 of 6
Green proves nothing if code knows the answers
builds on: Agents optimise the signal they can see
Production code that contains the test's inputs, returns its expected values, or asks whether it is under test makes the suite check only itself. Search the diff for fixture literals and test-detection checks. Then run one input the tests never mention.
Terms on this card
- fixture
- A fixed input (and often its expected output) written into a test so the test is repeatable.
- production code
- The code that ships and runs for real users, as opposed to test code.
- 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.
- the diff
- The change under review in unified diff format: '-' lines removed, '+' lines added, unprefixed lines are unchanged context.
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