System Prompt Design — Prompting Guide & Examples
System prompt design is the art of crafting the persistent instructions that shape an AI's behavior across an entire conversation. A well-designed system prompt defines the AI's role, capabilities, constraints, output format, and behavioral guidelines.
How It Works
The system prompt sits in a privileged position — it's processed before any user messages and persists across the conversation. Structure it with clear sections: identity/role, core instructions, output format, constraints/rules, and examples. Use XML tags or markdown headers to organize complex system prompts.
When to Use
Use system prompting for any production AI application, chatbots, assistants, and workflows where you need consistent behavior across many interactions. The system prompt is your primary control mechanism for deployed AI.
Model-Specific Tips
ChatGPT / GPT-4
Use the 'system' role in the API. GPT-4 follows system prompts well. Use clear sections with headers. Keep critical rules near the top.
Claude
Claude strongly adheres to system prompts. Use XML tags for structure. Claude respects constraints and will refuse to violate system prompt rules.
Gemini
Gemini supports system instructions. Place them in the systemInstruction field. Gemini respects boundaries but test edge cases carefully.
Pros & Cons
Pros
- ✓ Controls AI behavior consistently
- ✓ Persists across entire conversations
- ✓ Foundation of production AI apps
- ✓ Combines well with all other techniques
Cons
- ✗ Long system prompts increase cost
- ✗ Can be overridden by clever user inputs
- ✗ Requires testing across edge cases
- ✗ Balance between specificity and flexibility is hard
Example Prompts
You are a customer support agent for TechCorp. RULES: - Always greet customers warmly - Never reveal internal pricing or policies - Escalate billing disputes to human agents - Keep responses under 3 sentences unless asked for detail FORMAT: - Use bullet points for multiple items - Include a suggested next action at the end TONE: Professional but friendly. Match the customer's energy level.
<role>Senior code reviewer at a Fortune 500 company</role> <rules> - Review code for: security, performance, readability, maintainability - Always suggest specific improvements, not just problems - Rate severity: CRITICAL / WARNING / SUGGESTION - Never rewrite entire files — show targeted diffs </rules> <format>Start with a 1-sentence summary, then list findings by severity</format>
You are a medical triage assistant. You do NOT diagnose conditions. BEHAVIOR: 1. Ask clarifying questions about symptoms 2. Assess urgency: EMERGENCY / URGENT / ROUTINE 3. Recommend: ER, urgent care, schedule appointment, or home care 4. Always end with: 'This is not medical advice. Please consult a healthcare professional.' NEVER: Prescribe medication, diagnose conditions, or dismiss symptoms.