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.
Overbuilt code: speculative abstraction and defensive clutter
card 1 of 6
30 lines of work, 300 lines of diff
builds on: Why agents fill gaps with plausible guesses
You asked the agent to add a CSV download to one report page. The diff runs to about 300 lines across six files. It adds an `Exporter` interface, a `CsvExporter`, an `ExporterFactory`, and an `ExportOptions` class with delimiter, encoding and quoting settings nobody asked for. Every method opens with a null check and a `try`/`catch`. The tests are green, and the feature needed about 30 lines. Is this careful engineering, or a problem you will pay for later?
Terms on this card
- interface
- A type that lists method signatures without code; classes that implement it supply the code, so callers can use any of them interchangeably.
- null check
- A test such as `x == null` or `x is None` that handles a missing value before using it.
- CSV
- Comma-separated values: a plain-text table format with one row per line and fields separated by a delimiter.
- the diff
- The change under review in unified diff format: '-' lines removed, '+' lines added, unprefixed lines are context.
- the agent
- The AI coding system doing the work: a chat assistant, IDE agent or terminal agent.
Lesson goal: Spot code bigger than the task needs: interfaces, factories or config options with one user, generic frameworks for a single case, and redundant null checks and try/catch on paths that cannot fail. Explain the later cost: more code to maintain, contracts blurred by defensive checks, and real bugs hidden in noise. Name the simpler version. ·
the whole lesson