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.
Choose what to hand to an agent
card 5 of 6
The rename hides an irreversible part
builds on: What the agent cannot see, Agents optimise the signal they can see
Renaming the field across 40 files is good agent work. The type checker and tests catch most missed spots, and a search for the old name finds the ones in SQL strings and templates. As long as the name isn't part of a released interface, a revert undoes it.
This Alembic migration is different. `drop_column` deletes every stored email. Tests run on a fresh, empty database, so they stay green. The `downgrade` looks like an undo, but it only restores an empty column.
**Later cost:** permanent data loss. Keep this part yourself: use `op.alter_column(..., new_column_name=...)` and try it on a copy of real data.
// Python
+++ b/migrations/0042_contact_email.py
+def upgrade():
+ op.drop_column("users", "email")
+ op.add_column("users", sa.Column(
+ "contact_email", sa.String(255)))
+
+def downgrade():
+ op.drop_column("users", "contact_email")
+ op.add_column("users", sa.Column(
+ "email", sa.String(255)))
Terms on this card
- later cost
- The concrete damage a shortcut does after merge, such as a hidden bug, lost data or extra maintenance.
- migration
- A versioned script that changes a database's structure or data, run once per environment, usually with an upgrade and a downgrade step.
- Alembic
- A Python tool for database migrations; `op.drop_column`, `op.add_column` and `op.alter_column` are its schema-changing operations.
- type checker
- A tool or compiler pass that checks types without running the code, catching mismatches such as a renamed field still used under its old name.
- SQL
- Structured Query Language, the language used to query relational databases.
Lesson goal: Judge how well a task fits an agent on four axes: how cheaply the result can be verified, how much unwritten context it needs, how reversible it is and how security-critical it is. Delegate well-specified, checkable, local work. Keep, pair on or split ambiguous, cross-cutting or high-stakes changes. ·
the whole lesson