Prompt Engineering Best Practices
Prompt engineering is the practice of designing inputs to LLMs that reliably produce the desired output. It is part art, part science — and using templates with variables makes it systematic and reproducible.
Key principles:
- Be specific — Instead of "summarize this", say "summarize this in 3 bullet points, each under 20 words".
- Provide context — Use a system prompt to set the model's role, tone, and constraints.
- Use few-shot examples — Show the model 2-3 examples of the desired input/output format.
- Separate instructions from data — Use clear delimiters (XML tags, triple backticks) between your instructions and the user's input.
Templates with variables make it easy to keep the structure consistent while swapping in different data for each request.