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

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.

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.

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.

Key words

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.

What the model reads before a message

Your system prompt

Role and goal

who it is and who it serves

Rules

what to do, and never do

Output shape

length, format and tone

Examples

three to five sample cases

Context

current policy text, kept short

Model

reads all of it before each message

Reply

inside your rules and shape

  1. 1The five parts go in first, ahead of anything the user types.
  2. 2The model answers inside those rules, in the shape you set.
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.
  • “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.

Where each kind of text belongs

Keep in the prompt

Everyday rules

the same for every customer

Tone and format

how replies sound and look

Keep out of it

Passwords and keys

a clever user can find them

One customer's data

changes on every call

Whole policy manual

costly, and out of date soon

Model

follows the rules, asks for facts

Lookup tool

fetches only this customer's data

Code checks it

before the reply uses it

  1. 1Rules and tone go in first, so the model reads them on every call.
  2. 2The model asks the lookup tool for one customer's data, never a stored copy.
  3. 3Your code checks that result before the reply uses it.
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.
  • 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

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

    BetterLong 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."

    BetterThe model asks a tool. Your code holds the key and makes the call.

  • Trap"A strong system prompt stops misuse."

    BetterIt 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?

Quick check

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

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q081What makes a good prompt?13 min
  2. Q082Context engineering vs prompt engineering?11 min
  3. Q087Why template and version your prompts?11 min
  4. Q088What is prompt caching, and how does it save money?13 min
  5. Q201What is prompt injection?12 min

Learn it in depth

Last updated on 26 November 2026

Building an assistant that has to follow strict rules?

I design and build AI assistants and agents, the interface and the system behind them, including the prompts and the code that enforces the limits. Book a short call and tell me what yours needs to do.