Skip to main content
← Guides

Anatomy of a prompt

Prompts & workflows · Prompt guide

Break a prompt into roles, instructions, delimiters, examples, and reasoning — what each block does, where it goes, and how it fails.

Prompt effect has not been tested.

A prompt is a re-runnable template, not a promise of results. Changing the model, version or input can change the outcome. Use the checkpoints on this page to verify it yourself, and treat the official sources as evidence of mechanism rather than a guarantee of effect.

What this guide covers

Prompt anatomy means breaking a prompt into blocks with clear responsibilities. Roles, instructions, delimiters, examples, reasoning — each block solves a different problem. The Prompt Report survey organizes 58 prompting techniques and 33 vocabulary terms (the paper's own count). The names proliferate, but the skeleton is much the same. This guide covers how to assemble it and where each block goes. We have not run hands-on tests of these techniques; mechanisms and conclusions come from official docs and papers.

Message roles: the conversation skeleton

What the API receives is not one blob of text but a sequence of messages with roles. Anthropic's official tutorial uses the Messages API as its example: messages is an array of alternating user and assistant turns, and the first message must be user. system is a separate parameter for task background, rules, and guidelines — kept apart from the conversation. max_tokens is a hard ceiling: generation stops there, possibly mid-sentence.

OpenAI's GPT-4.1 guide organizes by role the same way: behavioral rules go in the system prompt, tools go through the API's tools field. The official advice is against hand-injecting tool descriptions into the prompt and writing your own parser. Get the roles wrong and no later block sits on a stable base.

Instruction blocks and delimiters

OpenAI's starting skeleton, add or remove sections as needed: role and objective → instructions (with sub-categories) → reasoning steps → output format → examples → context → final instructions.

Delimiters decide whether the model can tell the blocks apart. The GPT-4.1 guide's advice: start with Markdown headers; XML suits precise wrapping, nesting, and attaching metadata; JSON is more verbose and needs escaping. When feeding many documents in long context, OpenAI's own testing found XML performed well and JSON notably poorly. That is a vendor-reported test result — re-verify when you change models.

Examples and reasoning blocks

The examples block demonstrates instead of describing. The Prompt Report classifies this family as few-shot: give input-output pairs and let the model follow suit. No examples is zero-shot; one example is one-shot. The GPT-4.1 guide's reminder: key behaviors shown in examples must also be stated in the rules — keep the two aligned.

The reasoning block makes the model think before answering. GPT-4.1 is not a reasoning model, but a prompt can induce step-by-step planning. The cost is stated in the official guide: more output tokens, higher latency. Start with a simple "think step by step", then add concrete strategies based on failure cases.

Placement and order

What the blocks say matters; where they sit matters too. The GPT-4.1 guide's long-context experimental findings: instructions at both the beginning and the end of the context beat instructions at only one end; if placed only once, above the context beats below it. When instructions conflict, GPT-4.1 tends to follow the one closer to the end. The closing instruction is not a courtesy — it is the last corrective.

Failure modes

  1. Literal obedience: demand "call a tool before answering" and the model may fabricate arguments when information is missing. The official fix: add "ask the user when you lack information".
  2. Example parroting: given sample phrases, the model may repeat them verbatim. Explicitly require variation.
  3. Improvisation: without constraints the model adds explanations and extra formatting. Rein it in with instructions and examples.
  4. Migration breakage: after a model switch, implicit rules the old model used to infer stop working — spell them out.

The official caveat: no advice is one-size-fits-all. Prompt engineering is an empirical discipline; pair it with evals and keep iterating.

Sources

Verified 2026-11-07; all three fetched directly with HTTP 200. The OpenAI and Anthropic doc sites were unreachable from this network; official content was taken from raw files in both vendors' official repositories.

Sources

SourceURL
OpenAI Cookbook · GPT-4.1 Prompting Guide (official repo raw file, direct fetch 200 on 2026-11-07)https://raw.githubusercontent.com/openai/openai-cookbook/main/examples/gpt4-1_prompting_guide.ipynb
Anthropic official tutorial · Basic Prompt Structure (official repo raw file, direct fetch 200 on 2026-11-07)https://raw.githubusercontent.com/anthropics/courses/master/prompt_engineering_interactive_tutorial/Anthropic%201P/01_Basic_Prompt_Structure.ipynb
The Prompt Report paper (arXiv 2406.06608, abstract page direct-fetched 2026-11-07)https://arxiv.org/abs/2406.06608

Source snapshot: 2026-11-07; item-specific rechecks and their scope are recorded in the text or source notes. Features and terms may change; check the original sources before use.