AI Interviews · Question

What's your approach to prompt engineering?

Domain deep dive question reported at Sierra, OpenAI, Anthropic (2026). Sources, confidence and an answer card.

Researched · updated

eng-086 AI Engineer Fine-tuning vs RAG vs prompting Domain deep dive Medium confidence
On this page

What they’re really asking

If you only remember one thing, say this in the first minute: “I treat a prompt like code with a test suite. First I read real outputs and write down how they fail. I turn those failures into a test set with a score. Then I change one thing at a time, re-run the tests, and keep the change only if the score really improves. Prompts live in the repo, versioned, and a release is blocked if the score drops. The techniques, like examples of hard cases or a fixed output format, are tools inside that loop, not the answer by themselves.”

The rest of this page explains each part of that answer, so you can say it with understanding.

The interviewer is checking whether “prompt engineering” means a process to you or a bag of clever phrasings.

Here is why it needs a process. A large language model (LLM) reads text and writes text. The prompt is everything you send it with each request: instructions, examples, context and the user’s input. In normal code, you change a line and a unit test tells you whether it still works. With an LLM, two things are different:

  • The output isn’t exact. The same prompt can give a good answer to one input and a subtly wrong answer to a similar one. You can’t judge a change by reading one output.
  • Changes have side effects you can’t see. Adding a rule that fixes one case can quietly break five others.

So a strong answer sounds like software engineering: a test set, error analysis, one change at a time, versioning and a release gate. Techniques come second.

The question sits on a question list tagged Sierra, OpenAI and Anthropic Aced (formerly Exponent)aggregator.

Clarify first

  • “Which task?” Pulling fields out of text, sorting into categories, writing replies, an agent that calls tools? The loop is the same; the checks differ.
  • “Is there a test set?” If not, building one is step one.
  • “Which models?” A prompt doesn’t behave the same on every model, so ask whether there’s a fallback model.
  • “Who decides what good looks like?” A domain expert, rules in code, or another model acting as a judge?

Answer

Words you need first

  • Eval set. Real inputs, each with the right answer or a pass/fail rule. Running the prompt over it gives a score. It is the AI test suite; running it is called “an eval”.
  • Error analysis. Reading real outputs and naming the ways they fail, before writing any checks.
  • Token. Models read and write text in pieces called tokens, roughly ¾ of a word. Providers bill per million.

The loop

  1. Collect real inputs and read the outputs. Look at 20–50 of them. Write down the failure modes and label them. This is the error-analysis step Hamel Husain and Shreya Shankar’s evals FAQ puts first (hamel.dev).
  2. Turn failure modes into checks. Use code where a rule can decide: the output is valid JSON, a required field is present, a citation exists. For judgments code can’t make, use an LLM judge (a second model asked to grade the answer), after checking it agrees with human labels. Keep part of the set held out: you never tune on it, so it tells you whether a gain is real.
  3. Change one thing at a time. Re-run the eval. Keep the change only if the score improves by more than noise.
  4. Version prompts like code. Keep them in the repo and block releases on the eval. Re-run it whenever the model changes.

OpenAI’s optimization guide describes the same order: write evals that set “a baseline”, then iterate on prompts (fetched 2026-10-12).

One example, start to finish

A support team uses an LLM to pull three fields out of customer emails: order number, product and the customer’s request. Follow one round of the loop.

StepWhat happensWhat to say in the interview
Read outputs40 outputs read. Two patterns: it invents an order number when there isn’t one, and it sometimes returns prose instead of JSON.”Two failure modes, each with a name and a count.”
Write checksCode checks that the output parses as JSON. A labelled check asks: if the email has no order number, is the field empty?”One check per failure mode, mostly in code.”
BaselineThe current prompt is scored on the full set and the scores are recorded.”Now every change has something to beat.”
Change 1Add an output schema and validate it in code. Re-run: the JSON failures disappear.”One change, one re-run.”
Change 2Add an explicit rule: “If there is no order number, return null.” Add two hard examples of emails without one. Re-run on the held-out part too.”Examples come from the failures, not from easy cases.”
ReleaseThe new prompt version passes the gate and ships, with its version logged on every production call.”If a customer complains, I know which prompt answered.”

Techniques, and when each one helps

  • A clear structure. Role, task, context, rules, output format, always in the same order. Put the parts that never change first, so the provider’s prompt caching (a discount on a repeated start of a prompt) applies.
  • Examples of the hard cases. Showing worked examples in the prompt is called few-shot prompting. Choose them from failures, not from easy inputs. The applied-LLMs authors list n-shot examples, chain-of-thought (asking the model to reason step by step first) and providing relevant resources as techniques that have “consistently helped” (applied-llms.org, 2024-06-08).
  • Structured output. Give a schema, and validate it in code.
  • Grounding. Give it the facts, allow “I don’t know”, and ask for quotes before answers.
  • Decomposition. Split a task that does three things into steps you can test one by one.

When the eval stops improving, and the remaining failures are about behaviour on a narrow, high-volume task, that is the point to consider fine-tuning (training the model on your own examples). Not before.

Say it like this: “Prompt engineering isn’t clever phrasing. It’s a loop: look at failures, change one thing, re-run the eval, keep it only if the score improves.”

Senior vs Staff

Prompt engineering

Senior

  • Describes an eval-driven loop and the techniques, with an example of a failure that a change fixed.

Staff

  • Treats prompts as versioned artifacts with owners and release gates, plans for model migrations, and sizes the eval to detect the gap that matters.

In plain words: a Senior answer runs the loop well. A Staff answer also runs it as a team process, with owners, release gates and a test set big enough to see the differences that matter.

Small-team version

Build the eval set before the second prompt edit. It is the most valuable thing a small team’s AI owner makes. Keep prompts in the repo, run the eval in CI, and log the prompt version with every production call.

Agents are good at proposing prompt variants and running them against the set. The human keeps the labels and decides what counts as a failure.

If you keep a fallback model from a second provider, for outages, budget for it. Assembled reports that keeping prompts passing their evals on two providers adds 20–30% to prompt development time (Assembled, 2025-06-12).

The eval itself is cheap to run: about $2 a run for 200 cases, or $4 with the fallback model, so run it on every prompt change. The expensive part is labelling the 200 cases, a day or two of a domain expert.

The arithmetic behind the numbers (for a Staff-level follow-up)

Assumed: 200 cases, each 3,000 input and 400 output tokens, on Claude Sonnet 5 at $2 per 1M input and $10 per 1M output tokens (list price, fetched 2026-10-11).

  • Per case: 3,000 × $2 ÷ 1M + 400 × $10 ÷ 1M = $0.006 + $0.004 = $0.010.
  • Per run: 200 × $0.010 = $2; with a fallback model at a similar price, about $4.

Pitfalls

  • Tuning by feel on a handful of inputs. One good output proves nothing about the next fifty.
  • Changing several things at once. You won’t know which change helped and which hurt.
  • Tuning on the test set. The score goes up and the real quality doesn’t; keep a held-out part.
  • Assuming a prompt works the same on another model. Re-run the eval after any model change.
  • Listing tricks without a way to measure them. The interviewer wants the loop, not a list.

Go deeper

Family