User Prompt vs System Prompt
Modern chat APIs split a prompt into system and user messages.
Introduction
Modern chat APIs split a prompt into system and user messages. The system message sets the model's role, rules and constraints — it's invisible to the end user. The user message is what the actual person types. Mastering this split is the first step from hobbyist to engineer.
Beginner analogy: The system prompt is the job description handed to a new employee on day one. The user prompt is the daily ticket from a customer. Same employee, very different behaviour based on the job description.
Understanding the topic
Core concepts to understand:
- System: persistent role, tone, rules, format — set once per conversation.
- User: per-message question or instruction from the human.
- Assistant: prior model replies (used to maintain conversation context).
- System prompts have higher 'weight' on Claude and GPT-4 — use them for guardrails.
- Sensitive instructions belong in system, never in user input.
Syntax reference
Visual workflow / architecture:
messages = [{ role: "system", content: "You are a polite Spanish tutor." },{ role: "user", content: "How do I say good morning?" },{ role: "assistant", content: "Buenos días!" },{ role: "user", content: "And good night?" }]
Real-world use
OpenAI's GPTs, Claude Projects, Cursor rules and Notion AI personas are all just persistent system prompts wrapped in a UI.
Best practices
- Put role, format and safety rules in the system message; leave the user free to ask anything.
- Keep system prompts under ~500 tokens for cost & clarity.
- Never trust user input to override the system — design defenses early (see Prompt Injection).
Hands-on exercise
Interview preparation — practice these questions:
- Q1. Difference between system and user prompts?
- Q2. Where do you put safety guardrails and why?
- Q3. What happens if a user message tries to override the system?
- Q4. Why split into roles at all instead of one big prompt?