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 Makes a Good Prompt?

What a good prompt contains, how to test it on real cases, and where prompts stop working, explained simply for your AI interview.

In short

A good prompt says the job, gives the background the model lacks, sets the rules and the output shape, and shows a few examples. Then you test it on real cases, because a prompt is good only when its answers hold up.

13 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.

A good prompt tells the model the job, the background it can't know, the rules, and the shape of the answer. I add a few realistic examples, and I wrap each part in its own tag so the model can tell rules from customer data. The step people skip is the test. I run the prompt on real past cases with known answers, check each reply against the rules, and fix what breaks. A prompt that reads well but fails on real cases isn't finished.

What is a good prompt, in plain words?

A prompt is everything you send a model in one go: the job, the background, the rules, the examples and the message to answer. The model here is a large language model (LLM), the AI that writes the reply. Google Cloud's guide puts the craft this way: "Prompt engineering is the art and science of designing and optimizing prompts to guide AI models, particularly LLMs, towards generating the desired responses."

Picture a handover note on a hospital ward. A nurse covering a shift who has never worked the ward can do a safe shift only if the note says which patients to watch, which drugs are on hold and what counts as urgent. The model is that nurse. It can only work from what it is given, so a good prompt is a good note.

A bank's complaints assistant needs the same note: the fee rules, the tone to use and the one thing it must never do, plus the customer's message. Without the fee rules it will guess, and a guess can sound confident.

Key words

Prompt
Everything sent to the model for one answer: instructions, background and the message.
Context
Background the model can't know, like a policy text or a customer's history.
Output format
The shape you want back, such as a short reply, a list or a JSON object (a structured record with named fields).
Few-shot example
A worked case the model copies in style and shape.
Eval
Short for evaluation: a test set of past cases with known answers.

What parts should a good prompt have?

Five parts cover most prompts: a role, the instructions, the context, a few examples and the output format. The role is one line that sets the job and the tone. Anthropic's guide says that "Setting a role in the system prompt focuses Claude's behavior and tone for your use case."

Here is a small case. The vague version of the prompt was "Reply to this complaint." The model had no fee rules, so it promised a refund the bank cannot give and quoted a fee from an old price list. The clear version adds a role, the rules and one example reply.

What one good prompt holds

Inputs for this case

Customer's message

the one case to answer

Policy text

the fee and refund rules

The prompt

Role

a complaints assistant at a bank

Instructions

what to do, and never promise refunds

Example reply

one real case, answered well

Model

writes from all of it at once

Reply in the format

short, cites the policy line

  1. 1The customer's message goes in as its own part.
  2. 2The policy text goes in its own tag, so the model reads the fees from it.
  3. 3The prompt adds the role, the rules and one example reply.
  4. 4The model writes the reply from all three, in the agreed shape.
A complaints assistant at a bank gets one customer message and the policy text. Its prompt adds a role, the rules and one example, and the model writes a reply in the agreed shape.
  • Vague

    One line, no context

    The reply promises a refund the bank cannot give, and quotes a fee from an old price list.

  • Clear

    Role, rules, policy and one example

    The reply says a team lead reviews any refund, and quotes the fee from the policy tag.

The clear version is longer, so it takes more time to write and sends more text on every call. Add a rule only when a real case needs it, and cut the rest.

Tip

Anthropic's guide makes a habit of this: tell the model what to do, not only what to avoid. Ask for a plain English reply of under 80 words, rather than a bare ban on long replies.

Why do examples and tags make a prompt work?

Examples are the quickest way to show the shape you want. Anthropic's guide says "Include 3-5 examples for best results." Make them look like real cases from the job, and vary them so the model doesn't copy one odd pattern. For a complaints team, that means a refund that needs a team lead, a late fee that gets waived, and an angry message that needs a call back.

Tags do a second job. Anthropic's guide says that "Wrapping each type of content in its own tag (for example, <instructions>, <context>, <input>) reduces misinterpretation." The tag tells the model where your rules end and the customer's words begin.

Here it is in plain Python. Each part sits in its own tag, and the builder stops if a part is missing. The model call itself is left out.

Python
# A prompt builder: each part goes in its own tag, and a missing part stops the build before any model call.
REQUIRED = ["instructions", "policy", "example", "complaint"]

def build_prompt(parts):
    missing = [name for name in REQUIRED if name not in parts]
    if missing:
        return ["MISSING: " + ", ".join(missing)]
    lines = []
    for name in REQUIRED:
        lines.append("<" + name + ">")
        lines.append(parts[name])
        lines.append("</" + name + ">")
    return lines

parts = {
    "instructions": "Reply to the customer. Never promise a refund.",
    "policy": "Late fees: 25 dollars, waived once a year.",
    "example": "Complaint about a late fee. Reply: we have reviewed your account.",
    "complaint": "I was charged a late fee though I paid on time.",
}
for line in build_prompt(parts):
    print(line)
