Communicating with LLMs
15 minLesson 5 of 14
System Prompts and Personas
Shape model behavior with system prompts and personas for specific products and workflows
Learning goals
- •Understand what system prompts are and how they work
- •Learn to design effective personas for different use cases
- •Know common patterns for system prompt design
What Is a System Prompt?
- Sets persistent behavior rules
- Defines the AI's role and capabilities
- Establishes constraints and guidelines
- Is typically invisible to end users
Most APIs distinguish between "system" and "user" messages, giving system prompts priority.
Designing Effective Personas
Define the Role Clearly
You are a senior software architect with 15 years of experience
in distributed systems. You prioritize scalability and maintainability.Set Behavioral Rules
Rules:
- Always ask clarifying questions before providing solutions
- Cite trade-offs for every recommendation
- Never recommend deprecated technologiesEstablish Boundaries
Limitations:
- You can only discuss topics related to software architecture
- You cannot write or execute code directly
- You must acknowledge uncertainty when applicableSystem Prompt Patterns
The Expert Pattern
Position the model as a domain expert with specific knowledge and approach.
The Persona Pattern
Give the model a character with personality traits, speaking style, and values.
The Safety Pattern
Include instructions for handling edge cases, sensitive topics, and error conditions.
Common mistakes
×Making system prompts too long—the model may ignore parts of overly complex instructions
×Conflicting instructions—contradictory rules confuse the model
×Not testing edge cases—users will try to break or bypass your system prompt
×Assuming perfect compliance—models may still deviate from system prompt instructions
Key takeaways
+System prompts set persistent behavior rules for the entire conversation
+Define clear roles, rules, and boundaries in your system prompts
+Use patterns like Expert, Persona, and Safety for different use cases
+Test thoroughly—users will find ways to challenge your system prompt