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.
What makes a test able to fail
card 5 of 6
An expected value pasted from a run
The agent tests `parseDuration`. Its transcript shows it ran `node -e` on `parseDuration('1h30m')`, which printed `3630`. The test it then wrote is `expect(parseDuration('1h30m')).toBe(3630)`.
**Tell:** the expected value came from running the code itself. By the spec, 1h30m is 5400 seconds; the code reads the minutes as seconds.
**Good version:** `toBe(5400)`, worked out from the spec. It goes red and reveals the bug. Ask the agent where each expected value came from.
Terms on this card
- spec
- Specification: the stated requirements for what the code should do, e.g. a ticket, design doc or agreed rules.
- tell
- An observable sign in a diff, transcript or summary that suggests a shortcut or an error.
- red
- A test or check that fails.
- transcript
- The record of what the agent did in a session: the commands it ran, their output and its messages.
- toBe
- Jest/Vitest assertion in TypeScript/JavaScript that passes if the actual value is identical (===) to the expected one.
Lesson goal: Explain a test as inputs plus an oracle, the expected result. The oracle must come from the specification rather than from the code under test. A test that cannot go red when the code is wrong proves nothing. ·
the whole lesson