print(build_prompt({"complaint": parts["complaint"]})[0])

Output

<instructions>
Reply to the customer. Never promise a refund.
</instructions>
<policy>
Late fees: 25 dollars, waived once a year.
</policy>
<example>
Complaint about a late fee. Reply: we have reviewed your account.
</example>
<complaint>
I was charged a late fee though I paid on time.
</complaint>
MISSING: instructions, policy, example

The second call leaves three parts out, so the builder reports them and nothing reaches the model.

How do you test a prompt before you trust it?

Reading a prompt shows what you hoped it does. A test shows what it really does. Anthropic's guide suggests a quick first check: "Show your prompt to a colleague with minimal context on the task and ask them to follow it." If the colleague is confused, the model probably will be too.

The real test is a set of past cases with known right answers, including the awkward ones: a fee waiver, a customer in distress, a question the policy does not cover. Run each case, check every reply against the rules and count the failures. Fix one failure at a time, then run the whole set again, because that second run catches the old case your new rule broke.

Test a prompt before you trust it

Write the prompt

role, rules, examples and context

Run on past cases

real complaints with known answers

Check each reply

Breaks a rule?

a promised refund, a wrong fee

Wrong shape?

no case number, too long

Ship it

every past case passes

  1. 1The prompt goes through every past case with a known right answer.
  2. 2Each reply is checked for a broken rule or a wrong shape.
  3. 3If every case passes, the prompt can ship.
  4. 4Any failure sends the prompt back for one fix, then the full set runs again.
A prompt runs through a set of past cases with known right answers. Each reply is checked against the rules. A failure sends the prompt back for one fix, and the full set runs again before anything ships.

Both big vendors say the same thing in their own words:

  • “Building a successful LLM-based application starts with clearly defining your success criteria and then designing evaluations to measure performance against them.”

    Anthropic

  • “Add representative fixtures, tests, and evaluation checks before changing production prompts.”

    OpenAI

Worked example. A bank's fee assistant runs on 200 past complaints, each with the right reply written by a team lead. The first version passes 150 and fails 50. Fourteen of the failures quote last year's fee table. The fix is to put this year's table in a tag and rerun all 200. The cost is that someone now owns that table, and it must be updated whenever fees change.

Prompts also differ by model. Google Cloud's guide notes that "Different models may respond better to specific formats, such as natural language questions, direct commands, or structured inputs with specific fields." Anthropic's guide makes the same point: "Where a technique names a specific model, treat it as measured on that model and re-check it against your own evals before applying it to another."

How would you fix a prompt that fails in production?

Start with the failures, not the prompt. Sort each failed case by its cause, because each cause needs a different fix.

  1. 1

    Find the pattern

    Group the failed cases. Replies that promise refunds are one group, and wrong fees are another.

  2. 2

    Match each cause to a fix

    A missing rule gets a rule. A wrong shape gets an example. A missing fact gets a tag with the fact in it.

  3. 3

    Move hard limits into code

    A refund cap belongs in the payment tool, so a confused or fooled reply can't pay out more than the cap.

  4. 4

    Rerun the full set

    Every change goes through all past cases, so a fix for one group can't quietly break another.

What does the interviewer want to hear?

A strong answer covers

  • A plain definition: the parts that tell the model the job and its limits.
  • The usual parts: role, instructions, context, examples and output format.
  • Why tags help: they keep customer words apart from your rules.
  • Testing on real past cases, rerun after every change.
  • Honest limits: prompts differ by model, and hard limits belong in code.
  • A worked fix and what it costs.

Common traps

  • Trap"Make it longer and it will be better."

    BetterLength helps only when each line gives the model something it needs. Cut the padding.

  • Trap"It reads well, so it works."

    BetterRun it on real past cases. Reading a prompt won't show you how it performs.

  • Trap"Tell it never to make mistakes."

    BetterName the exact rule and what to do instead, then test that the rule holds.

Can you spot the weak prompt line?

Spot the weak line

Your claims assistant sends too many simple claims to a person. Which line gives the model the least to work with?

Quick check

A bank's fee assistant quotes last year's fees. Which fix is most likely to work?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q076What is prompt engineering?11 min
  2. Q080What goes in a system prompt?11 min
  3. Q098How do you pick and order few-shot examples?12 min
  4. Q099Why use delimiters or XML tags?10 min
  5. Q100How do you test prompts systematically?12 min
  6. Q082Context engineering vs prompt engineering?11 min

Learn it in depth

Last updated on 26 November 2026

Writing prompts for a team's real workflow?

I design and build AI products and agents, including the prompts, tests and guardrails behind them. Book a short call and tell me what your team needs to get right.