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.
Scope creep and unasked-for changes in a diff
card 5 of 6
Find the fix in this diff
builds on: You own every line the agent writes
Only the `start` line fixes the bug. The rest are tells:
- **Import spacing**: noise that hides the fix and credits the line to this commit in blame history.
- **Rename of `get_page` to `paginate`, and `n` to `page`**: no caller is updated here, so every call to `get_page` fails. Even a caller switched to `paginate` fails if it passes `n=` as a keyword argument. Python only finds out at runtime.
- **Pin `==2.28.2` loosened to `>=2.31`**: every fresh install now gets the newest `requests`, never the tested 2.28.2.
Reverting this commit would also undo all of it.
// Python
--- a/api/pages.py
+++ b/api/pages.py
-from utils import clamp,fetch
+from utils import clamp, fetch
-def get_page(rows, n, size):
- start = n * size
+def paginate(rows, page, size):
+ start = (page - 1) * size
return rows[start:start + size]
--- a/requirements.txt
+++ b/requirements.txt
-requests==2.28.2
+requests>=2.31
Terms on this card
- blame history
- What `git blame` shows: which commit last changed each line. Reformatting makes unrelated lines point at the reformatting commit instead of the one that wrote the logic.
- keyword argument
- A Python argument passed by name, like `f(n=2)`. Renaming the parameter breaks such calls with a TypeError at runtime.
- diff
- The set of line changes between two versions of the code: removed lines start with '-', added lines with '+'.
- commit
- Making database writes permanent. Once committed, a write stays even if later steps fail.
- caller
- Any place in code that invokes a function or uses a name, sometimes called a call site.
Lesson goal: Recognise drive-by reformatting, renames, refactors, new abstractions, config tweaks and dependency bumps mixed into the requested change. Explain how they hide the real change, raise risk and make review and revert harder. ·
the whole lesson