For the complete documentation index, see llms.txt. Every page on this site is also served as Markdown: append `.md` to any URL, or send `Accept: text/markdown`.
Attensira Logo
Attensira
AI Glossary

Prompt engineering

Structuring the text given to a language model so its output meets a stated success criterion — and, for anyone measuring AI answers, the variable that decides what the measurement is of.

Karl-Gustav KallasmaaKarl-Gustav Kallasmaa, Founder & CEOLast updated

Prompt engineering is the practice of structuring the text sent to a language model — instructions, context, examples, formatting — so that its output meets a success criterion you defined in advance. It is an empirical activity, not a stylistic one: without a criterion and a way to test against it, a prompt change cannot be evaluated, because the same prompt run twice does not return the same text.

Anthropic's prompt engineering overview makes that precondition explicit. Its guide assumes you already have a clear definition of the success criteria for your use case, some way to test empirically against those criteria, and a first draft prompt you want to improve. It also says plainly that not every failing evaluation is best solved by prompt engineering — latency and cost, for instance, are often fixed more cheaply by selecting a different model.

The techniques operators actually document

The published guidance from the two largest providers converges, which is useful, because it means these are properties of the systems rather than folklore.

  • Be explicit and sequential. Anthropic recommends giving instructions as numbered lists or bullet points when the order or completeness of steps matters.
  • Use examples, and few of them well. Anthropic calls examples one of the most reliable ways to steer output format, tone and structure, and recommends 3-5 examples that are relevant, diverse and structured. OpenAI's prompting guide gives the same instinct: include a handful of input/output examples showing a diverse range of possible inputs with the desired outputs.
  • Delimit the parts. Anthropic recommends XML tags — <instructions>, <context>, <input> — so a prompt mixing instructions, context, examples and variable input is parsed unambiguously. OpenAI recommends Markdown headers and lists, or XML tags, to delineate where one piece of content begins and ends.
  • Put long inputs first. For inputs of 20k+ tokens, Anthropic advises placing longform documents near the top of the prompt, above the query and instructions, and wrapping each document in <document> tags with <document_content> and <source> subtags.
  • Order for caching. OpenAI advises keeping content you expect to reuse at the beginning of the prompt, for cost and latency savings.
  • Separate roles. OpenAI describes developer, user and assistant messages as carrying differing levels of authority, so where an instruction sits changes how strongly it binds.
  • Chain when you need to inspect the middle. Anthropic notes that current models handle most multistep reasoning internally, and that explicit chaining is still worth it when you need to log or branch on an intermediate output — most commonly draft, review against criteria, refine.

Why this term belongs in a GEO glossary

Because the prompt is the measurement instrument, and instruments are not neutral.

An AI-visibility number is a count over a set of prompts someone wrote. Change the wording — "best CRM for startups" versus "CRM tools comparison" — and the retrieval step matches different documents, so a different set of brands gets named. The reported rate moved; nothing about the brands did. This is why two tools can report different figures for the same brand in the same week without either of them being wrong, and why a prompt set is the first thing to inspect when a number surprises you.

The practical consequence is that a prompt set should be treated like a schema: written down, versioned, and changed deliberately. Editing prompts mid-window breaks the comparison you were trying to make, and no statistical test downstream can repair it, because the denominator changed meaning rather than size.

Failure modes

  • Tuning without an eval. Models are non-deterministic. One better-looking output after a prompt change is a single draw, not evidence. Fix the criterion first, then measure over repeats.
  • Prompting around a retrieval failure. If the document was never fetched into the context window, rewording the question cannot surface it. That is a retrieval problem, and it is solved upstream.
  • Overstuffing the window. More context is not free: accuracy and recall degrade as a window fills, so an indiscriminately packed prompt can perform worse than a selective one, even when everything fits within the token budget.
  • Confusing compliance with correctness. A well-structured prompt makes output well-formed. It does not make it true — a confidently formatted hallucination is the standard result of a good prompt over bad context.
  • Silently changing the prompt set. The most common measurement error in this field is not a bad prompt. It is a prompt edited between two readings that are then compared to each other.

Frequently asked questions

What has to exist before tuning a prompt?

A success criterion and a way to test against it empirically. Anthropic's guide assumes both.

How many few-shot examples?

Anthropic documents 3-5, structured in <example> tags.

Where do long documents go?

Near the top, above the query and instructions, for inputs of 20k+ tokens.

Does a better prompt make an answer true?

No. Structure controls form. Truth depends on what was retrieved and whether the model read it correctly.

Frequently Asked Questions about Prompt engineering

Anthropic's prompt engineering overview states the guide assumes you already have a clear definition of the success criteria for your use case, some way to test empirically against those criteria, and a first draft prompt to improve. Without the second one, changes to a prompt are opinions, because model output varies between runs and you have nothing to compare against.

Anthropic's prompting best practices recommends including 3-5 examples for best results, wrapped in <example> tags (multiple examples in <examples> tags) so the model can distinguish them from instructions, and says they should be relevant, diverse and structured.

At the top. Anthropic's guidance for long context prompting — which it scopes to inputs of 20k+ tokens — is to place long documents and inputs near the top of the prompt, above the query, instructions and examples, and states this improves performance across all models.

No. Anthropic's overview says explicitly that not every success criterion or failing eval is best solved by prompt engineering, and gives latency and cost as things often fixed more easily by choosing a different model. Retrieval problems are the other common case: if the right document was never fetched, no rewording of the question recovers it.

Because the prompt is the measurement instrument. A mention rate is computed over a prompt set somebody wrote, and rewording a prompt changes which documents get retrieved and therefore who gets named. Two tools reporting different numbers for the same brand are usually running different prompts, not disagreeing about reality.
Share this term

Track how your brand shows up in ChatGPT, Claude, and Google AI

Attensira monitors your visibility across AI search platforms so you know exactly when and how you're being recommended.