System Prompts
Set persistent behavior and constraints that guide the AI throughout a conversation
What are System Prompts?
System prompts are high-level instructions that set the overall context, persona, or behavior for an AI conversation. Unlike user prompts which change with each message, system prompts remain active throughout the entire session.
Think of it as setting the "ground rules" before a conversation begins. The system prompt tells the AI who it is, how it should respond, and what boundaries to observe.
When to Use It
Best For:
- • Setting AI persona/tone
- • Defining response format
- • Establishing safety guidelines
- • Multi-turn conversations
Not Ideal For:
- • Single-turn queries
- • Quick factual questions
- • One-off tasks
- • When persona isn't relevant
Examples
def get_user(id): return db.query(id) • SQL injection vulnerability - use parameterized queries
• No input validation for `id` parameter
Best Practices:
• Add type hints
• Implement error handling
• Add docstring
Best Practices
- 01 Be specific but concise
Include essential rules without overwhelming the model with details
- 02 Place key instructions early
The model gives more weight to instructions at the beginning
- 03 Test and iterate
System prompts often need refinement based on actual outputs
- 04 Combine with user prompts
System prompts set context; user prompts provide specific tasks
System vs User Prompts
System prompts define persistent behavior across a session, while user prompts are task-specific. For best results, use system prompts for overall context and user prompts for immediate tasks. Some platforms combine these into a single conversation.