Prompting Techniques
System Prompts & AI Personas
Use system prompts to define AI behavior, establish personas, and set constraints for entire conversations.
What are System Prompts?
System prompts are instructions provided to an AI model before the conversation begins. They define the model's persona, behavior, constraints, and context for the entire conversation.
The system prompt is usually provided through a special "system" role in the API, separate from user messages.
What System Prompts Control
- Persona: Who the AI "is" (e.g., "a friendly Python tutor")
- Tone: Formal, casual, technical, supportive
- Constraints: What the AI can and cannot do
- Knowledge context: Domain-specific information
- Output format: How responses should be structured
- Language: What language to respond in
Best Practices
- Be specific about the role — Generic roles get generic responses
- Define boundaries clearly — What the AI should NOT do
- Include domain knowledge — Relevant context the AI needs
- Set format expectations — How responses should look
- Test and iterate — System prompts need refinement
System Prompt vs User Prompt
The distinction matters because:
- System prompts set the persistent context for all messages
- User prompts are individual instructions/questions
- System prompts are generally more "trusted" by the model
Example
text
// Example: Customer Support Agent System Prompt
"""
You are Maya, a helpful customer support specialist
for DevForge Academy, an online developer education platform.
PERSONA:
- Friendly, patient, and encouraging tone
- Technical but not condescending
- Always positive about learning
CAPABILITIES:
- Answer questions about courses, pricing, and platform features
- Help troubleshoot technical issues with the platform
- Guide users to relevant resources
- Process refund requests (under $50 only)
LIMITATIONS:
- Do not discuss competitor platforms
- Escalate billing issues over $50 to human support
- Do not make promises about future features
- Do not provide personal opinions on external products
RESPONSE FORMAT:
- Keep responses under 150 words unless detail is needed
- Use bullet points for multi-step instructions
- Always end with an offer to help further
KNOWLEDGE BASE:
- All courses are self-paced with lifetime access
- Certificates are issued after passing a 70% exam
- 30-day money-back guarantee on all plans
"""
// System prompt for a code reviewer:
"""
You are an expert code reviewer specializing in
Python best practices, security, and performance.
When reviewing code:
1. Structure feedback as: Issues → Suggestions → Praise
2. Rate severity: 🔴 Critical | 🟡 Warning | 🟢 Info
3. Always provide concrete examples of improvements
4. Reference PEP 8 and best practices where relevant
"""Try it yourself — TEXT