prompt-eng
Glossary ↗Prompt Template
A prompt template is a prompt written with placeholder variables (commonly using syntax like {{variable_name}}, {variable}, or $variable) instead of hardcoded values, designed to be reused across many requests by substituting different data into the same underlying structure and instructions. Prompt templates are the standard way production SaaS applications integrate LLMs, because raw prompts crafted ad hoc in a chat interface don't scale to a codebase serving thousands of users with different inputs. Instead, developers write one well-tested template per AI feature and populate it programmatically — much like a SQL prepared statement or an email template. Templates typically live in version control (or a dedicated prompt-management tool), separate from application logic, so they can be edited, A/B tested, and rolled back without a full code deploy — a pattern increasingly supported by dedicated prompt-management platforms (e.g., LangSmith, PromptLayer, Langfuse) that track template versions, log every filled prompt and its output, and support prompt-level evaluation and rollback. Good template design keeps variable substitution unambiguous (using clear delimiters so injected data can't be confused with instructions — directly relevant to preventing prompt injection), handles edge cases like empty or very long variable values gracefully, and separates the stable instruction portion from the variable data portion so the instruction can be improved without touching every call site. Concrete worked example: a customer-feedback-summarization SaaS feature uses this template stored in the codebase: "Summarize the following {{num_reviews}} customer reviews for the product \"{{product_name}}\" into 3 bullet points: one common praise, one common complaint, and one actionable suggestion. Reviews:\n{{reviews_text}}\n\nRespond in JSON: {\"praise\": string, \"complaint\": string, \"suggestion\": string}." At runtime, the application fills {{num_reviews}}, {{product_name}}, and {{reviews_text}} from the database for each product, sends the populated prompt to the model, and parses the JSON response into the UI. When the team later wants to add a 4th field ("sentiment_score"), they edit the one template file rather than hunting through scattered inline prompt strings across the codebase.
Related terms