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.
Leaked resources: files, connections, goroutines card 2 of 6

Why leaks pass every test

builds on: Error handling idioms across languages
Tests are short. They make a few calls, then the process exits and the OS reclaims every file and socket, so a leak keeps the proxy signal green. The agent writes the shortest code that works on the path it tried, and a `close()` on the success line looks finished. Leaks hide on error paths and early returns, and they only add up after thousands of calls. **Later cost:** exhausted file descriptors, a drained connection pool, locks held forever, and goroutine memory that keeps climbing.
Terms on this card
OS
Operating system. It hands out files, sockets and memory, and it reclaims all of them when a process exits.
socket
The OS object behind a network connection, such as an HTTP or database connection. Each open socket uses one file descriptor.
connection pool
A fixed set of reusable database connections. Code borrows one and must return it; connections that are never returned shrink the pool until callers wait or fail.
goroutine
A lightweight concurrent function in Go, started with `go f()`. It lives until its function returns; a goroutine blocked forever is never freed.
proxy signal
A visible stand-in for the real goal, such as green tests, that can be satisfied without achieving the goal.
Learn this step by step on Bytewise
Lesson goal: Spot files, connections and locks opened without `with`, try-with-resources or `defer`, as well as `defer` inside loops, goroutines blocked forever and contexts never cancelled. Explain why these pass tests but exhaust resources in production. · the whole lesson