Give the context it can't find
Point the agent at the relevant files, existing helpers, examples to imitate, conventions, library versions and the commands for building and testing, and keep durable rules in a project instruction file. Explain which blind spot each piece of context closes.
Builds on: What the agent cannot see
It works, but it isn't how we do it
You asked the agent to "add a CSV export for orders". It came back working, but it wrote a new date parser even though `app/utils/dates.py` has one. It used `requests` where the team uses `httpx`. The layout matches no other report module. It said "tests pass" after running one file with plain `pytest`, while CI runs `make check`. Nothing is broken today. What was the agent missing?
It can only reuse what is in its context
A helper the agent never opened doesn't exist for it, so it writes another. A convention nobody wrote down gets replaced by the most common pattern in public code. If it doesn't know your library versions, it writes for the version it has seen most. If it doesn't know your test commands, it guesses. You can close each gap with one line. Left open, the later cost is two parsers that drift apart, mixed styles, and checks that never ran.
Six pieces of context and the gap each closes
- **Relevant files** (paths): files it would never open.
- **Helpers to reuse**: name and path, or it writes a new one.
- **An example to imitate**: one file carries layout, naming and error style.
- **Conventions, with the why**: team decisions the code doesn't show. The reason lets it handle cases you didn't list.
- **Library versions**: from the lockfile, so its calls exist in yours.
- **Build/test/lint commands**: so it checks itself the way CI does.
Rules true for every task go in the project instruction file. The rest go in the task.
The same task, with the gaps closed
Task: "Add CSV export in `app/reports/orders.py`, structured like `app/reports/invoices.py`. Parse dates with `parse_day` from `app/utils/dates.py`."
Project instruction file, written once: "HTTP goes through `app/http.py` (httpx, shared timeouts and retries). Versions: see `poetry.lock`. Before saying done, run `make check` (lint, types, all tests)."
Now the export, the parser and the check match yours. Every later task inherits the rules for free.
What the first prompt produced
The tell is a fresh private helper for a job the codebase already has a helper for. Slicing `s[:10]` keeps the local date as written and drops the UTC offset. The other reports use `parse_day`, which converts to UTC first. So an order created at `2024-03-01T23:30-05:00` lands on 1 March here, but on 2 March (04:30 UTC) in every other report. That is the later cost: two parsers that disagree on the same data. One line naming `parse_day` in the task would have prevented it.
// Python
--- a/app/reports/orders.py
+++ b/app/reports/orders.py
@@ -1,2 +1,9 @@
+from datetime import datetime
+
+def _to_day(s):
+ return datetime.strptime(
+ s[:10], "%Y-%m-%d").date()
+
def export_orders(rows):
- raise NotImplementedError
+ return [(r["id"], _to_day(r["created"]))
+ for r in rows]
Hand over what it can't find
Each gap in the agent's context has a cheap fix: a path, a helper name, a file to copy, a version, a command. Put rules that hold for every task in the project instruction file, so you write them once and every task inherits them.
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.