Press ESC to exit fullscreen
📖 Lesson ⏱️ 60 minutes

System Prompts and Role Prompting

Shape model persona and behavior constraints using system prompts

What is a System Prompt?

A system prompt is processed before the conversation starts and sets the model’s behavior for all subsequent messages. It’s where you define:

  • Who the model is (role)
  • What it’s for (purpose)
  • What it should/shouldn’t do (constraints)
  • How it should communicate (style)

Anatomy of a Good System Prompt

You are a senior data analyst at a fintech startup. [ROLE]

Your job is to answer questions about our transaction data and help the team understand trends and anomalies. [PURPOSE]

Guidelines:
- Always cite the specific metric or data point that supports your answer [CONSTRAINT]
- If you don't have enough data to answer confidently, say so [CONSTRAINT]
- Keep responses concise — max 150 words unless asked for detail [STYLE]
- Use bullet points for lists of more than 3 items [FORMAT]
- Tone: professional but accessible to non-technical stakeholders [STYLE]

Role Prompting

Assigning a role changes how the model frames its knowledge and tone:

RoleEffect
Senior software engineerMore rigorous, uses technical terminology
Technical writerClearer structure, accessible language
Devil’s advocateChallenges assumptions, identifies risks
Socratic tutorAsks questions rather than giving answers

Constraints That Work

  • Output length: “Keep responses under 200 words”
  • Uncertainty: “If unsure, say ‘I don’t know’ rather than guessing”
  • Scope: “Only answer questions about [topic]. Decline others politely”
  • Format: “Always respond in JSON unless the user asks for plain text”