Prompt Engineering System Prompts and Roles
System prompts and roles let you set rules that apply to a whole conversation. In chat-based APIs every message has a role: system, user or assistant. The system message describes who the assistant is and how it must behave.
System vs User Messages
- system - written by the developer; persona, rules, format, boundaries.
- user - what the end user asks; changes every turn.
- assistant - the model's previous replies.
A Solid System Prompt
You are the help assistant for "GreenLeaf", an online plant shop.
Goals:
- Help customers choose plants and care for them.
- Answer questions about orders using only the provided order data.
Rules:
- Keep answers under 120 words.
- If you are unsure, say so and offer to connect a human agent.
- Never invent prices, discounts or delivery dates.
- Do not discuss topics unrelated to plants or GreenLeaf orders.
Tone: warm, practical, no jargon.(user) My fern's leaves are turning brown at the tips. Sample response: Brown tips usually mean the air is too dry or the soil dried out. Try misting it a few times a week, keep it away from heaters, and water when the top 2 cm of soil feels dry. If it continues, I can connect you with our plant care team.
Role Prompting
Assigning an expert role ("You are a senior tax accountant") nudges vocabulary and depth. It helps most when combined with concrete instructions; a role alone does not add knowledge the model lacks.
You are a patient primary-school teacher.
Explain what fractions are to a 9-year-old, using a pizza example, in 3 sentences.Sample response: A fraction is a way to show part of something whole. If you cut a pizza into 4 equal slices and eat 1, you ate 1/4 of the pizza. The bottom number tells how many slices there are, and the top number tells how many you have.
Tips
- Put stable rules in the system prompt and task-specific data in user messages.
- Explain the reason behind rules; models follow rules better when they understand why.
- Avoid long lists of ALL-CAPS commands; calm, clear wording works better.
- Remember the system prompt is not secret; users can often coax it out.
Frequently asked questions
What is a system prompt?
A developer-written message at the start of a chat that sets the assistant's role, rules and style for the whole conversation.
Can users see the system prompt?
Not directly in most apps, but they may extract it through clever questions. Never put secrets like API keys in it.
Does role prompting improve accuracy?
It improves tone and focus. For accuracy, clear instructions, context and examples matter more.