A prompt template is a reusable text structure with instructions and slots for task-specific input. In an LLM application, rendering the template combines those inputs into the prompt sent to the model. The template is a configuration artifact: changing its instructions can change application behavior as significantly as changing code. section 3.2.2 section 9.3.4
In retrieval-augmented generation (RAG), the template merges the user’s question with retrieved text and, often, source metadata. Retrieval vectors select matching chunks; the original text, not the vectors, enters the prompt. A template can instruct the model to answer only from the supplied context. section 3.2.2 section 3.10.1
Support ticket triage
A Jinja2 template parameterizes the assistant’s role, company name, classification labels, rules, and ticket. It instructs the model to classify outages, payment failures, security incidents, or data loss as urgent and to output exactly one label. A Python evaluator renders the template with test tickets and expected classifications; a GitHub Actions workflow runs the check in CI. section 9.4.6
Listing 9.7 Prompt template for support ticket triage with Jinja2
You are a {{ role }} for {{ company_name }}.
Use the labels exactly as written:
- {{ urgent_label }}: outages, payment failures, security incidents,
or data loss.
- {{ normal_label }}: how-to questions, account changes, or non-blocking
issues.
Rules:
- If the ticket mentions outage, payment failure, security, or data loss,
reply with {{ urgent_label }}.
- Otherwise reply with {{ normal_label }}.
- Output exactly one word.
Ticket:
{{ ticket }}
Inspect the Jinja2 placeholders and decision rules used for ticket triage. section 9.4.6
Operate templates as versioned configuration:
- Keep templates in version control so changes can be reviewed and rolled back. section 9.3.4 section 9.4.6
- Evaluate changes against a benchmark set. Regression tests can check format adherence, refusal behavior, citations, escalation, accuracy, and resistance to instruction override, using positive, negative, adversarial, and representative inputs. section 9.3.4
- Compare variants with A/B tests, and log the template version, response, and user feedback for monitoring and auditability. section 9.3.4


