System Messages
The system message defines who the LLM is and how it behaves. Be specific. Vague (bad):Constraints Matter
Explicit constraints prevent the most common failure modes:Temperature Settings
Temperature controls randomness. Match it to your task:
For production workflows, err toward lower temperatures. A temperature of 0 means the same input produces the same output — essential for debugging and testing. Judge prompts should always use temperature 0.
judge_summary@v1.prompt
Structured Output
When you need to parse the result programmatically, usegenerateText with Output.object() and a Zod schema instead of asking for JSON in the prompt.
Unreliable (parsing JSON from text):
Keep Schemas Simple
Complex nested schemas confuse models. If your schema has more than 5-6 fields or deep nesting, split it into multiple calls. Too complex:Few-Shot Examples
Show the LLM what you want with 2-3 examples. This works better than lengthy instructions.- Classification tasks
- Formatting requirements
- Edge case handling
- Tone matching
Common Mistakes
1. No Role Definition
2. Unbounded Creativity
3. Asking for Everything at Once
Writing Style Guidelines
For prompts that generate customer-facing content, define explicit style rules:Output Shape Selection
Match theOutput.* helper to your output shape:
Further Reading
- Anthropic’s prompt engineering guide
- LLM-as-a-Judge Best Practices — Writing effective judge prompts specifically