Explainer · updated Oct 5, 2026

What is prompt engineering and how it works in 2026

Prompt engineering is the practice of writing and refining the instructions you give an AI model so it returns the output you want. This page explains it using 17 sample prompts taken from the Anthropic, OpenAI and Google Gemini prompt engineering guides.

What prompt engineering is

Prompt engineering is the work of writing, testing and adjusting the text you send to an AI model so the answer matches your need. A prompt can be one line, such as "Summarize this text in one sentence", or a structured message with a role, rules and examples.

Anthropic, OpenAI and Google each publish a prompt engineering guide. Our library at /prompts/ includes 17 sample prompts taken from those three guides: 9 from Anthropic, 3 from OpenAI and 5 from Google Gemini, each linked back to its source page. The same techniques apply inside coding agents such as Claude Code, OpenAI Codex and Cursor, where the prompt is often a project file like AGENTS.md or a Claude skill.

A prompt can be one line such as Summarize this text in one sentence, or a structured message with a role, rules and examples ONE LINE A prompt can be short "Summarize this text in one sentence" or STRUCTURED MESSAGE A role, rules and examples Rolewho the model is Ruleswhat it must do Examplesinput and output pairs write → test → adjust, until the answer matches your need
A prompt can be one line or a structured message with a role, rules and examples

How it works in practice

The guides show a few repeatable techniques. One is giving the model a role and rules, as in the OpenAI sample that sets up a coding assistant with an identity, instructions and examples. Another is wrapping instructions in named tags, like the Claude sample whose tag tells the model to investigate before answering.

A third is showing examples, known as few-shot prompting. The OpenAI sample labels product reviews as Positive, Negative or Neutral, and the Gemini sample extracts JSON from free-text food orders, both by showing the pattern first. A fourth is constraining the output, such as the Gemini one-sentence summary or multiple-choice prompts.

Four techniques from the vendor guides: role and instructions, examples, constraints and context TECHNIQUE 1 Role and instructions set who the model is and what it must do TECHNIQUE 2 Examples show input and output pairs so format is clear TECHNIQUE 3 Constraints limit length, options or format TECHNIQUE 4 Context say why an instruction exists few-shot prompting = the Examples card: show the pattern first
Four repeatable techniques: role and instructions, examples, constraints, context
  • Role and instructions: set who the model is and what it must do
  • Examples: show input and output pairs so the format is clear
  • Constraints: limit length, options or format
  • Context: say why an instruction exists, as in the Claude text-to-speech sample

What the sample prompts control

Several Anthropic samples change how an agent behaves, not what it knows. One tells Claude to implement changes by default. Its opposite tells Claude to research and advise before editing files. Another asks Claude to run independent tool calls in parallel.

Others target output quality. One reduces claims about code the model has not opened. One asks for prose instead of bullet-heavy formatting. One pushes for distinctive frontend design instead of a generic look. One grounds answers in quotes pulled from long documents first. The guides treat these as starting points to adapt, so test each against your own task.

Sample prompts either change how an agent behaves or improve output quality AGENT BEHAVIOR OUTPUT QUALITY Implement changes by default Research and advise first Run independent calls in parallel changes how an agent acts Fewer claims about unopened code Prose, not bullet-heavy text Distinctive frontend design Quotes from long documents first changes the output, not what it knows
Sample prompts change how an agent behaves or how good its output is

Who it is for

Anyone who gets inconsistent results from an AI model can use these techniques: developers writing system prompts, analysts classifying text, and writers shaping tone. The library tags samples by task, including coding, writing, research, data, education, business and productivity, so you can start from the one closest to your job. If you are choosing the model itself, start with our Claude vs ChatGPT and Claude vs Gemini comparisons, or the guides to chat assistants and writing tools.

It is less useful if the model lacks the capability you need. A better prompt changes how the model uses what it has. The samples are short and specific, and several contain placeholders such as [Insert Domain] that you must fill in before use.

Getting started

Pick a sample at /prompts/ that matches your task and read its source guide through the link on the page. Replace the placeholders, run it on your own input, and compare the output with what you expected.

Change one thing at a time: add an example, tighten a constraint, or explain the reason behind a rule. Keep the version that works. Because each vendor guide targets its own models, a prompt written for Claude may need edits before it behaves the same way in Gemini or an OpenAI model. For reusable prompt packs in coding tools, see Cursor rules and Claude Code skills; current plan prices are on the ChatGPT pricing and Claude pricing pages.

Getting started loop: pick a sample, replace placeholders, run it, compare, change one thing, keep what works STEP 1Pick a sample STEP 2Replace placeholders STEP 3Run on your input STEP 4Compare with expected STEP 5Change one thing STEP 6Keep what works repeat: one change at a time
Getting started: run a sample, compare, change one thing, keep the version that works

Read next

Frequently asked questions

What is prompt engineering in simple terms?

It is writing and refining the instructions you give an AI model so it produces the output you want. The vendor guides cover roles, examples, constraints and added context.

Where can I find real prompt engineering examples?

Our prompt library at /prompts/ lists 17 sample prompts from the Anthropic, OpenAI and Google Gemini guides. Each links to its source guide.

What is few-shot prompting?

Few-shot prompting means including examples of the input and output you want inside the prompt. The OpenAI review-sentiment sample and the Gemini order-to-JSON sample both use it.

Do prompts work the same across Claude, ChatGPT and Gemini?

Not guaranteed. Each vendor publishes its own guide for its own models, so test a prompt on the model you use and adjust it.

Can I copy these sample prompts?

They are samples from public vendor guides, meant as starting points. Replace placeholders like [Insert Domain] and check them against your own task before relying on them.

Sources