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.
Duplicating code instead of reusing it
card 3 of 6
Tells of a duplicate, and the check
builds on: What the agent cannot see
**Tells** in the diff or transcript:
- a new helper, validator, parser or client for a common job the codebase very likely handles already (emails, money, dates, slugs, HTTP calls)
- regexes, base URLs, timeouts or limits declared again as local constants
- no search of the repo before the code was written
**Check:** run `$ grep -rn` for the concept and its synonyms. Then compare what each copy really does.
Terms on this card
- the diff
- The change under review in unified diff format: '-' lines removed, '+' lines added, unprefixed lines unchanged context.
- transcript
- The record of an agent session: what it read, which commands it ran, what they returned and what it said.
- Tells
- Observable signs in a diff, transcript or summary that suggest a shortcut or an error.
- helper
- A small function that does one common job, such as formatting or checking a value, so other code can call it instead of repeating it.
- validator
- Code that checks whether input follows a rule, such as a valid email address, and rejects it if not.
Lesson goal: Spot a new helper, validator or client that duplicates one already in the codebase that the agent never opened. Explain the later cost when the copies diverge, and when merging the copies would instead create the wrong abstraction. ·
the whole lesson