Stop 12 · Prompt EngineeringTopics · 4/10

System Prompts

Part of the AI Engineer Roadmap

In short

Every AI product you use has hidden instructions that run before your first message. That system prompt sets the bot's role, tone and rules. It's the main control panel you have as a builder.

The instruction layer that sets a model's persona, rules and boundaries for an entire conversation — the main lever product builders use to shape assistant behavior.

The blob catering manager briefs a line of waiters holding trays before a wedding dinner.

Think of it like this

The caterer's briefing

Before a wedding dinner, the catering manager briefs the waiters: serve veg first, no alcohol at table five, be polite to the bride's uncle. Guests never hear this briefing, but it shapes every interaction. The system prompt is that briefing for your model.

Watch it happen

Who says what in a chat app

Developer
User
Model

system: You are...

1/5The developer's system prompt goes first: role, tone, rules. The user never sees it.

The big ideas

What you need to know

Role and audience

Say who the assistant is and who it's talking to. 'Support agent for a college bookstore, talking to students.'

Rules and boundaries

List what it must and must not do, and what to say when it can't help.

Stable facts

Put policies and product details that rarely change here. Changing data belongs in retrieval instead.

Not a secret vault

Users can sometimes coax a model into revealing its system prompt. Never put passwords or API keys in it.

See it in code

Walk through the code

python
1from openai import OpenAI2client = OpenAI()  # reads OPENAI_API_KEY3 4SYSTEM = """You are the support assistant for CampusKart, a college bookstore.5Be friendly and brief. Returns are allowed within 7 days with the bill.6If you don't know something, say so and share help@campuskart.example."""7 8reply = client.chat.completions.create(9    model="<your-model>",10    messages=[11        {"role": "system", "content": SYSTEM},12        {"role": "user", "content": "Can I return a calculator I bought 3 days ago?"},13    ],14)15print(reply.choices[0].message.content)

1/3Role, tone, one policy and a fallback, all in a few short lines.

The system message comes first in the messages list. Most chat APIs follow this same pattern.

Save yourself the pain

Common mistakes

Oops

Writing a 3-page system prompt full of rules that contradict each other.

Do this instead

Keep it focused and test it. Group rules clearly and remove ones you never see used.

Oops

Putting secrets like database passwords in the system prompt.

Do this instead

Treat the system prompt as something users might see. Keep secrets on the server, in code.

Your mission

Build a bot personality

~25 min

Quick check

Where should you put a rule like 'Never give medical diagnoses'?

Go deeper

  1. 1Write a system prompt for a specific assistant persona and test it across many user inputs.
  2. 2Learn the difference in weight/persistence between system prompts and user messages.
  3. 3Practice hardening a system prompt against attempts to override its instructions.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge