Skip to main content
Versioned prompt templates moving through a test suite and canary rollout into production

Prompt Engineering at Scale: Moving Beyond Hacks

When you have hundreds of prompt templates in production, ad-hoc prompt engineering breaks down fast.

Prompt engineering has a reputation problem. For many developers, it conjures images of trial-and-error, magical incantations, and vague advice like “be more specific.” At small scale — one or two prompts — that approach is fine. At production scale — dozens of prompt templates, multiple models, and continuous iteration — it’s a disaster.

Here’s how we think about prompt engineering as a proper engineering discipline.

Treat Prompts as Code

This is the foundational rule. Prompts belong in version control (not hardcoded in application files), they have tests, they go through code review, and changes to them have a deployment process.

We typically store prompts as YAML files that include:

  • The prompt template with clearly named variables
  • The model and parameters it’s designed for
  • The version number and changelog
  • The evaluation criteria for this prompt
  • Example inputs and expected outputs

Define a Prompt Testing Pipeline

Every prompt change should run against your evaluation suite before it can be merged. This means having:

  • A set of regression test cases representing the distribution of real inputs
  • Automated metrics appropriate for your task (format checks, semantic similarity, LLM judge)
  • A clear threshold: “this change must not reduce eval score by more than X%”

Without this, you’re shipping prompt changes blind and wondering why your users are suddenly getting worse responses two weeks after a “small” update. Our LLM evaluation framework covers how to build the test set and set release thresholds.

A/B Testing Prompts in Production

For prompt changes that pass offline evaluation but you’re not fully confident about, run a production A/B test. Route 10% of traffic to the new prompt and compare real user quality signals — engagement, thumbs up/down feedback, follow-up questions (a sign of incomplete answers), and support escalations.

Build this infrastructure once and it pays off every time you iterate on any prompt.

Use Structured Outputs Everywhere

When your prompt needs to return structured information, always specify a JSON schema and use your LLM provider’s structured output features (OpenAI’s response_format, Instructor, Outlines, etc.). Never parse free-form text when you don’t have to.

Structured outputs eliminate a whole class of failures and make your system dramatically more robust — you always know exactly what shape the data will be. Validate them at the API boundary too; our guide to designing AI-powered APIs shows how.

Separate System, User, and Context Prompts

Many applications mix all prompt content into one blob. Instead, maintain clear separation:

  • System prompt: Persona, constraints, output format — stable, rarely changes
  • Context prompt: Retrieved documents, user history — dynamic per-request
  • User message: The actual user input — untrusted, always sanitize (our AI threat model guide explains why)

This separation makes each piece easier to iterate on independently and easier to debug when something goes wrong.


Prompt engineering done right is software engineering, and versioned, tested prompts are one of the items on our AI production readiness checklist. If your team is struggling to maintain quality across a growing library of prompts, talk to Tensorplay about your prompt infrastructure.

Frequently asked questions

Answers to common questions about this topic.

How should prompts be stored in production?
In version control rather than hardcoded in application files, typically as files that record the template and its variables, the target model and parameters, a version and changelog, evaluation criteria, and example inputs and outputs.
How do you test a prompt change?
Run it against a regression suite that represents real inputs, using automated metrics suited to the task such as format checks, semantic similarity or an LLM judge, and block the change if the score drops by more than an agreed threshold.
When should you A/B test a prompt in production?
When a change passes offline evaluation but you are not fully confident in it. Route a small share of traffic, such as 10%, to the new prompt and compare real quality signals like feedback ratings, follow-up questions and support escalations.
Why separate system, context and user prompts?
Separation lets each part be iterated on and debugged independently, and it keeps untrusted user input clearly apart from your instructions, which reduces the risk of prompt injection.

Production AI Architecture

Turn prototypes into reliable, observable, and scalable AI systems.

Discuss your project

Model Optimization & Evaluation

Improve model quality, control costs, and establish repeatable evaluation systems.

Discuss your project