Prompt engineering techniques that work
What prompt engineering techniques actually work in production?
TL;DR
Treat a prompt like a spec for a capable new colleague: be clear and specific about the task, the audience, the constraints and the output format. The techniques that reliably help: a focused system prompt with role and rules, context first and the question last, clear delimiters (XML tags or headings) between instructions and data, few-shot examples of the exact output you want, asking the model to reason before answering on complex tasks, structured output (JSON schema or tool calling) for machine-read results, and breaking big tasks into a chain of smaller prompts.
Key points
- Say what to do, not only what not to do, and explain why a rule exists; models follow reasons better than bare commands.
- Few-shot examples should be diverse and match the real input distribution; models copy their quirks.
- Wrap untrusted content in tags (
<document>...</document>) and tell the model to treat it as data, which also helps against prompt injection. - Give an escape hatch: "If the information isn't in the documents, say so."
- For classification, list the labels and define edge cases.
- Prompts are code: version them, test them against an eval set, and re-test when you change the model.
- Don't over-engineer: modern models need less trickery than older ones; clarity beats "magic words".
Example
System: You are a support assistant for Acme's billing product.
Answer using only the documents provided. If they don't contain the answer, say
"I don't have that information" and suggest contacting support.
<documents>
{retrieved_chunks}
</documents>
Answer the customer's question below in 2–4 sentences, in the customer's language.
Return JSON: {"answer": string, "source_ids": string[]}
<question>{question}</question>Common follow-ups
- What is chain-of-thought prompting? Asking the model to work step by step before giving the answer. It improves multi-step reasoning; reasoning models do it internally.
- How do you know a prompt change helped? Run both versions on the same eval set and compare scores, not a few hand-picked examples.
What interviewers look for
Tip
Concrete techniques with reasons, structured outputs for reliability, and treating prompts as tested, versioned artifacts.
- Red flag: iterating on prompts by eyeballing two or three outputs.