Level : Intermediate

Prompt engineering: the techniques that actually work

By The Info Agent IA editorial team ·

A hand lays out translucent cards on a glowing table, linked by threads of light to a central sphere.

Prompt engineering is the craft of phrasing a request to an AI model so that you reliably get the answer you need. The techniques that actually work have nothing to do with magic phrases: they come down to giving the model context, a goal, examples and a clear format, then checking the output against real cases.

What prompt engineering means today

A prompt is the text you send to the model: instructions, context, documents, examples and the question itself. Prompt engineering is the practice of designing and improving it methodically. With early models, people hunted for phrasings that “unlocked” better answers. With today’s large models the challenge has moved: they almost always understand what you say, but they cannot guess what you leave out.

Model providers now publish detailed guides. This article draws on two of them, opened on 22 October 2026: Anthropic’s prompt engineering overview and its best practices, and OpenAI’s prompt engineering guide. Their advice overlaps heavily, which is useful information in itself.

The techniques at a glance

TechniqueWhen to use itWhat it fixes
Clear instructions and contextAlwaysGeneric or off-target answers
Explaining the whyRules on form or substanceRules applied the wrong way
Role and system promptApps, recurring assistantsWrong tone or level
Examples (few-shot)Specific format or styleInconsistent outputs
Structuring tagsLong prompts, several documentsInstructions mixed up with data
Explicit reasoningMulti-step problemsLogic errors
Enforced output formatAutomated processingAnswers a program cannot parse
Documents first, question lastVery long contextLost information
Chaining and self-correctionComplex tasksUnreviewed drafts
Tests and evaluationsBefore going to productionSilent regressions

1. Be clear and specific, and give context

This is the technique with the biggest payoff. Anthropic recommends treating the model like a brilliant but new employee who knows nothing about your company, your audience or your habits. Its test: show your prompt to a colleague who lacks the context; if they would be lost, so will the model.

In practice, spell out:

  • the goal: what the answer is for and who will read it;
  • the context: what the model cannot know (your product, your constraints, what has already been tried);
  • the success criteria: length, level of detail, what must be included;
  • the steps, numbered, when order matters.

Compare “Write a follow-up email” with “Write a five-line follow-up email to a client whose invoice is thirty days overdue; friendly but firm; suggest a call this week; no apologies”. The second version contains no trick at all, only the information you already had in mind.

2. Explain why an instruction matters

A rule without a reason gets applied literally, sometimes in the wrong way. A rule with a reason gets generalized sensibly. Anthropic’s example is telling: instead of “never use ellipses”, explain that the answer will be read aloud by a text-to-speech engine that cannot pronounce them. The model then understands it should also avoid other symbols that do not work when spoken.

In the same spirit, say what to do rather than what not to do. “Write in flowing paragraphs” works better than “do not use bullet points”. And write your prompt in the style you want back: a prompt full of Markdown invites a Markdown answer.

3. Assign a role and craft the system prompt

The system prompt is the framing message placed before the conversation. It is where you define a role (“You are an employment lawyer answering HR managers at small companies”), the tone, the limits and the default format. Both providers recommend this practice.

OpenAI adds a point that matters for anyone building an application: developer messages take priority over user messages. Its documentation compares the system prompt to a function and the user’s messages to its arguments. Put lasting rules on the system side and let the user supply the request of the moment.

Check yourself Your internal assistant answers correctly, but in a tone too casual for your clients. Where should you fix it: in every message, or somewhere else?

In the system prompt. Tone is a lasting rule that should apply to every conversation: putting it in the framing avoids repeating it and gives it priority. Add the reason (“answers are sent to clients as they are”) and, if possible, a short example of the tone you expect.

4. Show examples (few-shot)

Showing often beats explaining. Few-shot prompting means including a few examples of inputs and expected outputs. The idea was popularized by the GPT-3 research paper published in May 2020 (arXiv 2005.14165), which showed that a large model could pick up a task from a handful of demonstrations placed in the prompt.

Anthropic’s best practices, consulted on 22 October 2026, recommend three to five examples, chosen to be:

  • relevant: close to your real cases;
  • diverse: covering edge cases, so the model does not copy an unintended detail;
  • clearly delimited: wrapped in dedicated tags so they are not confused with the request.

OpenAI makes the same recommendation. A good warning sign: if every answer has the same length as your single example, the model is imitating it too closely.

5. Structure with tags

As soon as a prompt mixes instructions, documents and examples, separate them clearly. Anthropic recommends XML-style tags; OpenAI also accepts Markdown headings. What matters is consistency: explicit names, reused from one prompt to the next.

<instructions>
Summarize the contract below for a procurement manager.
Five bullets at most, risks first.
</instructions>

<contract>
[contract text]
</contract>

