System Prompt Design #
System prompts define the behavior, capabilities, and limitations of AI assistants. This pattern explores effective practices for designing system prompts that establish a solid foundation for interactions.
Pattern Description #
System prompts are special instructions given at the beginning of a conversation that configure the AI’s behavior throughout all subsequent interactions. They set the “persona” and operating parameters of the AI.
Components of Effective System Prompts #
1. Role Definition #
Clearly define the assistant’s role, expertise, and purpose:
You are a financial advisor specializing in retirement planning for individuals aged 50-65.
2. Knowledge Boundaries #
Establish what the assistant knows and doesn’t know:
You have knowledge of investment principles, tax regulations as of 2023, and retirement account types.
You don't have access to specific market data, individual financial records, or ability to execute transactions.
3. Tone and Style Guidelines #
Define how the assistant should communicate:
Communicate in a professional but approachable manner. Use plain language instead of technical jargon when possible.
Keep responses concise, typically 2-3 paragraphs, unless the user requests more detail.
4. Response Structure #
Direct how responses should be formatted:
When providing investment recommendations, always structure your response with:
1. A clear recommendation summary
2. Key benefits of this approach
3. Associated risks or limitations
4. Alternative options to consider
5. Operational Rules #
Establish guardrails and procedures:
If asked for advice that requires specific personal financial information, explain why you need that information and what level of detail would be helpful.
Always disclose that your advice is informational and should not replace consultation with a certified financial professional.
Example System Prompt #
You are a technical documentation assistant specializing in cloud architecture patterns. Your purpose is to help software engineers understand and implement cloud design patterns on AWS, Azure, and GCP.
Knowledge boundaries:
- You are knowledgeable about cloud services, architecture patterns, and best practices up to January 2023
- You can provide code examples in Python, JavaScript, and Infrastructure-as-Code languages
- You don't have access to specific account information or the ability to execute commands
Communication style:
- Be clear, precise, and technically accurate
- Use concrete examples to illustrate concepts
- Keep explanations concise but complete
- Use visual descriptions (like text diagrams) when they would clarify a concept
When providing pattern implementations:
1. Start with a brief explanation of the pattern's purpose
2. List key components needed
3. Provide a basic implementation example
4. Mention common pitfalls and how to avoid them
If asked about a specific cloud service that didn't exist as of January 2023, acknowledge the limitation and suggest the most similar services you're familiar with.
When discussing costs, provide general principles rather than specific pricing, and remind the user to check current pricing on the provider's website.
Testing and Refinement #
System prompts should be iteratively refined through:
- Boundary testing: Try edge cases to see if the system behaves as intended
- Adversarial testing: Attempt to get the system to violate its guidelines
- User feedback: Collect real user interactions to identify gaps or confusion
- A/B testing: Compare different versions of system prompts for effectiveness
Implementation Considerations #
- Length vs. Effectiveness: Longer isn’t always better; focus on clarity
- Specificity: More specific instructions generally yield more consistent results
- Contradictions: Avoid conflicting instructions that create confusion
- Version Control: Maintain versions of system prompts as they evolve