# What Goes in a System Prompt?

> What goes in a system prompt, what stays out, and how to check it, explained simply with a bank example for your AI interview.

**In short:** A system prompt is the set of standing instructions an app gives an AI model before the user types, covering its role, rules, output shape, examples and facts. Keep secrets and one customer's data out of it, and let code enforce the limits that matter most.

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

## Say it in 30 seconds

A system prompt is the set of standing instructions an app gives the model before the user types anything. I put five things in it: the role, the rules, the output shape, a few examples and the facts it needs. I keep out passwords and one customer's data, because a clever user can find what the model reads. Hard limits, like a refund cap, live in my code, where a clever message can't talk them away.

## Say it in 2 minutes

Think of a system prompt as the handbook a new hire reads on day one. It sits above every conversation, and the customer is not meant to see it. It says who the assistant is, what it must and must not do, and how its replies should look. OpenAI calls the developer's instructions a developer message, and says they are prioritised ahead of user messages.

I build mine from five parts: a role and goal, the rules, the output shape, three to five worked examples, and the facts it needs. Anthropic's guide says that Claude can generalise from the explanation. Keep it short too, because every extra line costs tokens (the small chunks of text a model reads and bills you for) on every call, and the rules that matter get lost in the noise. A good test is to hand the prompt to a colleague with no context. If they would be confused, the model will be too.

What stays out matters just as much. OWASP, which publishes a top 10 list of AI application risks, says to design as if hidden context is discoverable, so passwords and keys never go in. Customer data is fetched by a tool, for that one person, when it is needed. Hard limits, like a refund cap, live in code, because a model can be talked round and code cannot. OWASP's 2026 list says critical controls must not be delegated to the LLM. In practice the model asks for an action, and the code decides whether it runs.

## What is a system prompt, in plain words?

Most AI apps have a set of standing instructions that the model reads before anyone types a word. That is the system prompt. The model reads it on every call, and it shapes every answer. The person chatting with the app usually can't see it.

Picture a new hire on the first morning at a bank's support desk. They read the team handbook: what the job covers, what they must never promise, how a good reply sounds. A customer never sees the handbook, yet it shapes every answer that new hire gives. A system prompt plays the same part for an AI assistant, and the bank case below shows one.

- **System prompt:** The standing instructions an app sends before the user's first message.
- **Developer message:** OpenAI's name for the developer's instructions, which take priority over the user's messages.
- **Context:** The facts the model needs for this app, such as the current policy text.
- **Token:** A small chunk of text that a model reads and is billed for. Long prompts use more of them.
- **Tool:** A function your code runs when the model asks, such as looking up a balance.

## What goes in a system prompt?

A useful one covers five things. Keep each part short and plain.

- **Role and goal:** Who the assistant is and who it serves. Anthropic says even one sentence helps.
- **Rules:** What it must do and never do, each with its reason. Anthropic's guide says Claude can generalise from the explanation.
- **Output shape:** Length, format, tone and what to end with. Anthropic's advice is to be specific about the format and the limits.
- **Examples:** Three to five sample questions with the reply you want. Anthropic suggests the same range for best results.
- **Context:** The facts it needs, such as current policy text, kept short and up to date.

*Diagram, What the model reads before a message: Five kinds of text go in first, before any user message. The model reads them on every call, and it answers inside those rules and that shape. Your code still checks what matters most.*
1. The five parts go in first, ahead of anything the user types.
2. The model answers inside those rules, in the shape you set.

> "Setting a role in the system prompt focuses Claude's behavior and tone for your use case." (Anthropic, prompting guide)
>
> "System prompts should be extremely clear and use simple, direct language that presents ideas at the right altitude for the agent." (Anthropic, context engineering)

Anthropic's engineers aim for the minimal set of information that fully outlines the behaviour they expect. The guide names two ways to get it wrong: hardcoded, brittle logic at one extreme, and vague, high-level guidance at the other. Check a draft the simple way: give it to a colleague with no context, and ask them to follow it.

## What should stay out of it?

Most bad system prompts fail on what is inside them. Three things do the most damage.

Secrets come first. A key, a password or a connection string in the prompt can be found by a clever user, so it should never be there. OWASP, which publishes a top 10 list of AI application risks, says in its 2026 list to design as if hidden context is discoverable.

> "Practitioners should design under the assumption that hidden context is discoverable and that any contents of the context should not be considered a secret." (OWASP, LLM08:2026 Hidden Context Exposure)
>
> "Sensitive data such as credentials, connection strings, and tokens should not be embedded in it" (OWASP, LLM08:2026 Hidden Context Exposure)

Customer data is second. One customer's balance or claim history changes on every call. It belongs in a tool call that your code runs for that person only.

The third is a whole policy manual pasted in. It costs more on every call, and it goes out of date when the policy changes. Paste the rule that matters, and let a tool fetch the rest.

*Diagram, Where each kind of text belongs: Rules and tone go in the prompt. Passwords, customer data and whole manuals stay out, and a lookup tool fetches only what one answer needs. Your code checks that result before the reply uses it.*
1. Rules and tone go in first, so the model reads them on every call.
2. The model asks the lookup tool for one customer's data, never a stored copy.
3. Your code checks that result before the reply uses it.

- **Weak: Balance pasted in.** The prompt holds one customer's balance from this morning. It is wrong by lunch, and a clever user may read it.
- **Better: Tool fetches it.** The model asks a lookup tool for this customer's balance. Your code checks who is asking, and returns only that account.

Here is a worked example for a mid-size bank's card-dispute assistant. The prompt is built from parts, and the build refuses to run if a banned word, such as a key name, slips in.

```python
# A mid-size bank's card-dispute assistant. Its system prompt is built from parts,
# and the build refuses any part that contains a banned word, such as a key name or a balance.
PARTS = {
    "role": "You help bank customers with card disputes. You never approve refunds.",
    "rules": "Quote policy only from tool results. Never promise a refund or a date.",
    "format": "Reply in under 120 words and end with a case reference.",
}
BANNED = ["card_vault_key", "db_password", "balance:"]

def build(parts):
    text = "\n\n".join(name.upper() + ":\n" + body for name, body in parts.items())
    for word in BANNED:
        if word in text:
            raise ValueError("keep out of the prompt: " + word)
    return text

print(build(PARTS))
print()
try:
    build({**PARTS, "rules": PARTS["rules"] + " Use card_vault_key=cvk-0042."})
except ValueError as err:
    print("Blocked:", err)
```

Output:

```text
ROLE:
You help bank customers with card disputes. You never approve refunds.

RULES:
Quote policy only from tool results. Never promise a refund or a date.

FORMAT:
Reply in under 120 words and end with a case reference.

Blocked: keep out of the prompt: card_vault_key
```

The key never reaches the model. The refund limit is enforced in the refund tool, not in the prompt. In the real app, that tool checks the amount before any money moves, and the prompt only tells the assistant to pass the customer to a human agent.

### How would you write one for a hospital note summariser?

The summariser shortens a doctor's notes for the next shift. The risk is a dose that was never written, or an allergy that drops out of the summary. A prompt alone can't stop that.

- **Prompt only: Hope it copies well.** The prompt says to copy doses exactly. A busy model still rounds a number, and nothing checks it.
- **Prompt and code: Check before saving.** The prompt says to copy each dose word for word, or write 'not stated'. Code compares every dose with the note and blocks any that differ.

A clinician still signs the summary, because a person who reads the exact text catches what a check misses. In the interview, say it plainly: the prompt sets the behaviour, and code and people hold the line.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] A plain definition: the standing instructions the model reads before the user types.
- [ ] The parts: role, rules, output shape, examples and context.
- [ ] What stays out: secrets, customer data and whole manuals.
- [ ] Where hard limits live: in code, not in the wording of the prompt.
- [ ] How you test it: a colleague's read first, then evals (scored test cases) on real examples.
- [ ] Honest limits: a prompt lowers the odds, it does not guarantee anything.

**Common traps**

- Trap: "Put everything in the system prompt, so it always knows." Better: Long prompts cost more and go stale. Keep the rules there, and fetch facts with tools.
- Trap: "Put the API key in the prompt so the model can call the service." Better: The model asks a tool. Your code holds the key and makes the call.
- Trap: "A strong system prompt stops misuse." Better: It lowers the odds. Hard limits belong in code the model cannot change.

## Can you spot the problem?

**Spot the problem:** Which line in this card-dispute system prompt is the biggest risk?

A. You are a card-dispute assistant. Be polite and brief.
B. Refunds over 500 dollars need a human agent. Say so, and open a case.
C. When you call the lookup tool, use card_vault_key=cvk-0042.
D. Reply in under 120 words, ending with a case reference.

**Answer:** C. A key sits in the text the model reads, and a clever user can ask for it. Keep keys in code, so the tool call handles them.

**Quick check:** A bank's fee table changes every month. Where should the assistant get the current table?

A. Pasted in full into the system prompt
B. Fetched by a tool from the fee service, then quoted from its result
C. Typed into the user's first message
D. Stored in the model's memory

**Answer:** B. A tool reads the live table, and your code controls what it returns. A pasted copy goes stale every time the fees change, and it costs tokens on every call.

## Can you answer these from memory?

**Flash cards**

- **What is a system prompt?** Standing instructions the app sends before the user's first message, usually unseen by the user.
- **What are its five parts?** Role and goal, rules, output shape, examples, and context facts.
- **Where do secrets go?** Not in the prompt. Code holds them, and tools use them.
- **Why not paste a whole manual?** It costs tokens on every call and goes out of date when the policy changes.
- **What is a developer message?** OpenAI's name for the developer's instructions, prioritised over user messages.
- **Can a prompt enforce a refund cap?** No. The prompt can ask for it. Code has to enforce it.

## Likely follow-up questions

- Q081 What makes a good prompt? https://designervenkat.online/interview/ai/what-makes-a-good-prompt
- Q082 Context engineering vs prompt engineering? https://designervenkat.online/interview/ai/context-engineering-vs-prompt-engineering
- Q087 Why template and version your prompts? https://designervenkat.online/interview/ai/why-template-and-version-your-prompts
- Q088 What is prompt caching, and how does it save money? https://designervenkat.online/interview/ai/what-is-prompt-caching
- Q201 What is prompt injection? https://designervenkat.online/interview/ai/what-is-prompt-injection

## Learn it in depth

- [System Prompting](https://designervenkat.online/learn/ai-engineering/system-prompting)
