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

AI and LLM interview question Q081, Prompt and context engineering. Beginner, very common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/what-makes-a-good-prompt

## Say it in 30 seconds

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.

## Say it in 2 minutes

Think of a good prompt as a handover note. Anthropic's guide describes the model as "a brilliant but new employee who lacks context on your norms and workflows." A new hire does a good job only with the note in front of them, so the prompt must say the job, the background, the rules and the output shape. In a bank's complaints assistant, that means the fee rules, plus one rule it must never break: no promised refunds, because only a team lead can approve one.

The parts usually go in a rough order: role, instructions, examples, then context and the message to answer. OpenAI's guide lists sections such as identity, instructions and context, notes that the best order can vary by model, and says context is usually best near the end. Anthropic's guide asks for long documents near the top, above the query. The two guides place documents differently, so I test the order on the model I use. Each part gets its own tag, such as policy or complaint, so the model keeps customer words apart from rules.

The part people skip is the test. Anthropic's guide says that "Building a successful LLM-based application starts with clearly defining your success criteria and then designing evaluations to measure performance against them." So I keep a set of past complaints with known right answers, run the prompt on all of them, and count what breaks. Each fix goes back through the whole set, so a new rule is less likely to quietly break an old case.

Two honest limits. Advice on prompts is model-specific, so I re-check it on each model. And a prompt can't enforce what code must enforce. A refund limit belongs in the payment tool's code, because a prompt can only ask the model to respect it.

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

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

*Diagram, What one good prompt holds: 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.*
1. The customer's message goes in as its own part.
2. The policy text goes in its own tag, so the model reads the fees from it.
3. The prompt adds the role, the rules and one example reply.
4. The model writes the reply from all three, 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:

```text
<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.

*Diagram, Test a prompt before you trust it: 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.*
1. The prompt goes through every past case with a known right answer.
2. Each reply is checked for a broken rule or a wrong shape.
3. If every case passes, the prompt can ship.
4. Any failure sends the prompt back for one fix, then the full set runs again.

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. **Find the pattern:** Group the failed cases. Replies that promise refunds are one group, and wrong fees are another.
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. **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. **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." Better: Length helps only when each line gives the model something it needs. Cut the padding.
- Trap: "It reads well, so it works." Better: Run it on real past cases. Reading a prompt won't show you how it performs.
- Trap: "Tell it never to make mistakes." Better: Name 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?

A. Be helpful, accurate and professional.
B. Auto-approve claims under 500 dollars with no injury. Send the rest to a person.
C. Quote policy limits only from the policy tag.
D. End with one line: approve, review or reject.

**Answer:** A. Helpful, accurate and professional describe every assistant, so the model has no rule to act on. The other three give a rule, a source or a shape. Replace the vague line with the rule your team really uses.

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

A. Use a bigger model
B. Put this year's fee table in a tag and test replies against it
C. Lower the randomness setting
D. Shorten the instructions at the top

**Answer:** B. A model can only quote fees it was given. A bigger model or a lower randomness setting does not add this year's table, and a shorter prompt may drop it. Give it the current table and test the replies against it.

## Can you answer these from memory?

**Flash cards**

- **What is a good prompt?** The job, the background, the rules, the output shape and a few examples, tested on real cases.
- **Which parts does a prompt usually have?** A role, instructions, context, a few examples and the output format.
- **Why wrap parts in tags?** So the model can tell your rules apart from customer words and data.
- **How many examples?** Anthropic suggests three to five. Use real cases from the job.
- **Where do hard limits belong?** In code. A prompt can ask the model to respect a limit, but only code enforces it.
- **How do you check a prompt?** Run it on past cases with known answers, check each reply, and rerun the full set after each change.

## Likely follow-up questions

- Q076 What is prompt engineering? https://designervenkat.online/interview/ai/what-is-prompt-engineering
- Q080 What goes in a system prompt? https://designervenkat.online/interview/ai/what-goes-in-a-system-prompt
- Q098 How do you pick and order few-shot examples? https://designervenkat.online/interview/ai/how-do-you-pick-and-order-few-shot-examples
- Q099 Why use delimiters or XML tags? https://designervenkat.online/interview/ai/why-use-delimiters-or-xml-tags
- Q100 How do you test prompts systematically? https://designervenkat.online/interview/ai/how-to-test-prompts-systematically
- Q082 Context engineering vs prompt engineering? https://designervenkat.online/interview/ai/context-engineering-vs-prompt-engineering

## Learn it in depth

- [Prompt Engineering](https://designervenkat.online/learn/ai-engineering/prompt-engineering)
- [System Prompting](https://designervenkat.online/learn/ai-engineering/system-prompting)
- [Prompts That Hold Up](https://designervenkat.online/learn/ai-engineering/robust-prompt-engineering)
