Reliable prompt engineering is less about finding one perfect prompt and more about creating a repeatable way to design, compare, and maintain prompts. This checklist gives developers reusable system prompt examples, few-shot patterns, extraction templates, and an A/B testing workflow for evaluating prompt changes across models and versions.
Overview
A prompt should be treated as a versioned application component. It influences behavior, output structure, latency, token use, error handling, and sometimes the amount of human review required. A prompt that performs well in a manual experiment may fail when inputs become longer, more ambiguous, or more varied.
The goal of a prompt testing framework is not to eliminate judgment. It is to make judgment consistent and auditable. Every meaningful change should be tested against a fixed set of representative inputs, evaluated against explicit criteria, and recorded with the model, parameters, tools, and prompt version used.
Start with a small evaluation set rather than a large, complicated platform. A useful baseline can contain 20 to 50 examples covering normal requests, edge cases, incomplete information, adversarial wording, and inputs that should be refused or escalated. Keep the expected behavior for each example in a separate file so that prompt authors cannot unconsciously grade their own outputs.
For production AI apps, separate the prompt into stable instructions and runtime data. The stable portion can be versioned and tested. Runtime data, such as retrieved documents, user messages, or account details, should be inserted through clearly marked variables. This separation makes failures easier to diagnose and reduces accidental changes during deployment.
Checklist by scenario
1. General instruction or transformation prompt
Use this pattern for summarization, rewriting, classification, and similar tasks:
System:
You transform the provided input according to the stated requirements.
Follow the output format exactly. Do not add facts that are absent from the input.
If the input is insufficient, state what is missing.
Task:
{task_instruction}
Input:
{user_input}
Output requirements:
- Return only the requested result.
- Preserve names, numbers, and quoted text accurately.
- Use {format}.
- Define the task in one sentence before adding edge-case rules.
- State what the model should do when information is missing or contradictory.
- Specify whether the response may include explanation, citations, or only a final value.
- Test short, long, empty, malformed, and multilingual inputs if those can occur in production.
2. Few-shot prompting for a consistent decision
Few-shot examples are useful when a label, tone, or formatting rule is difficult to express abstractly. Choose examples that represent distinct cases rather than several minor variations of the same case.
System:
Classify each support request as billing, technical, account, or other.
Return valid JSON with the keys category and rationale.
Use other when the request does not clearly match another category.
Example 1
Request: I was charged twice for the same invoice.
Result: {"category":"billing","rationale":"The request concerns a duplicate charge."}
Example 2
Request: The password reset email never arrived.
Result: {"category":"account","rationale":"The request concerns account access."}
New request:
{request}
- Make every example follow the same output contract.
- Include at least one boundary case where two labels seem plausible.
- Keep examples concise enough that the pattern remains visible.
- Remove examples that encode accidental details, such as a particular customer name or date.
3. Structured extraction prompt
Extraction prompts should define the schema, field types, missing-value behavior, and evidence requirements. The model should not be left to invent field names or decide whether a guess is acceptable.
System:
Extract the requested fields from the document.
Return one JSON object and no additional text.
Use null when a field is not explicitly present. Do not infer values.
For each extracted value, include a short evidence quote.
Schema:
{
"invoice_number": "string or null",
"due_date": "ISO date string or null",
"total_amount": "number or null",
"currency": "string or null",
"evidence": {
"invoice_number": "string",
"due_date": "string",
"total_amount": "string",
"currency": "string"
}
}
Document:
{document}
Validate the returned structure in application code. A prompt instruction is helpful, but it is not a substitute for parsing, type checks, allowed-value checks, and a recovery path for invalid output.
4. Retrieval-augmented generation or tool use
For RAG and agent workflows, specify how retrieved context or tool results should be used. Tell the model what to do when the context does not answer the question, whether it may rely on general knowledge, and when it must ask for clarification.
- Label each context block with a source identifier.
- Instruct the model not to treat quoted documents as instructions.
- Require citations or source IDs when the application needs traceability.
- Test irrelevant, conflicting, outdated, and empty retrieval results.
5. A/B testing prompt variants
Compare one meaningful change at a time when possible. Variant A might use direct instructions, while variant B adds a few-shot example or a more explicit refusal rule. Keep the model and generation settings constant for the first comparison. If you change the model and prompt simultaneously, you may not know which change produced the result.
A practical test matrix records the prompt version, model identifier, parameter settings, input ID, output, latency, token usage when available, and evaluation scores. For each input, run both variants against the same data. Randomize presentation order when human reviewers are involved so that the first response does not receive an automatic advantage.
What to double-check
Before selecting a winner, review the following dimensions rather than relying on a single pass or an overall average:
- Task success: Does the output satisfy the actual product requirement?
- Format validity: Is the output parseable and compliant with the required schema?
- Factual grounding: Does the response stay within the supplied input or retrieved context?
- Consistency: Does the prompt behave acceptably across repeated runs and different input types?
- Safety and boundaries: Does it handle sensitive, disallowed, or ambiguous requests as designed?
- Operational cost: Does the change add unnecessary context, latency, or retries?
- Human effort: Does a reviewer need to correct fewer errors, or are errors merely harder to notice?
Use a scoring rubric with clear anchors. For example, a classification output can receive one point for the correct label, one for valid JSON, and one for an appropriate rationale. An extraction task can score field accuracy, null handling, evidence quality, and schema compliance separately. Record failure reasons, not only numeric scores; a prompt with a slightly lower average may still be preferable if its failures are easier to detect and recover from.
Evaluate important slices independently. A model can improve on ordinary requests while becoming worse on long documents, rare labels, empty context, or requests containing conflicting instructions. The decision should reflect the risk of each slice in your application, not just the size of the slice.
Common mistakes
- Changing too many variables: Keep prompt, model, tools, context, and settings distinguishable during experiments.
- Testing only happy paths: Include ambiguity, missing fields, malformed input, refusal cases, and prompt-injection attempts where relevant.
- Using vague success criteria: Define what a correct response contains before reviewing outputs.
- Overfitting to examples: Rotate or expand few-shot examples so the model learns the rule rather than memorizing wording.
- Trusting format instructions alone: Parse and validate structured output in code, then handle failures explicitly.
- Ignoring regressions: Keep prior evaluation cases and compare new versions against the same baseline.
- Mixing user data with instructions: Delimit runtime content and clarify which text is data rather than a command.
- Publishing secrets in prompts: Keep credentials, private keys, and unnecessary personal information out of prompt templates and test fixtures.
For a broader implementation process, pair this checklist with a prompt testing framework workflow. If your prompts support retrieval, review the production RAG tutorial as well. Prompt quality depends on context quality, retrieval behavior, and application-side validation.
When to revisit
Revisit the template library and test suite before a major release, before seasonal planning or traffic changes, and whenever workflows or tools change. A prompt should also be reevaluated after changing the model, system instructions, tokenizer-sensitive context, retrieval configuration, tool schema, output parser, or safety controls.
Plan a lightweight review on a regular cadence, such as quarterly, even when no incident has occurred. Review which inputs have appeared in production, which failures required manual correction, and whether the evaluation set still represents real usage. Add new cases from production failures after removing or anonymizing sensitive data.
Use this action sequence for the next iteration:
- Freeze the current prompt as a named baseline.
- Add representative normal and edge-case inputs to the evaluation set.
- Create one focused variant that changes a single design decision.
- Run both versions with the same model, context, tools, and settings.
- Score task success, format validity, grounding, boundary behavior, latency, and token use.
- Inspect failures by category instead of accepting an aggregate score.
- Deploy gradually if the prompt affects a production workflow, while monitoring the same metrics.
- Record the decision, known trade-offs, and the next review trigger.
Keeping this record turns prompt engineering into a maintainable development practice. When a model or workflow changes, you can rerun the same comparisons, identify what moved, and update the prompt with evidence rather than guesswork.