Artificial Intelligence · Explainer

Prompt engineering: techniques with real applications

Writing good requests for a language model is less a trick and more a method: clarity, examples, structure and testing. See what official sources and research say and how to apply it day to day.

Responsible editor:
Daniel Ferreira

Published · 8 min read

Originally published in Brazilian Portuguese.

Translated from the Portuguese original with AI assistance.

Also available in: Português

Key points

  • Before adjusting the prompt, define what a good answer is and how you will check it.
  • Clear instructions, varied examples and a structure that separates instructions from data are the techniques official guides recommend most.
  • Prompts do not solve everything: cost, latency, outdated facts and prompt injection call for other solutions.

You have probably asked an AI assistant a question, received a generic answer and thought: “that’s not what I meant.” Most of the time, the problem is not the model. It is the request.

Prompt engineering is the work of writing, organizing and testing the instructions you send to a language model so that it produces the result you need. The prompt is the input text: the question, the instructions, the examples and the data that accompany the request.

This article brings together the techniques that appear consistently in the official guides of three companies that develop models (Anthropic, OpenAI and Google) and in well-known academic research. The prompt examples were written by the newsroom to illustrate each technique. If you want to understand first what a language model is, start with what LLMs are.

Before the prompt: define what a good answer is

Anthropic’s prompt engineering guide starts from a simple premise. Before improving a prompt, you need three things: clear success criteria, a way to test against those criteria and a first draft. Anthropic’s overview also notes that not every problem is solved with a prompt. Latency and cost, for example, sometimes improve more by switching models.

OpenAI’s documentation takes the same line for those using models in production: pin the model version you use and keep tests (so-called evals, or evaluations) to measure the prompt’s behavior when you change it or switch models.

In practice, this means writing, first of all, sentences such as “the answer must fit in five lines,” “it must cite the contract clause number” or “it must not invent deadlines.” Without that, you cannot tell whether a change to the prompt improved or worsened the result. The topic is covered in depth in how to evaluate AI responses.

Clear instructions with context

The most basic technique is also the most cited: say exactly what you want. Anthropic’s guide suggests thinking of the model as a new, very capable employee who does not know your norms or your workflow. The golden rule proposed there is to show the prompt to a colleague with no context on the task: if they would be confused, the model will be too (Anthropic, best practices).

The same guide recommends explaining the reason behind each instruction. Saying why something matters helps the model understand the goal and get it right in cases you did not foresee.

Google’s Gemini prompting guide (updated September 17, 2026) adds two elements: constraints (what the model should or should not do, such as a length limit) and response format (table, list, paragraph).

See the difference in practice.

Example of a vague prompt (created by the newsroom):

Summarize this email.

Example of a clear prompt (created by the newsroom):

You will read an email from a customer. Summarize it in at most three sentences,
so the support team understands the problem without opening the original email.
State: what the problem is, what the customer has already tried and what they are asking for.
If any of this information is not in the email, write "not provided".

The second prompt defines audience, goal, length, structure and what to do when information is missing. This last instruction is important: it gives the model an honest way out instead of encouraging it to fill gaps, one of the paths to AI hallucinations.

Examples: zero-shot and few-shot

A prompt without examples is called zero-shot. A prompt with a few examples of input and expected output is called few-shot (or multishot).

The idea gained traction with the paper that introduced GPT-3 in 2020. The authors showed that the model could perform new tasks with only demonstrations written in the request text itself, without updating the model’s weights (Brown et al., 2020).

Today all three official guides recommend examples:

  • Anthropic says examples are among the most reliable ways to control format, tone and structure, and suggests three to five relevant, varied examples (Anthropic).
  • OpenAI advises showing “a diverse range of possible inputs” with the desired outputs (OpenAI).
  • Google recommends always including examples, but warns that too many examples can make the model copy the pattern excessively, and that all of them should have the same structure (Google).

Example of a few-shot prompt to classify messages (created by the newsroom):

Classify each customer message as: BILLING, DELIVERY or OTHER.
Reply with the category only.

Message: "I was charged twice on my card."
Category: BILLING

Message: "The order says delivered, but I received nothing."
Category: DELIVERY

Message: "Do you have a physical store in Recife?"
Category: OTHER

Message: "{customer message}"
Category:

Note that the examples cover all three categories. If they were all about billing, the model could learn a bias you did not intend to teach.

Structure: separate instructions, data and format

When the prompt mixes instructions, documents and examples, the model may confuse what is an order and what is working material. The recommended solution is to mark each part.

Anthropic suggests XML-style tags, such as <instructions> and <document>, to reduce misinterpretation. OpenAI suggests Markdown headings and XML tags to delimit where reference content begins and ends, and proposes an order: identity, instructions, examples and context. Google also recommends consistent delimiters.

Example of a structured prompt (created by the newsroom):

<instructions>
Answer the question using only the rules below.
Cite the item number that supports the answer.
If the rules do not cover the subject, say so.
</instructions>

<rules>
{text of the condominium rules}
</rules>

<question>
Can I do renovation work in the apartment on Saturday afternoon?
</question>

For long texts, Anthropic recommends placing documents at the beginning and the question at the end. According to the company, in internal tests, questions placed at the end improved response quality by up to 30% on complex inputs with multiple documents. This is the manufacturer’s own figure, not an independent study. Why position matters is explained in context, memory and information retrieval in AI.

Step-by-step reasoning

In 2022, Jason Wei and co-authors described the chain-of-thought technique: including in the prompt examples that show intermediate reasoning steps, not just the final answer. According to the paper, this improved performance on arithmetic, commonsense and symbolic reasoning problems, but the effect appeared in sufficiently large models (Wei et al., 2022).

