esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
  • Download ResumeContact
Let’s talk

I’ll build the agent for it.

What Is Prompt Engineering?

What prompt engineering is, how to write a prompt that works, and where it stops, explained simply for your AI interview.

In short

Prompt engineering is writing and testing the instructions, context and examples a model gets, so its answers are right and consistent. It is often the first fix to try, but some problems need different data or a different model instead.

11 min readBeginnerVery common · estimateFacts checked 26 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

Prompt engineering is writing the instructions, context and examples a model needs to give the answer I want. I write the rules as short lines, set the output format, and add a few real examples. Then I test the prompt on past cases where I already know the right answer, change one thing at a time, and test again. It is often the first fix to try, because a prompt edit costs little. When the test still fails, the problem may be the data or the model instead.

What is prompt engineering, in plain words?

A model reads one block of text and writes text back. That block is the prompt: your instructions, the background the model needs, a few examples and the question itself. Prompt engineering is deciding what goes in that block, then testing and improving it until the answers are right.

  • “Prompt engineering is the process of writing effective instructions for a model, such that it consistently generates content that meets your requirements.”

    OpenAI

  • “Prompt engineering is the art and science of designing and optimizing prompts to guide AI models, particularly LLMs, towards generating the desired responses.”

    Google Cloud

Think of a new claims handler on their first morning. Hand them a vague brief and you get vague work. Give them the policy, the claim form, two solved cases and a clear format for the reply, and their work starts to look the same from one file to the next. A claims team sorting 2,000 motor claims a week needs exactly that kind of consistency from its AI.

Key words

Prompt
Everything sent to the model in one call, such as the instructions, the examples and the question.
System prompt
The developer's standing instructions, usually hidden from the end user.
Few-shot example
A solved case shown in the prompt, so the model copies its shape.
Test set
Past cases where you already know the right answer.
Output format
The shape of the reply, such as JSON, that code can read.

How do you write a prompt that works?

Start with five parts: the job and the reader, short rules, the context the model cannot know, the output format, and a few examples that look like the real work.

  1. 1

    Name the job and the reader

    Say who the output is for and exactly what it must do. Vague jobs get vague work.

  2. 2

    Write the rules as short lines

    One rule per line, such as the allowed labels and what to do when a detail is missing.

  3. 3

    Give the context

    Paste in the policy or fee table the answer depends on. The model can't know your rules unless they are in the prompt.

  4. 4

    Set the output format

    Ask for JSON or a fixed template, and say so plainly. Anthropic's guide asks for this too.

  5. 5

    Add three to five examples

    Anthropic's guide says a few well-crafted examples improve accuracy and consistency, and it suggests 3-5 for best results.

  6. 6

    Test before you trust it

    Run the same test cases after every change, and score them. Anthropic's guide also asks for a clear definition of success first.

The prompt test loop

Write a draft prompt

rules, context, output format

Run the test cases

same cases every time

Score the answers

right, wrong or unsure

Good enough? Ship it

keep the test set for later

Change one thing

one rule or one example

  1. 1Run the draft on the same test cases.
  2. 2Mark each answer right, wrong or unsure.
  3. 3Take the misses and change one thing that caused them.
  4. 4Run the same test cases again.
  5. 5When the scores reach your target, ship it and keep the test set.
The draft goes through the same test cases each time, and every change is judged by the same score. Stop when the scores reach the target you set in advance, or when the test shows the prompt alone can't get there. Keep the test set for the next change.

Here is a small triage prompt built from those parts, for a motor insurer. No model is called, so the code gives the same result every time. The check function matters most: the prompt asks for JSON, and the code confirms the reply really is JSON with a known label.

Python
# A claims team's triage prompt, built from parts. No model is called here:
# the reply format is checked in code, because a prompt alone can't promise it.
import json
RULES = [
    "Sort each claim into FAST_TRACK, MANUAL_REVIEW or FRAUD_CHECK.",
    "Use FRAUD_CHECK when the photos and the date of loss disagree.",
    "Never approve a payout. Only sort the claim.",
]
EXAMPLE_CLAIM = "Rear bumper dent, 2 photos, police report attached."
EXAMPLE_REPLY = '{"route": "FAST_TRACK", "reason": "Clear damage, report on file"}'
ROUTES = ("FAST_TRACK", "MANUAL_REVIEW", "FRAUD_CHECK")
def build_prompt(claim):
    lines = ["You are a claims triage assistant at a motor insurer."]
    lines += ["Rules:"] + ["- " + rule for rule in RULES]
    lines += ["Example claim: " + EXAMPLE_CLAIM, "Example reply: " + EXAMPLE_REPLY]
    lines += ["Claim: " + claim, "Reply with JSON only."]
    return "\n".join(lines)
