What teaching can tell us about prompting
By Flavio
Tagged: AI
Clear examples and useful feedback help when teaching a concept or directing a coding agent. Explain the expected behavior and show where the result differs.
When you teach someone to code, the example you pick does most of the work.
If you say “validate the input” to someone who has built plenty of forms, they already have a mental checklist for what counts as valid. A beginner doesn’t. They need to know whether an empty name is fine, whether spaces count, and what should happen when the field is missing.
Coding agents run into the same problem from a different angle. Hand an agent a vague instruction like that and it won’t stop to ask. It’ll just guess and hand back code that looks fine until you test the edge cases. If you want a specific behavior, you still have to answer those questions.
I teach programming, so this overlap caught my attention. Helping a person understand an idea and telling an agent what code to write rely on a lot of the same habits, even if the goals are different and I don’t treat a model like a student.
Explain the distinction the example is meant to teach
Say you’re building a booking form and you tell the agent to “reject dates in the past.” That sounds tiny until you start thinking through what it means. Is today allowed? What if someone tries to book a slot from earlier today? And whose clock are we checking, the customer’s browser or the shop’s?
Instead of trying to explain all that with abstract rules, give one concrete case that settles those questions. Bookings follow the shop’s local time zone: when it’s 14:00 at the shop, a booking for 13:00 today gets rejected, and a booking for 15:00 today goes through. The customer’s browser time zone shouldn’t change either answer.
With those two slots spelled out, the agent has something real to build against. Anyone reading the prompt can also see right away why comparing plain date strings isn’t going to cut it.
The drawing shows the shop’s clock next to the two requested slots, making the cutoff clear before anyone writes a line of code.
Feedback should point to the mismatch
Suppose the agent’s first attempt rejects every booking for today.
Replying with “that’s wrong, try again” doesn’t give it much to work with. Point straight at the case that broke: at 14:00 in the shop’s time zone, a 15:00 slot today should be bookable, and the code rejects it because it’s only comparing calendar dates. That tells the agent both what the result should be and why the current logic missed it.
Then add a second case, like a customer whose browser is set to a different time zone. If you only retest the first example, the next attempt can easily paper over it with a quick special case and keep the real bug intact. Put the failing case and that extra time zone check together like this:
Each example pins down one piece of the rule. Once the first case passes, test the other situations that rule implies so you know the underlying logic holds up.
Give the missing context, then inspect what happens
Writing a longer prompt doesn’t mean you’ve explained more. You can paste in a whole page of general advice about writing clean code and still never mention which time zone the booking form uses. A few concrete sentences will do more than that entire page.
Give the agent the business rule, point it to the existing code that owns that behavior, and tell it how you’re going to verify the result. If you aren’t sure what the rule should be yet, ask the agent to list the options first so you can pick one before it starts writing code.
Agents are also handy for surfacing questions you didn’t realize you had. Ask the agent to read the form and list the assumptions the current code makes, which saves a lot of digging when the logic is spread across several files. Once you have that list, it’s still your call whether those assumptions match how the product is supposed to work.
The goals eventually separate
When I teach a person, the goal is for them to work through the next problem on their own, so I’ll sometimes leave part of an exercise open to give them room to think.
When you’re changing production code with an agent, you’re after something different: working software that behaves the way the product requires. Leave an important business rule unsaid and the agent will fill in the gap with a guess you didn’t want.
Next time you write a prompt, look for one vague phrase that relies on unspoken context. Swap it out for an example of what should happen, plus one case that should give a different result. When the agent finishes, you’ll have something concrete to check right away.
Want me to talk about your product? You can sponsor this site.
Related posts about ai: