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.
See it fail: red before green and break-it checks
card 5 of 6
Break-it check in Go
builds on: What makes a test able to fail
The agent added `func IsAdult(age int) bool { return age >= 18 }`, with tests for ages 30 and 10. All green.
Break it on purpose: change `>=` to `>` and run `go test ./...`. Still `ok`. No test sits at 18, so an off-by-one there would ship. Add the case `IsAdult(18) == true`, taken from the spec, and rerun the broken version: red. Revert the break: green. Keep the new case.
Terms on this card
- break-it check
- A manual, one-off mutation: break the code in one small way, run the tests, expect red, then revert.
- off-by-one
- A bug where a limit is wrong by exactly one, such as using `>` where `>=` was meant.
- spec
- Specification: the stated required behaviour, independent of how the code happens to implement it.
- go test ./...
- Runs the tests in every package under the current directory of a Go module.
- go test
- The Go command that builds packages and runs their tests; './...' means the package and all below it.
Lesson goal: Confirm a new test is red without the fix and green with it. Temporarily break the code to check that the suite catches the break, which is the core idea of mutation testing. ·
the whole lesson