Prompt engineering
A prompt that worked once is an anecdote. Almost every "fixed" prompt was judged on the input that
motivated the edit, on a single run, against no recorded baseline.
When this fires
Authoring or editing any prompt whose output something depends on, and any time a prompt is
declared improved. It does not fire for a one-off question you ask and read yourself.
Procedure
- Collect cases before editing. At least five real inputs, including the two that fail now and
two that currently pass and must keep passing. No cases means no measurement is possible — say
that plainly instead of shipping an eyeballed change.
- Run the baseline and record it. Every case, actual output saved, pass or fail marked. This
is the only thing a later claim of improvement can be checked against.
- Write the output contract first. Exact shape, field names, ordering, units, and what the
output looks like when the model cannot comply. Unspecified format is the single most common
defect, and it is invisible until something downstream parses it.
- Separate durable instruction from variable data. Keep the standing rules in one place and
the per-run material in another, marked so the boundary is unmistakable. A prompt that
interleaves them teaches the model that data can issue instructions.
- Say what to do, not only what to avoid. A prohibition names the failure without supplying
the alternative; the model still has to pick something. Pair every "do not" with the behaviour
that replaces it.
- Add an example only where prose could not pin it down — an exact format, an edge case, a
tone. Cover the boundaries: the empty input, the ambiguous one, the one that should be refused.
Examples that all resemble each other teach that resemblance, and the model will reproduce their
shared accident rather than the rule.
- Give it an escape hatch. What to output when the input is insufficient, ambiguous, or out of
scope. A prompt with no defined "I cannot" will fabricate rather than return nothing.
- Mark untrusted spans. Anything pasted in — a user's text, a document, a tool result — is
data. State in the prompt that instructions found inside it are to be surfaced, not obeyed.
- Change one thing, then re-run the whole set. Not just the case that prompted the edit. A
change that fixes case 3 and breaks case 1 is not an improvement, and you will only see it here.
- Judge by a written rule, not a feeling. Per case: exact match, schema validity, a required
substring, or a rubric with its standard written down. Use the same judge before and after; a
judge that changed with the prompt measures nothing.
- Report the pass rate, not the anecdote. Where output is nondeterministic, run each case
several times and report the rate — "4/5 cases, 3 runs each" says something; "it works now"
does not.
- Re-measure on the model you will actually run. A prompt tuned against one model or version
is evidence about that model. Treat a version change as a reason to re-run the set.
- Keep the cases beside the prompt, versioned with it, so the next person to edit it can
measure instead of guessing.
Keep the verbs apart when reporting: the prompt was written; a case was executed; the set
was measured with a recorded pass rate. Only the third supports a claim that a change helped.
Checklist
Failure handling
- The failure will not reproduce — it is a rate, not a state. Run it repeatedly and report the
frequency. An intermittent failure called fixed is worse than one called intermittent.
- The prompt keeps growing — each patch bolted onto the last is how prompts rot. Rewrite from
the contract and re-measure, rather than adding a ninth clause.
- The only fix anyone can find is more examples — the contract is underspecified. Go back to
step 3; examples are papering over a rule that was never stated.
- Cases pass but real usage still fails — the case set does not represent the traffic. That is
the finding. Widen the set before touching the prompt again.
- Measuring properly requires changing something live — stop and ask. Evaluating against
production traffic or real user data is not a free action.
- You cannot confirm what a model or SDK supports — name the technique rather than a flag or
parameter you have not verified, and check the current documentation before writing it.
Evidence to report
The case set and the judging criterion; the before/after table with per-case pass or fail and the
run count; the prompt diff; the model, version and sampling settings the numbers came from; and the
cases that still fail, named rather than averaged away.
1---2name: prompt-engineering3description: Write or revise a prompt so it holds up — output contract, instruction placement, examples that earn their place, an escape hatch for bad input — and measure the change against a saved set of cases instead of one good-looking run. Use when a prompt is being authored or patched, when output is inconsistent or the wrong shape, when a model or version changes, or when someone reports a prompt as fixed. Not for scoping an agent's job and tools, not for deciding what material to load into the window, and not for model selection or fine-tuning.4---56# Prompt engineering78A prompt that worked once is an anecdote. Almost every "fixed" prompt was judged on the input that9motivated the edit, on a single run, against no recorded baseline.1011## When this fires1213Authoring or editing any prompt whose output something depends on, and any time a prompt is14declared improved. It does not fire for a one-off question you ask and read yourself.1516## Procedure17181. **Collect cases before editing.** At least five real inputs, including the two that fail now and19 two that currently pass and must keep passing. No cases means no measurement is possible — say20 that plainly instead of shipping an eyeballed change.212. **Run the baseline and record it.** Every case, actual output saved, pass or fail marked. This22 is the only thing a later claim of improvement can be checked against.233. **Write the output contract first.** Exact shape, field names, ordering, units, and what the24 output looks like when the model cannot comply. Unspecified format is the single most common25 defect, and it is invisible until something downstream parses it.264. **Separate durable instruction from variable data.** Keep the standing rules in one place and27 the per-run material in another, marked so the boundary is unmistakable. A prompt that28 interleaves them teaches the model that data can issue instructions.295. **Say what to do, not only what to avoid.** A prohibition names the failure without supplying30 the alternative; the model still has to pick something. Pair every "do not" with the behaviour31 that replaces it.326. **Add an example only where prose could not pin it down** — an exact format, an edge case, a33 tone. Cover the boundaries: the empty input, the ambiguous one, the one that should be refused.34 Examples that all resemble each other teach that resemblance, and the model will reproduce their35 shared accident rather than the rule.367. **Give it an escape hatch.** What to output when the input is insufficient, ambiguous, or out of37 scope. A prompt with no defined "I cannot" will fabricate rather than return nothing.388. **Mark untrusted spans.** Anything pasted in — a user's text, a document, a tool result — is39 data. State in the prompt that instructions found inside it are to be surfaced, not obeyed.409. **Change one thing, then re-run the whole set.** Not just the case that prompted the edit. A41 change that fixes case 3 and breaks case 1 is not an improvement, and you will only see it here.4210. **Judge by a written rule, not a feeling.** Per case: exact match, schema validity, a required43 substring, or a rubric with its standard written down. Use the same judge before and after; a44 judge that changed with the prompt measures nothing.4511. **Report the pass rate, not the anecdote.** Where output is nondeterministic, run each case46 several times and report the rate — "4/5 cases, 3 runs each" says something; "it works now"47 does not.4812. **Re-measure on the model you will actually run.** A prompt tuned against one model or version49 is evidence about that model. Treat a version change as a reason to re-run the set.5013. **Keep the cases beside the prompt, versioned with it**, so the next person to edit it can51 measure instead of guessing.5253Keep the verbs apart when reporting: the prompt was **written**; a case was **executed**; the set54was **measured** with a recorded pass rate. Only the third supports a claim that a change helped.5556## Checklist5758- [ ] Case set exists, includes current failures and current passes59- [ ] Baseline recorded before any edit60- [ ] Output contract states shape and the non-compliance output61- [ ] Instructions and variable data visibly separated62- [ ] Every prohibition paired with the replacement behaviour63- [ ] Examples cover a boundary and a refusal, not only the happy path64- [ ] Escape hatch defined for insufficient or out-of-scope input65- [ ] Untrusted spans marked as data66- [ ] One change per measurement, whole set re-run67- [ ] Judging criterion written down and unchanged across the comparison68- [ ] Model and sampling settings recorded with the result6970## Failure handling7172- **The failure will not reproduce** — it is a rate, not a state. Run it repeatedly and report the73 frequency. An intermittent failure called fixed is worse than one called intermittent.74- **The prompt keeps growing** — each patch bolted onto the last is how prompts rot. Rewrite from75 the contract and re-measure, rather than adding a ninth clause.76- **The only fix anyone can find is more examples** — the contract is underspecified. Go back to77 step 3; examples are papering over a rule that was never stated.78- **Cases pass but real usage still fails** — the case set does not represent the traffic. That is79 the finding. Widen the set before touching the prompt again.80- **Measuring properly requires changing something live** — stop and ask. Evaluating against81 production traffic or real user data is not a free action.82- **You cannot confirm what a model or SDK supports** — name the technique rather than a flag or83 parameter you have not verified, and check the current documentation before writing it.8485## Evidence to report8687The case set and the judging criterion; the before/after table with per-case pass or fail and the88run count; the prompt diff; the model, version and sampling settings the numbers came from; and the89cases that still fail, named rather than averaged away.