A few months later, another group showed that simply adding the phrase “Let’s think step by step” was enough to obtain gains without examples. With one of the models tested, accuracy on a set of math problems (MultiArith) rose from 17.7% to 78.7% (Kojima et al., 2022).

There is an important caveat for 2026. Many current models have their own reasoning mode, enabled by a parameter. Anthropic’s documentation (consulted on October 8, 2026) recommends using this mode on the company’s latest models, instead of asking the model to write out its reasoning in the text, and treats the manual “think step by step” request as an alternative when reasoning mode is off. OpenAI notes that its reasoning models usually work well with high-level goals, while the others need more explicit instructions.

In the newsroom’s assessment, the lasting lesson is not the magic phrase but the principle: multi-step tasks become more reliable when the model has room to solve them in parts.

Split the task into steps

When a task is large, it is worth breaking it into several prompts, one per step. Google’s guide calls this breaking down the prompt; Anthropic calls it prompt chaining.

The most common pattern described by Anthropic is self-correction: generate a draft, ask the model to review the draft against defined criteria and then ask for the final version. Each step is a separate call, which makes it possible to record and check the intermediate result.

Example of a three-step chain (created by the newsroom):

  1. “List the five main points of this quarterly report, each with its page number.”
  2. “Check each point on the list against the report. Flag those not supported by the text.”
  3. “Using the confirmed points, write a one-paragraph summary for the board.”

The same reasoning, taken further, is the basis of AI agents, which plan steps and use tools.

Role and tone

Defining a role (“you are a legal reviewer,” “you are a high school teacher”) is another common technique. Anthropic recommends doing this in the system prompt, the background instruction the application sends before the conversation, and says even one sentence makes a difference. OpenAI separates developer instructions, which take priority, from user messages.

The role adjusts vocabulary and focus. It does not give the model knowledge it does not have. Asking the AI to “be a doctor” does not turn the answer into a diagnosis.

Real applications: three scenarios

The scenarios below combine the previous techniques. They are illustrative, put together by the newsroom.

Customer service. A store wants standardized answers to questions about returns. The system prompt defines role and tone, the returns policy goes between tags, three examples show the answer format and an instruction says to escalate to a human when the case is not covered.

Document analysis. A law firm wants to extract dates and amounts from contracts. The contract comes first, the instruction at the end, and the output format is a table with a column for the exact passage that justifies each value. Asking for the passage makes human review easier.

Content production. A marketing team wants to adapt a technical text for social media. A three-step chain extracts the facts, generates short versions and, finally, compares each version with the extracted facts to discard exaggerations.

In all cases, someone needs to check a sample of the answers before putting the process into use.

Limits and risks

Prompt engineering improves how you ask. It does not change what the model knows. If the information was not in the training data or is outdated, the solution is to provide the content in the request itself or use document retrieval, as explained in the article on RAG. Every extra word also consumes tokens, which has a cost.

The most serious risk is prompt injection: when text that enters the request (an email, a web page, a document) contains hidden instructions that the model ends up following. A 2023 study demonstrated attacks of this kind, called indirect injection, against real applications, and argued that these systems blur the line between data and instructions. The authors also stated that, at the time, effective defenses were lacking (Greshake et al., 2023).

Separating instructions and data with tags helps organize the request, but it is not a security barrier. If the application can send emails, make payments or delete files, permissions need to be limited outside the prompt, with human confirmation for sensitive actions.

Key takeaways

  • Start with the success criterion: without knowing what a good answer is, you cannot measure whether the prompt improved.
  • The techniques with the most support in official guides are clear instructions with context, varied examples, a structure that separates instructions from data and splitting large tasks into steps.
  • Step-by-step reasoning is grounded in research, but with current models it is usually better to use the native reasoning mode, when available.
  • Prompts do not replace up-to-date data, testing or security controls. Treat text coming from outside as data, never as an order.

Sources

  1. Prompt engineering overview, Anthropic (Claude Developer Platform). Accessed October 8, 2026
  2. Prompting best practices, Anthropic (Claude Developer Platform). Accessed October 8, 2026
  3. Prompt engineering, OpenAI (API documentation). Accessed October 8, 2026
  4. Prompt design strategies | Gemini API, Google AI for Developers. Published September 17, 2026 · Accessed October 8, 2026
  5. Language Models are Few-Shot Learners, arXiv (Brown et al.). Published May 28, 2020 · Accessed October 8, 2026
  6. Chain-of-Thought Prompting Elicits Reasoning in Large Language Models, arXiv (Wei, Wang, Schuurmans, Bosma, Ichter, Xia, Chi, Le, Zhou). Published January 28, 2022 · Accessed October 8, 2026
  7. Large Language Models are Zero-Shot Reasoners, arXiv (Kojima, Gu, Reid, Matsuo, Iwasawa). Published May 24, 2022 · Accessed October 8, 2026
  8. Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection, arXiv (Greshake, Abdelnabi, Mishra, Endres, Holz, Fritz). Published February 23, 2023 · Accessed October 8, 2026

Related reading

Artificial Intelligence · Explainer

How to automate business processes with AI

Automating with AI starts with the process, not the tool. This guide shows how to choose what to automate, where AI makes sense and how to keep control over the result.

Artificial Intelligence · Explainer

How to build a chatbot with your own documents

An assistant that answers based on your organization's manuals, contracts and policies is one of the most common uses of AI. This roadmap shows the decisions at each stage and where projects usually go wrong.