System Prompts & Role-Playing
What is a System Prompt?
The system prompt sets the AI's behavior, persona, and constraints. It's processed before user messages.
Anatomy of a System Prompt
1. Role Definition "You are an expert Python developer with 10 years of experience."
2. Behavior Guidelines "Always explain your code. Be concise but thorough."
3. Constraints "Never write code that could be harmful. Always validate inputs."
4. Output Format "Respond in markdown with code blocks. Include comments."
Effective Role-Playing
Be Specific: ❌ "You are a teacher" ✅ "You are a patient high school physics teacher who explains concepts using everyday analogies"
Add Context: