AI news
AI model reviews
AI tools
How-to guides
Our staffAboutContact

AI prompt engineering in 2026: 6 steps beyond the basics, with examples

AI prompt engineering in 6 steps: success criteria, system prompts, few-shot examples, reasoning, structured output and testing, with a worked example.

A person typing on a laptop

Here is the short version. AI prompt engineering is the practice of designing, testing and refining the instructions you give a large language model so it produces the output you need reliably, not just once. In practice that means six habits: define what "good" looks like, write standing instructions, show examples, decide how much reasoning the task needs, lock down the output format, and measure every change against a test set.

This guide goes one level above everyday prompting. If you want the basics first (roles, context, being specific), start with our guide on how to write better AI prompts for ChatGPT, Claude and Gemini. We compiled this one from the official prompting documentation published by Anthropic, OpenAI and Google, checked as of late October 2026. Nobody at the site ran hands-on tests for this piece.

What you need before you start

  • One repeatable task. It pays off when you run the same request many times, such as classifying tickets or extracting invoice fields.
  • Access to a model. A chat app works for steps 1 to 4. Steps 5 and 6 are easier through an API or a playground. Our list of free AI models covers options that cost nothing to try.
  • 10 to 50 real inputs. Past emails, documents or questions you already know the right answer for. These become your test set.
  • A spreadsheet. One row per test input, one column per prompt version.

For the mental model of how a model reads text, see our explainer on what an LLM is.

Step 1: Define success and build a small test set

This step makes the rest measurable. Anthropic's prompt engineering overview assumes you already have clear success criteria and a way to test against them, and tells you to set those up first if you do not.

Anthropic's guide to building evaluations says criteria should be specific, measurable, achievable and relevant. "Good summaries" is not a criterion. "Under 80 words, names the customer's problem, no invented facts" is. The guide also says to include edge cases, and that "More questions with slightly lower signal automated grading is better than fewer questions with high-quality human hand-graded evals."

Example criteria sheet:

Task: label each support email as billing, bug, feature request, account access or other.

Pass: label matches the human label exactly.

Target: at least 36 of 40 test emails correct (90%).

Edge cases included: 4 emails that mention two topics, 3 empty or one-line emails, 2 emails in Spanish.

Step 2: Write a system prompt for standing instructions

A system prompt holds the instructions that apply to every request: who the model is acting as, the rules it follows and the context it always needs. Anthropic's docs say setting a role in the system prompt focuses the model's behaviour and tone, and that "Even a single sentence makes a difference." Google describes Gemini's system instructions as a preamble the model sees before any instructions from the end user.

Keep three things apart: the standing rules (system prompt), the variable input (user message) and any reference material. Anthropic recommends wrapping each type of content in its own XML-style tag, such as <instructions>, <context> and <input>, so the model does not confuse them. For long documents, the same page advises putting the material at the top and your question at the end.

Copy-paste system prompt:

You are a support triage assistant for a software company. Your job is to read one customer email and assign exactly one label.

<labels>billing, bug, feature_request, account_access, other</labels>

<rules>If an email covers two topics, choose the one the customer asks you to act on. If the email is empty or unclear, use other. The labels feed an automated routing system, so never invent a new label.</rules>

The last rule explains why; Anthropic's guidance says models generalise from the reason behind an instruction.

Step 3: Add few-shot examples

Few-shot prompting means showing the model a handful of input and output pairs before the real input. It is the fastest fix when the format or judgement you want is hard to describe in words. Anthropic's best-practices page says a few well-crafted examples improve accuracy and consistency, and recommends: "Include 3–5 examples for best results." It also asks for examples that are relevant to your real use case and diverse enough to cover edge cases, wrapped in <example> tags.

Start small. Anthropic's blog post on prompt engineering suggests: "Start with one example (one-shot). Only add more examples (few-shot) if the output still doesn't match your needs." Models copy examples closely, so every example should show only behaviour you want.

<examples>

<example>Email: "I was charged twice this month and also the export button is broken." Label: billing</example>

<example>Email: "Could you add dark mode?" Label: feature_request</example>

<example>Email: "hi" Label: other</example>

</examples>

The first example teaches the two-topic rule, the third the empty-input rule.

Step 4: Decide how much reasoning the task needs

Chain-of-thought prompting asks the model to work through intermediate steps before answering. The technique was popularised by a 2022 paper from Google researchers, "Chain-of-Thought Prompting Elicits Reasoning in Large Language Models", which showed gains on maths and logic tasks. The classic form is one line: "Think through this step by step, then give your final answer in <answer> tags."

Many current models now reason internally, and vendors have adjusted their advice. Anthropic's blog says built-in extended thinking is generally preferred over manual chain of thought where it is available. Its docs also warn that "Thinking adds latency and should only be used when it will meaningfully improve answer quality".

TechniqueUse it whenSkip it when
Few-shot examplesFormat or judgement is hard to describeThe task is simple and instructions already pass
Chain of thought / thinkingMulti-step maths, logic, planningSimple lookups, labelling, short rewrites
Structured outputCode or a spreadsheet will read the resultA person reads free text
Prompt chainingOne prompt gives inconsistent results on a long taskLatency matters more than accuracy

Labelling one email is not a multi-step problem, so leave reasoning off for the triage task.

Step 5: Lock down the output format with structured output

If software will read the answer, do not rely on the model following a format by habit. Ask the API to enforce a schema. OpenAI's documentation explains the difference between its two options: "While both ensure valid JSON is produced, only Structured Outputs ensure schema adherence." It recommends Structured Outputs over JSON mode whenever possible. Google's Gemini docs describe the same idea: pass a response schema with the prompt, which also works for classification with a fixed set of labels.

One older trick no longer works everywhere. Anthropic's docs say prefilling the start of the model's reply is not supported from Claude 4.6 models onward and returns an error. In a chat window without schema support, the fallback is an explicit instruction:

Return only valid JSON with no preamble, in this shape: {"label": one of billing, bug, feature_request, account_access, other; "confidence": high or low}

The confidence field lets you route uncertain emails to a person.

Step 6: Test, compare and iterate

Run every prompt version against the full test set, record pass or fail per row, and change one thing at a time. Anthropic's blog is blunt: "The first prompt rarely works perfectly. Test and refine." Its evaluation guide lists grading methods from exact string match (ideal for labels) to using a second model as a judge for subjective qualities like tone, adding that it is "Generally best practice to evaluate with a different model from the one used to generate the evaluated output."

When one prompt keeps failing on a long task, split it. Anthropic describes the most common chaining pattern as self-correction: generate a draft, review it against your criteria, then refine, with each step as a separate call you can log and check.

Example: a complete worked example

Here is the whole method applied to the triage task. The scores are illustrative, to show how you read results, not results from a test we ran.

  1. Baseline. A one-line prompt, "Label this email as billing, bug, feature request, account access or other." Suppose it scores 30 of 40 (75%), and most misses are two-topic or empty emails.
  2. Version 2: system prompt. Add the role, the fixed label list and the two-topic rule from Step 2. Suppose the score rises to 34 of 40 (85%). The empty emails still fail.
  3. Version 3: few-shot. Add the three examples from Step 3. Suppose this reaches 37 of 40 (92.5%), past the 36 target.
  4. Version 4: schema. Enforce the JSON shape from Step 5 so the routing code never meets a malformed label.
  5. Regression check. Add 10 new emails from last week and re-run. If the score holds near 90%, ship it. If it drops, the new failures tell you which example or rule to add next.

The point: every change is justified by rows in a spreadsheet, not a feeling that the answer "looks better".

Common mistakes and how to fix them

  • Judging by one output. A single good answer proves little. Fix: always run the full test set.
  • Over-engineering. Anthropic's blog lists longer, more complex prompts and using every technique at once among common mistakes. Fix: add a technique only when a failure calls for it.
  • Examples that teach the wrong pattern. If all your examples are billing emails, expect more billing labels. Fix: vary examples and include edge cases.
  • Telling the model what not to do. Anthropic's docs suggest stating the behaviour you want instead, for example "write in flowing prose paragraphs" rather than "do not use markdown".
  • Treating a prompt as permanent. Models are updated and retired. Google's docs, for instance, note that Gemini 2.5 models shut down for all projects in October 2026 on its Agent Platform API. Fix: re-run your test set whenever you switch model.

Tips to get better results from AI prompt engineering

  • Use the colleague test. Anthropic suggests: "Show your prompt to a colleague with minimal context on the task and ask them to follow it. If they'd be confused, Claude will be too."
  • Keep a prompt library. Store each prompt with its version, test score and date. A good AI prompt library is tested prompts plus their results.
  • Remember the cheaper fix. Anthropic's overview notes that latency and cost are sometimes better solved by choosing a different model than by rewriting the prompt.

Next steps

Pick one task you repeat every week and build a 20-row test set for it this week. Once your prompts are stable, the same skills carry over to multi-step systems: our explainer on agentic AI shows how prompts, tools and checks combine into agents. Our Claude AI review covers its plans, and our guide on how to use AI suits colleagues who are just starting.

FAQ

What is a prompt in AI?

A prompt in AI is the input you give a generative model to tell it what to produce. It can be a question, an instruction, examples, documents or a mix. In API products it usually has two parts: a system prompt with standing rules and a user message with the request.

What is an AI prompt?

An AI prompt is the text, and sometimes images or files, you send to a chatbot or model to get a response. A good one states the task, the context, the format you want and any limits. "Summarise this" is a prompt. "Summarise this report in five bullets for a finance manager, under 100 words" is a much better one.

How to write an AI prompt?

Start with a verb and the task, add the background the model needs, separate any pasted material with clear tags, show one example of a good answer and state the format. Test it on several real inputs. Our prompt writing guide covers the basics step by step.

What are AI prompts?

AI prompts are the instructions people write to steer models such as ChatGPT, Claude or Gemini. They range from one-line questions to long system prompts with rules, examples and output schemas. Teams often keep tested ones in a shared prompt library.

What is AI prompt engineering?

AI prompt engineering is the discipline of designing and testing prompts so a model performs a task reliably. It goes beyond wording: it includes system prompts, few-shot examples, reasoning settings, structured output and evaluation against a test set. Vendor guides from Anthropic, OpenAI and Google all treat measuring results as part of the job.

Sources

  1. Prompt engineering overview (Claude Platform Docs, Anthropic)
  2. Prompting best practices (Claude Platform Docs, Anthropic)
  3. Define success criteria and build evaluations (Claude Platform Docs, Anthropic)
  4. Best practices for prompt engineering (Claude blog, Anthropic)
  5. Structured model outputs (OpenAI API docs)
  6. Understand prompt design (Firebase AI Logic docs, Google)
  7. Chain-of-Thought Prompting Elicits Reasoning in Large Language Models (arXiv)

Keep reading