IA Dev Learn

Writing prompts that work

An agent never says it doesn't know. Whatever your prompt leaves out, it guesses.

Six things to say

IngredientThe question it answersExample
GoalWhat should change?Add a discount function
ContextWhere?in @src/cart.ts
DetailsHow exactly?applyDiscount(totalCents, percent), 20 means 20% off
ConstraintsWhat must not happen?never below 0, don't change total()
VerifyHow do we check it?add tests and run them
Done whenWhat does finished look like?it returns whole cents

You rarely need all six in one sentence. Your rules file can carry the permanent ones (how to run tests, which package manager), and a skill can carry the format of a recurring task.

The same request, twice

The agent searched the whole project, created src/discount.js (JavaScript, in a TypeScript project), hard-coded 10% off and wrote no test.

text
Add applyDiscount(totalCents, percent) to @src/cart.ts: 20 means 20% off,
never below 0. Add tests and run them.

Right file, right rule, two tests, and the agent ran them.

Habits that pay off

  • Point at files with @path instead of describing them.
  • Show the exact output you want in quotes: "12,50 €" leaves nothing to interpret.
  • Say what to keep: "keep the name formatPrice" prevents a rename that breaks every import.
  • One task per prompt. Two unrelated changes in one request are harder to review.
  • If the result is off, say what's wrong and why, rather than repeating the prompt louder.
  • Ask questions too. "What does total() do?" changes nothing and costs little.