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.
Happy-path code: the edge cases it skipped
card 4 of 6
Predict before you run it
builds on: Why agents fill gaps with plausible guesses
These are the agent's two helpers. Before you read on, predict which call crashes and which one silently returns the wrong data. Read the docstring and the `start` line together.
// Python
def avg_stars(reviews):
total = sum(r["stars"] for r in reviews)
return round(total / len(reviews), 1)
def page(reviews, page_no, size=20):
"""Pages start at 1."""
start = page_no * size
return reviews[start:start + size]
Terms on this card
- docstring
- In Python, a string literal placed first in a function body that documents what the function does or expects.
- the agent
- The AI coding system doing the work: a chat assistant, IDE agent or terminal agent.
Lesson goal: Probe agent code for the structural inputs it typically ignores: empty collections, None/null/nil and missing keys, zero and negative values, and off-by-one boundaries on ranges, slices and pagination. Predict which of these a given function will mishandle, and write the one test that would show it. ·
the whole lesson