<format>
One closing line: sign, negotiate or decline.
</format>

This structure keeps the model from mistaking a sentence in the document for an instruction. It also reduces, without eliminating, exposure to prompt injection when the document comes from an outside source.

6. Get the model to reason

For multi-step problems (calculations, analyses, decisions against criteria), asking the model to think before answering improves results. This is chain of thought, described in a research paper from January 2022 (arXiv 2201.11903).

Practice has shifted with reasoning models, which think on their own before answering. OpenAI notes that they work best with high-level guidance describing the goal, whereas classic models need very precise, step-by-step instructions. With a reasoning model, dictating every step is often unnecessary or even counterproductive: give it the goal and the criteria.

7. Enforce the output format

If a program will read the answer, describe the format precisely: fields, types, allowed values. For a reliable integration, prefer the structured outputs offered by APIs, which constrain the model to follow a schema.

One caveat from Anthropic’s documentation: prefilling, which meant writing the start of the answer on the model’s behalf, is no longer supported from Claude 4.6 models onward. Structured outputs replace it when you need to force a format.

8. Handle long contexts

With ever larger context windows, it is tempting to paste everything into the prompt. Order matters. For long inputs, Anthropic recommends putting documents at the top and the question at the end: according to its best practices consulted on 22 October 2026, this can improve response quality by up to 30 percent in its tests, for inputs of roughly 20,000 tokens or more.

Two further tips:

  • label each document with tags giving its source and date;
  • ask the model to extract the relevant quotes first, then answer from them: this cuts down on hallucinations, that is, made-up claims.

9. Chain steps and ask for a review

A complex task is better split into several calls than crammed into one giant prompt. Anthropic describes a simple self-correction pattern: a first call produces a draft, a second reviews it against precise criteria, a third improves it. Each step is easier to test and fix on its own.

This is also the basic principle behind agents: a loop of steps, tools and checks. If you want to give your model access to your own data or functions, see our tutorial on how to build an MCP server.

10. Test, measure and pin the model version

A prompt that works on three tries can fail on the fourth. Both providers stress evaluation: build a set of representative cases with expected answers, and run it every time you change the prompt. Our article on evaluating an AI agent walks through the method.

OpenAI also recommends pinning production apps to a specific model snapshot, because behavior can change from one version to the next. Anthropic makes a similar point: any model-specific technique should be rechecked against your own evaluations whenever you switch models.

Finally, for high-volume applications, put stable content (instructions, examples, reference documents) at the start of the prompt. OpenAI points out that this lets you benefit from prompt caching, which lowers cost and latency. To estimate the bill, see our guide to AI API pricing.

Ideas that sound good but are not

A few common habits add little or even backfire:

  • Threats and rewards (“this is vital for my career”): they are not among the techniques these guides recommend; a clear, justified instruction is enough.
  • Capital letters everywhere: in our view, shouting a rule is no substitute for explaining it. A justified instruction is better understood and better generalized than a capitalized “NEVER”.
  • The catch-all prompt: piling up every possible rule buries the important ones. A short, tested prompt that you enrich based on observed errors works better.
  • Copying a prompt from one model to another without retesting: each model family has its quirks.

Putting it into practice

A simple method is enough to improve quickly:

  1. Write a first draft with goal, context, instructions and format, without aiming for perfection.
  2. Gather a few real cases, including hard or ambiguous ones, and note the answer you expect for each.
  3. Run the prompt on every case and sort the errors: missing information, format not respected, faulty reasoning, wrong tone.
  4. Fix one thing at a time, then rerun all the cases to make sure nothing else broke.

This discipline matters more than any trick: it turns an impression (“it seems better”) into something you can verify.

To avoid starting from a blank page, the site’s prompt generator helps you structure role, context, instructions and format. Then test the result on an assistant such as Claude or another model, across several real cases. And if your goal goes beyond a conversation, our guide to building an AI agent shows how these prompts become the core of an agent.

Frequently asked questions

Is prompt engineering still useful with recent models?

Yes, but its nature has changed. Recent models handle vague requests better, which makes magic phrases pointless. Providing context, a goal, examples and an output format is still what separates an average answer from a usable one, especially inside an application or an agent.

Should prompts be written in English?

Not necessarily. Today's large models handle many languages well. Write in the language you want the answer in and test: if a given model does better with English instructions on your specific task, your own trials will show it.

How many examples should a prompt include?

Anthropic's documentation, consulted on 22 October 2026, recommends three to five relevant, varied examples for best results. Examples that are too similar push the model to copy an unintended detail, such as length or a turn of phrase.

What is the difference between a system prompt and a user message?

The system prompt sets the lasting frame: role, rules, tone, format. The user message carries the request of the moment. OpenAI notes that developer instructions take priority over user instructions, much like a function and its arguments.

Go further