def check_reply(reply):
    try:
        data = json.loads(reply)
    except json.JSONDecodeError:
        return "REJECTED: not JSON, ask again"
    if not isinstance(data, dict) or data.get("route") not in ROUTES:
        return "REJECTED: unknown route"
    return "OK: " + data["route"]
prompt =build_prompt("Tree fell on the car on Sunday. Photos show roof dents.")
print(len(prompt.splitlines()), "lines in the prompt")
print(prompt.splitlines()[-1])
for reply in ['{"route": "FAST_TRACK", "reason": "Clear"}', "Sure! It is fast track.", '{"route": "PAY_NOW"}']:
    print(check_reply(reply))

Output

9 lines in the prompt
Reply with JSON only.
OK: FAST_TRACK
REJECTED: not JSON, ask again
REJECTED: unknown route

Where does prompt engineering stop?

Prompt engineering is often the first fix to try, and it has a limit. Anthropic's guide says: "Not every success criterion or failing eval is best solved by prompt engineering." Some problems need different data, a different model or a change to the process.

  • Try first

    Change the prompt

    Quick to try, and cheap to run. Good for format, tone and rules the model already follows well.

  • Then

    Change the model

    Sometimes a different model improves speed and cost more easily than rewording the prompt. Measure it on the same test set.

  • Also

    Give it the data

    If the answer depends on this month's fee table, the table has to reach the model. A prompt can't know it.

What to change when a prompt fails

Wrong or unsteady answers

same question, different answers

Try first, cheap

Sharper prompt

clear rules and output format

Add examples

show the shape you want

Try next, if still wrong

A different model

may be faster or cheaper

Give it the data

the policy or table it must use

Right on the test set

measured, not guessed

  1. 1Start with the words and examples, the usual first fix.
  2. 2Still wrong? Give it the data, or measure another model.
  3. 3Re-run the same test cases and keep what passes.
Start with cheap changes to the words and examples. If the answers stay wrong, give the model the data it needs, or measure a different model on the same test cases. Either way, prove the fix on the same test cases.

How would you fix a bot that is wrong one time in five?

A bank's support assistant answers questions about card fees. In about one reply in five it quotes an old fee table. Customers ask things like "What is the fee for a late card payment?", and the complaints team wants it fixed this week.

  1. 1

    Build the test set

    Collect 60 real past questions with the answers the fee team approved. Keep them apart from the prompt.

  2. 2

    Score the current prompt

    Mark each reply right, wrong or unsure. Count them before you change anything.

  3. 3

    Read the wrong ones

    Look for a pattern. Here, most wrong replies quote the old fee table.

  4. 4

    Change one thing

    Add a rule: quote fees only from the table in the prompt, and say so when the table has no answer.

  5. 5

    Re-run everything

    Run all 60 again. If another question breaks, the fix made things worse.

  6. 6

    Check the data

    If the table itself is out of date, fix the table. No prompt can make stale facts current.

Tip

Name the trade-off in the interview. A strict rule makes the bot say it doesn't know more often, which is fine for fee questions and risky for loan advice.

What does the interviewer want to hear?

A strong answer covers

  • A plain definition: writing and testing the instructions a model gets.
  • The parts of a good prompt: job, rules, context, format and examples.
  • Testing: the same cases, scored after every change.
  • Limits: when to change the model, the data or the process instead.
  • One real example from work, with the failure and the fix.

Common traps

  • Trap"Prompt engineering is just finding the right magic words."

    BetterIt is writing, testing and measuring instructions on known cases. The test decides when you're done.

  • Trap"If the answer is wrong, add more rules."

    BetterFirst check whether the prompt is the problem at all. Stale data and a weak model need different fixes.

  • Trap"A longer prompt is always safer."

    BetterLong prompts cost more and can bury the rule that matters. Keep what the test shows helps, and cut the rest.

Can you spot the weak prompt?

Spot the prompt that gives consistent answers

Which prompt is most likely to give the same kind of answer every time, across 2,000 claims a week?

Quick check

A prompt gets 30 of 50 past claims right. What do you do next?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q077Zero-shot vs few-shot prompting?12 min
  2. Q080What goes in a system prompt?11 min
  3. Q081What makes a good prompt?13 min
  4. Q078What is chain-of-thought, and when does it help?10 min
  5. Q087Why template and version your prompts?11 min

Learn it in depth

Last updated on 26 November 2026

Building an assistant that must give the same answer twice?

I design and build AI products and agents, including the prompts, tests and interface behind them. Book a short call and tell me what your assistant needs to do.