Skip to main content
Production prompts need to be reliable, not clever. This guide covers patterns that work consistently across thousands of runs.

System Messages

The system message defines who the LLM is and how it behaves. Be specific. Vague (bad):
Specific (good):
The specific version produces consistent, useful output. The vague version produces whatever the model feels like.

Constraints Matter

Explicit constraints prevent the most common failure modes:
Without constraints, the model might invent categories, misclassify edge cases inconsistently, or add explanations you don’t want.

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, use generateText with Output.object() and a Zod schema instead of asking for JSON in the prompt. Unreliable (parsing JSON from text):
Reliable (schema-validated):
The schema is validated server-side by the LLM provider. You get typed output or an error — no parsing surprises.

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:
Better — split into focused calls:

Few-Shot Examples

Show the LLM what you want with 2-3 examples. This works better than lengthy instructions.
Few-shot examples are especially effective for:
  • Classification tasks
  • Formatting requirements
  • Edge case handling
  • Tone matching

Common Mistakes

1. No Role Definition

2. Unbounded Creativity

3. Asking for Everything at Once

Run multiple focused prompts and combine results in your workflow. This is what steps are for.

Writing Style Guidelines

For prompts that generate customer-facing content, define explicit style rules:
These constraints produce consistent output that matches your brand voice.

Output Shape Selection

Match the Output.* helper to your output shape:

Further Reading