AI & prompting

What Is Prompt Engineering? A Plain Explanation With Examples

Prompt engineering is the process of writing effective instructions for an AI model so that it consistently produces output that meets your requirements. That is OpenAI's definition, and it includes the part people skip: you test the instructions against real inputs and keep improving them.

The word "engineering" refers to that loop of writing, testing and revising. A single clever sentence that worked once is not prompt engineering. A prompt that gives acceptable results across 50 different inputs, and that you can show is better than the previous version, is.

What counts as a prompt

A prompt is everything you send to the model: the instructions, any documents or data you paste in, examples, and the question itself. In OpenAI's API, messages carry roles. Developer messages carry the application's rules and rank above end-user input, user messages supply the inputs those rules apply to, and the model's replies use the assistant role. Splitting standing rules from per-request input is a basic prompt engineering decision. System prompt vs user prompt explains it in detail.

What prompt engineering involves

The vendor guides describe a set of techniques. These are the main ones:

TechniqueWhat you doRead more
Clear instructionsState the task, the audience, the constraints and the output format instead of leaving them to be guessedHow to write a good AI prompt
Examples (few-shot)Include a handful of input and output examples in the prompt, covering a diverse range of inputsFew-shot prompting
StructureSeparate instructions, reference material and examples so the model can tell them apartBoth guides cover it
Step-by-step reasoningAsk the model to work through a problem in stagesChain-of-thought prompting
Testing and evaluationBuild tests that measure how the prompt behaves, and re-run them when you change the prompt or the modelNext section

A short before and after

These two prompts are our own illustration, not taken from a vendor guide.

Before:

Write about our new feature.

After:

Write a 3-sentence release note for existing customers about our new CSV export.
Say what it does, where to find it (Reports menu), and that it is free on all plans.
Plain tone, no exclamation marks.

The first prompt leaves the model to guess the length, audience, tone and facts. The second supplies them. The model is the same in both cases; only the instructions changed. That difference is the whole discipline in small.

The testing part

OpenAI's guide recommends two habits that separate engineering from guesswork. One is "building tests and evaluation suites that measure prompt behavior", so you can track performance as you iterate or upgrade models. The other is pinning production applications to specific model snapshots, so behaviour stays consistent until you choose to change it.

Anthropic's overview makes the same point from the other direction. It assumes you already have three things before you start tuning: a clear definition of success criteria, some way to test against those criteria empirically, and a first draft prompt. If you lack the first two, it says to establish them first.

A practical version for a small project: collect 10 to 20 real inputs, run each prompt version on all of them, and compare the outputs side by side. A text diff helps with that; larely's diff checker runs in the browser.

Prompts differ by model

OpenAI's guide compares two kinds of model. A reasoning model is "like a senior co-worker": give it a goal and let it work out the details. A GPT model is "like a junior coworker": it does best with precise, explicit instructions. So the same prompt can behave differently depending on the model, and advice written for one family does not always carry over to another. Anthropic likewise points to a separate, model-specific "Prompting best practices" page for its latest models, which it calls the living reference.

When prompt engineering is not the fix

Anthropic's overview says plainly that not every success criterion or failing evaluation is best solved by prompt engineering. Its example: you can sometimes improve latency and cost more easily by choosing a different model. If a prompt keeps failing after several clear revisions, consider whether the problem is the model choice, missing information the model never received, or a requirement that needs a different tool.

Prompt engineering and security

Instructions you write are not a security boundary. If a prompt includes text from users or from the web, that text can contain instructions of its own. Prompt injection explained covers how that happens and what limits the damage.

Where to start

  1. Write down what a correct output looks like for your task, in a sentence.
  2. Collect a handful of real inputs, including awkward ones.
  3. Write a first prompt with the task, constraints and format, and add one or two examples.
  4. Run it on all the inputs, read the results, and change one thing at a time.
  5. Keep the prompt and the test inputs together, so you can re-run them when the model changes.

Frequently asked questions

Is prompt engineering a real job?
The two vendor guides we cite describe prompt engineering as a practice, not a job title, and neither says anything about hiring. In practice it is a skill that developers, analysts and writers use when they build on or work with language models. Whether an employer posts a role with that name varies, so check job listings directly instead of relying on a general claim.
Do I need to know how to code to do prompt engineering?
No. Writing clear instructions, giving examples and checking the results needs no code. Code becomes useful when you want to run the same prompt over many inputs and measure the results, which is what the vendors' advice about test suites and evaluations assumes.
How is prompt engineering different from fine-tuning?
Prompt engineering changes the instructions you send to an existing model. Fine-tuning changes the model itself by training it on additional examples. OpenAI's guide describes few-shot prompting as a way to steer a model toward a task with examples in the prompt instead of fine-tuning, so you can often try prompting first.
Does the same prompt work on every model?
Not reliably. OpenAI's guide says reasoning models generally do well with high-level goals, while GPT models need more precise, explicit instructions. A prompt tuned for one model should be re-tested when you switch or when the vendor releases a new version.

Sources