StudyAIStudyAI
Pro
Lesson 59 min

System Prompts

Set persistent rules for tone, behaviour, and safety.

What you will learn
  • What a system prompt is and why it is special
  • Locking tone, persona, and refusal rules
  • Requesting structured output reliably

Explanation

Most chat APIs let you set a system prompt — instructions that apply to the whole conversation, separate from the user's messages. It is where you fix the persona, rules, and boundaries.

Use it to lock tone ('always professional and concise'), define refusals ('never give medical diagnoses'), and require a consistent format ('always reply in valid JSON with keys answer and confidence').

Because it persists, the system prompt is how products keep an assistant on-brand and on-task across many user turns.

Code Example

text
1
System: You are StudyAI's HR assistant. Be warm and concise.
2
Never give legal advice. If unsure, ask a clarifying question.
3
Always end with one suggested next step.
Real-world use

Every AI product you use has a hidden system prompt shaping its personality and guardrails.

Common mistakes
  • Putting rules in each user message instead of once in the system prompt.
Practice

Write a system prompt for an HR assistant that stays friendly, refuses legal advice, and always suggests a next step.

Knowledge check
0/1 answered

1. What makes a system prompt different from a normal message?

Answer all questions to check.