Ask for a plan before code
Have the agent explore and propose a plan, listing the files it will touch, its approach and its assumptions, before it edits anything. Correct wrong assumptions at the plan stage, where they are cheap to fix.
Builds on: Why agents fill gaps with plausible guesses
400 lines built on two quick guesses
You ask the agent to "cache product lookups, they're slow". Twenty minutes later it reports success: tests green, 9 files changed, a new third-party caching package and a cache wrapper of its own. Your codebase already has a cache helper, and prices must never be more than a minute stale. You now face 400 lines built on two guesses you would have rejected in seconds.
Early guesses are cheap only while still words
The decisive guesses come first: which helper to use, which files to touch, which constraint applies. With information missing, the agent picks the typical option, states it confidently and builds everything on it. In a diff, a wrong guess is buried and fixing it means redoing the work. In a plan, the same guess is one sentence you can read and correct in seconds, before anything depends on it.
The plan request and how to check it
Ask: *Before editing, read the relevant code. Then propose the files you'll touch and why, your approach, the existing helpers you'll reuse, and your assumptions and open questions. Change no file until I approve.*
Then check:
- each assumption against what you know
- the file list: surprises, or files you know must change but are missing
- new files or packages: did it miss an existing helper?
- correct, then approve
Reading the assumptions line
The agent's plan: *Files: `products/service.py`, `requirements.txt` (add `cachetools`). Approach: LRU cache around `get_product`. Assumptions: no cache exists; entries need no expiry.*
Tells: a new package suggests it never found your helper; "no expiry" contradicts the price rule. Your reply: *Use `app.cache.cached(ttl=60)`; prices may be at most 60 s stale; no new packages.* Two lines now instead of a rewrite later.
What the unchecked guess would have shipped
BAD is what happens when nobody reads the assumptions. It runs, and a test that fetches a product twice goes green. But `LRUCache` drops entries only when it is full; it never expires them. Later cost: a changed price stays invisible until eviction or a restart, and the codebase gains a second caching style plus an extra package. BETTER is the same code after one corrected plan.
// Python
# BAD: built on the unchecked guess
from cachetools import LRUCache, cached
@cached(LRUCache(maxsize=10_000))
def get_product(pid: int) -> Product:
return db.fetch_product(pid)
# BETTER: after one plan correction
from app.cache import cached
@cached(ttl=60)
def get_product(pid: int) -> Product:
return db.fetch_product(pid)
Correct the plan, not the diff
Have the agent explore, then write down files, approach and assumptions before it edits anything. A wrong guess costs one sentence to fix in a plan and a rewrite to fix in a diff, so read the assumptions and the file list first.
On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.