Prompt engineering is the practice of writing instructions and context so a language model produces the output you need on the first or second try. This guide covers the techniques that still matter with current models, with before-and-after prompts, a reusable template and a way to test prompts instead of guessing.
- Most bad answers come from missing context, so tell the model who the output is for, why you need it and what done looks like.
- Show 3 to 5 varied examples when format or tone matters; they steer output more reliably than adjectives.
- Separate instructions, documents and examples with XML tags or Markdown headings, and put long documents above your question.
- Say what to do instead of what not to do, and ask for an exact output format (JSON schema, table columns, word limit).
- Treat a prompt like code: keep it in a file, test it on 10 to 20 real inputs and change one thing at a time.
What is prompt engineering in 2026?
Prompt engineering is writing the instructions, context and examples that make a language model produce the output you want. With current models from Anthropic, OpenAI and Google, it is less about clever phrasing and more about giving a clear brief: what the task is, who it is for, what good looks like and how the answer should be shaped.
Early guides were full of tricks: "take a deep breath", "you will be tipped $200", elaborate personas. Models have improved to the point where most of those tricks rarely change results on current models. What still moves quality is the same thing that helps a new colleague do good work: enough context and a precise request.
Anthropic's prompting guide puts it this way: think of the model as a brilliant new employee who lacks context on your norms. Its "golden rule" is to show your prompt to a colleague with minimal context; if they would be confused, the model will be too. That test alone fixes most weak prompts.
The rest of this guide covers seven techniques, roughly in the order you should reach for them, plus a reusable template.
Why do vague prompts give generic answers?
Vague prompts give generic answers because the model fills every gap with the most statistically average choice. If you do not say who the audience is, it writes for everyone. If you do not say how long, it picks a medium length. If you do not say what to avoid, it includes the usual filler.
Compare these two requests:
Write a product announcement for our new feature.Write a 150-word product announcement for our changelog page.Feature: scheduled exports. Users can now schedule a CSV export of any reportto run daily or weekly and land in their email.Audience: operations managers at mid-size logistics companies who already usethe reports page. They care about saving manual work, not about how it works.Tone: plain and factual, like a release note from Linear or Stripe. Noexclamation marks, no "we're excited to announce".End with one sentence on where to find the setting: Reports > Schedule.The second prompt is longer, but every line removes a guess. That is the core of the craft. Before you add any technique below, check that your prompt answers five questions: what, for whom, why, in what shape and how long.
1. How much context should you give the model?
Give the model the context a capable outsider would need to do the task well, including the reason behind your constraints. Explaining why a rule exists lets the model apply it sensibly to cases you did not anticipate.
Anthropic's documentation shows this with a formatting rule. "NEVER use ellipses" works less well than "Your response will be read aloud by a text-to-speech engine, so never use ellipses since the text-to-speech engine will not know how to pronounce them." The second version tells the model what problem it is solving, so it also avoids other things a speech engine would stumble on.
Useful context to include:
- The audience and what they already know.
- The goal behind the task (the decision this output supports).
- Constraints with their reasons (legal wording, brand rules, length limits).
- Source material: the document, data or code the answer should be based on.
- What you already tried and why it did not work.
For anything bigger than a single request, managing what goes into the model's context window becomes its own discipline. Our guide to context engineering covers memory files, retrieval and keeping long sessions on track.
Do role prompts still help?
A short role still helps set tone, vocabulary and level of detail, especially in a system prompt. It does not make the model smarter, so pair it with real context rather than expecting the role to do the work.
"You are a senior tax accountant" shifts the output toward precise terminology and caution. "You are a senior tax accountant explaining a client's options to a first-time freelancer in Germany who has never filed self-employed taxes" is far better, because most of that sentence is context about the reader.
Where to put the role:
| Setting | Where the role goes |
|---|---|
| Claude API | The system parameter |
| OpenAI API | The instructions parameter or a developer message |
| Coding agents | CLAUDE.md, AGENTS.md or the agent's definition file |
2. When should you use examples (few-shot prompting)?
Use examples whenever the format, tone or structure of the output matters more than the facts. A few concrete samples steer a model more reliably than any list of adjectives like "concise" or "professional".
Anthropic recommends 3 to 5 examples, chosen to be relevant to your real use case and diverse enough that the model does not copy an accidental pattern. If all your examples are 40 words long and start with a verb, expect every output to do the same. OpenAI's guide gives the same advice: show a diverse range of inputs with the outputs you want.
Wrap examples so the model can tell them apart from the instructions:
Classify each support ticket as billing, bug, feature_request or other.Reply with the label only.<examples><example>Ticket: I was charged twice this month.Label: billing</example><example>Ticket: The export button does nothing in Safari.Label: bug</example><example>Ticket: Could you add dark mode to the dashboard?Label: feature_request</example><example>Ticket: Do you have an office in Berlin?Label: other</example></examples>Ticket: {{ticket_text}}Label:If you have no good examples, ask the model to draft five, then edit them by hand. Editing is faster than writing from scratch, and you end up with examples that match your taste.
3. How do you structure a long prompt?
Structure a long prompt by putting each kind of content in its own labeled section, so instructions, reference material, examples and the actual input never blur together. XML-style tags work well with Claude; Markdown headings work well with most models.
OpenAI suggests a developer message with sections for identity, instructions, examples and context, usually in that order. Anthropic recommends consistent, descriptive tag names such as <instructions>, <context> and <input>, nested when the content has a hierarchy.
For long documents, placement matters too. Anthropic's guide says to put long material (20,000 tokens and up) at the top of the prompt and the question at the end, and reports that queries at the end can improve response quality by up to 30 percent in its tests with complex, multi-document inputs.
<documents> <document index="1"> <source>q3_board_deck.pdf</source> <document_content>{{DECK}}</document_content> </document> <document index="2"> <source>customer_interviews.md</source> <document_content>{{INTERVIEWS}}</document_content> </document></documents>First, copy the quotes from both documents that relate to churn into <quotes>tags. Then, using only those quotes, list the three most likely causes of churnin <analysis> tags. If the documents do not support a cause, say so.Asking for quotes first is a simple grounding step. It makes the model point at evidence before it reasons, which cuts down on invented details. Our article on AI hallucinations has more techniques for that problem.
4. How do you get the exact output format you need?
Ask for the format explicitly and positively: name the structure, the fields, the length and the order. "Return a JSON object with keys title, summary and tags" beats "don't write a long answer".
Anthropic's guide makes three practical points here:
- Say what to do, not what to avoid. "Write in flowing prose paragraphs" works better than "Do not use markdown".
- Match your prompt's style to the output you want. A prompt full of bullet points and bold text invites a reply full of bullet points and bold text.
- Use the API's structured output features for machine-readable results. For JSON that code will parse, use structured outputs or tool calling with a schema instead of relying on wording alone.
One change to know about if you build on the Claude API: prefilling the start of the assistant's reply (a common trick for forcing JSON or skipping preambles) is no longer supported on Claude 4.6 models and later, and those requests return an error. Anthropic's migration advice is to use structured outputs for format control and a direct instruction such as "Respond directly without preamble" for the rest.
5. Should you tell the model to think step by step?
For current reasoning models, "think step by step" adds little, because they already reason before answering. Give them the goal, constraints and a way to verify the result, and let them choose the steps.
OpenAI's prompt engineering guide frames the difference with an analogy: reasoning models are like a senior colleague you can give a goal to, while standard GPT models are like a junior colleague who does best with explicit, precise instructions. So:
- With a reasoning model or extended thinking turned on: describe the outcome and how to check it. "Find the bug that makes this test fail, explain the root cause in two sentences, then propose the smallest fix."
- With a fast, non-reasoning model: spell out the procedure as numbered steps when the order matters.
Anthropic's guide also suggests numbered steps whenever the order or completeness of steps matters, regardless of model.
6. When should you split one prompt into several?
Split a task into a chain of prompts when it has distinct stages that each need full attention, such as research, then outline, then draft, then review. Each step gets a focused prompt, and you can inspect and fix the output between steps.
A content example:
- Extract: "From these interview transcripts, list every pain point with a direct quote."
- Group: "Cluster these pain points into 4 to 6 themes. Name each theme in under five words."
- Draft: "Write a 600-word summary for the product team, one section per theme."
- Review: "Check this summary against the original quotes. Flag any claim the quotes do not support."
The review step is where chaining earns its keep. A model checking a finished draft against sources catches errors it made while writing.
The same idea drives coding agents, which plan, act and check in a loop. If you write tasks for tools like Claude Code or Codex, see how to write tasks for AI coding agents for a spec template with acceptance criteria.
7. How do you test and improve a prompt?
Test a prompt the way you test code: run it on a fixed set of real inputs, judge the outputs against written criteria, change one thing and run it again. One good response proves nothing; ten good responses on varied inputs is evidence.
Both Anthropic and OpenAI put evaluation first. Anthropic's overview says to start with clear success criteria and a way to test against them before tuning the prompt. OpenAI recommends building test suites that measure prompt behavior, keeping production prompts in your codebase and pinning production apps to a specific model snapshot so behavior does not shift under you.
A lightweight routine that works without any tooling:
- Collect 10 to 20 real inputs, including two or three awkward edge cases.
- Write 3 to 5 pass/fail criteria ("under 120 words", "mentions the refund window", "no invented prices").
- Run the prompt on every input and score each output.
- Change one thing (an example, a constraint, the order of sections).
- Rerun everything and compare scores. Keep the change only if the score improves.
If cost matters as your prompts grow, put stable content (instructions, examples, reference documents) at the start so the provider's prompt caching can reuse it. Our guide on how to reduce LLM API costs explains caching and model routing in detail.
A reusable prompt template
A good default template has five parts: role and audience, task, context, output format and checks. Fill in what applies and delete the rest.
<role>You are a {{role}} writing for {{audience}}, who already know {{what they know}}.</role><task>{{One or two sentences: what to produce and the decision or action it supports.}}</task><context>{{Background, source documents, constraints and the reason for each constraint.}}</context><examples>{{2 to 5 examples of good output, if format or tone matters.}}</examples><output_format>{{Structure, length, fields or headings, and what to do if information is missing.}}</output_format><checks>Before answering, verify that: {{2 or 3 concrete checks, e.g. every numbercomes from the context; the answer is under 200 words}}.</checks>For ready-made prompts built on this pattern for writing, analysis, email and planning, see our collection of ChatGPT prompts for work; they work in Claude and Gemini too.
How to start improving your prompts today
You do not need a course to get better results this week. Pick one prompt you use often and work through this list:
- Run the colleague test: would a smart outsider understand exactly what you want?
- Add the audience, the goal and one reason for each constraint.
- Replace adjectives ("professional", "engaging") with two or three examples.
- Separate instructions from material with tags or headings, and move long documents above the question.
- Specify the output: structure, length and what to do when information is missing.
- Save the prompt in a file, test it on ten real inputs and change one thing at a time.
When your prompts turn into longer tasks for coding agents, the same rules apply, with one extra concern: the agent needs somewhere to keep working after you close your laptop. Orkio runs agents like Claude Code on an always-on cloud box, so a well-specified task can finish overnight and wait for you as a pull request.
Frequently asked questions
Is prompt engineering still relevant with newer AI models?
Yes, but the emphasis has shifted. Current models need fewer tricks and more clear specifications: context, examples, constraints and a definition of done. The skill now looks more like writing a good brief than finding special phrasing.
Does chain-of-thought prompting still help?
For models with built-in reasoning or extended thinking, that phrase adds little because the model already reasons before answering. OpenAI notes that reasoning models do better with high-level guidance, while standard models benefit from precise instructions. For hard problems, it is more useful to give a goal, the constraints and a way to check the answer.
What is the difference between a system prompt and a user prompt?
A system prompt (called a developer message in OpenAI's API) sets standing rules, role and behavior for the whole conversation. The user prompt carries the specific request and its inputs. Put stable rules in the system prompt and the changing task in the user message.
How long should a prompt be?
As long as it needs to be to remove ambiguity, and no longer. A one-line request is fine for a simple rewrite, while a production prompt for a support bot can run to several hundred words with examples. Length that adds context helps; length that repeats instructions does not.
Do the same prompts work in ChatGPT, Claude and Gemini?
Mostly. Clear context, examples and an explicit output format help every current model. The differences are in details: Anthropic recommends XML tags to separate parts of a prompt, OpenAI suggests Markdown headings or XML, and each API has its own place for system-level instructions. Test an important prompt on the model you will actually use.


