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.
Races introduced by plausible concurrent code card 5 of 6

The Go map written from goroutines

builds on: Race conditions and interleavings
`regionOf(u)` is the slow call; the agent moved the whole loop body into goroutines. The tell: `counts[regionOf(u)]++` now runs in many goroutines with no lock. Go maps are unsafe for concurrent writes, and `++` is a read-modify-write. With 10 test users it often passes. Later cost: under load the runtime can stop with `fatal error: concurrent map writes`, killing the process. `go test -race` flags it even when the timing was harmless, if the test runs this loop with two or more users. BETTER: call `regionOf(u)` outside any lock, then lock a `sync.Mutex` around just the increment.
// Go
--- a/report.go
+++ b/report.go
 counts := map[string]int{}
+var wg sync.WaitGroup
 for _, u := range users {
-  counts[regionOf(u)]++
+  wg.Add(1)
+  go func(u User) {
+    defer wg.Done()
+    counts[regionOf(u)]++
+  }(u)
 }
+wg.Wait()
Terms on this card
sync.Mutex
A Go lock. Code between `Lock()` and `Unlock()` runs in one goroutine at a time, which orders access to shared data.
go test -race
Runs Go tests with the race detector. It reports unsynchronized conflicting memory accesses that occur during that run.
read-modify-write
Reading a value, computing a new one and writing it back. If two runs interleave, one update can overwrite the other.
tell
An observable sign in a diff, transcript or summary that suggests a shortcut or an error.
later cost
The concrete damage a shortcut does after merge, such as a hidden bug, corrupted data or extra maintenance.
Learn this step by step on Bytewise
Lesson goal: Recognise races that look fine on the page: a Go map written from goroutines, unsynchronized lazy initialisation in Java, check-then-act on a cache, and async read-modify-write in JS. Name which tool or synchronization would catch or fix each one. · the whole lesson