Prompt Engineering: A Practical Guide With Examples That Actually Work
Prompt engineering guide with examples that work: the five-part prompt, OpenAI's six strategies, Anthropic's rules, and the mistakes to avoid.
By Galactic News Editorial · Published 2026-11-07T15:04:07+00:00 · Updated 2026-11-07T15:04:07+00:00
Prompt engineering is the skill of writing instructions that get reliable results from AI models. A vague prompt gets a vague answer. A specific prompt with context, examples, and a clear output format gets work you can use. This guide teaches the method the major AI labs themselves recommend, with examples you can copy and adapt.
The advice here comes from the official prompting guides published by OpenAI and Anthropic, plus Google's Gemini prompting guidance. The three guides agree on far more than they disagree. Learn the shared rules first. Then learn the small differences between models.
The prompt engineering guide in one page
Every good prompt has five parts. You do not need all five every time, but check the list before you send an important prompt.
- Role: who the model should act as. You are a senior Python developer reviewing code for a junior team.
- Task: what to do, in plain words. One verb, one object, one outcome.
- Context: the background the model cannot guess. Source material, definitions, constraints, and audience.
- Examples: three to five samples of the input and the output you want. Anthropic calls examples one of the most reliable ways to steer format and tone.
- Format: the exact shape of the answer. Length, headings, table or list, and tone.
Test your prompt with the colleague test. Anthropic suggests showing it to a colleague with minimal context. If they would be confused, the model probably will be too.
Step 1: Be specific, like briefing a new hire
Anthropic describes Claude as a brilliant but new employee who does not know your norms. OpenAI says the same in its own words: GPT models need precise, explicit instructions to do their best work. Vague words are the main cause of bad outputs.
Compare the two prompts below. The first leaves every decision to the model. The second makes the decisions for it.
Weak: Write about climate change.
Strong: Write a 300-word explainer on ocean acidification for high-school students. Use short sentences. End with three things readers can do. Do not use jargon without defining it.
The strong prompt sets the topic, length, audience, style, structure, and a rule. That is six decisions the model no longer has to guess. Add the reason behind a rule when it matters. Anthropic notes that the model generalizes better from an explained instruction than from a bare command.
Tell the model what to do, not only what to avoid. Write in flowing prose paragraphs works better than Do not use bullet points. Positive instructions give the model a target. Negative ones only remove options.
Step 2: Give context the model cannot guess
A model cannot know your audience, your data, or your constraints unless you supply them. Paste the source material into the prompt. State the facts that matter. Name the output you expect.
OpenAI's guide makes this a strategy of its own: provide reference text. Instruct the model to answer using the reference text, and to cite it. OpenAI compares it to a sheet of notes helping a student do better on a test. Reference text cuts down on invented facts, which is the most common failure in AI answers.
For long inputs, put the documents first and the question last. Anthropic recommends this for inputs of 20,000 tokens or more. In its tests, placing the query after large evidence blocks improved response quality by up to 30 percent on complex multi-document tasks. Google's guidance agrees: stable material first, changing task later.
Give the model permission to say it does not know. Anthropic's guide recommends an explicit line for this. A model that must always answer will invent one. A model allowed to say the documents do not contain this will stay honest.
Step 3: Show examples, then set the structure
Examples beat descriptions. Show the model three to five examples of the input and the output you want. Anthropic recommends three to five for best results. OpenAI suggests a diverse range of examples with the outputs you want. Pick examples that cover the range: a short one, a long one, and an edge case.
Structure long prompts with headings or tags. OpenAI recommends Markdown headers, lists, and XML tags to mark distinct sections. Anthropic recommends XML tags such as <instructions>, <context>, and <input>. Google says XML-style tags or Markdown headings both work. Pick one format and use it consistently inside a single prompt.
A simple template looks like this:
<role>You are an editor for a science magazine.</role> <context>[paste the draft here]</context> <task>Cut this draft to 200 words. Keep all facts. Flag any claim you cannot verify from the text.</task> <format>Return the edited draft, then a bullet list of flagged claims.</format>
Delimiters matter because they stop the model from confusing your instructions with your source material. Without them, a sentence inside a pasted document can be read as a command.
Step 4: Split big jobs into small steps
OpenAI's third strategy is to split complex tasks into simpler subtasks. A model does better work on a small, clear step than on a large, vague one. Break the job into stages and run them in order.
For example, do not ask for a finished report in one prompt. Ask for an outline first. Check the outline. Then ask for one section at a time. Then ask for a summary of the full draft. Each step is easy to check, and an error in one step does not ruin the rest.
Intent classification is a useful first step. Ask the model to classify the request before it answers: is this a summary, a comparison, or a how-to? Then route the classified request to the right instructions. OpenAI lists this as a tactic under task splitting.
For reasoning models, the rules change. OpenAI's reasoning best practices say these models work best with brief, clear instructions and a defined end goal. Try zero-shot first. Explicit step-by-step instructions are usually unnecessary for them, and can sometimes hinder. Ask for the outcome and the verification, not for the hidden steps.
The classic let's think step by step phrase comes from a 2022 paper by Kojima and colleagues. It lifted one model's arithmetic score from 17.7 percent to 78.7 percent in their tests. That finding shaped years of prompting advice. For today's reasoning models, the labs now say the instruction is built in, so you can skip it.
Step 5: Check the work and test changes
OpenAI's sixth strategy is to test changes systematically. A tweak that improves one example can make overall performance worse. Test each change on a small set of representative examples before you adopt it.
Build a habit of verification. Ask the model to check its own answer against criteria you set. Anthropic's guide suggests a line such as: Before you finish, verify your answer against these test criteria. For numbers, make the model use a tool. All three labs offer code execution, so the model can calculate instead of guessing.
For long conversations, re-ground the model. Summarize the decisions so far and restate the open questions. Long chats drift. A short reset keeps the model on task.
Keep a prompt log. Save the prompts that work, with a note on what they were for. Good prompts are reusable assets. A prompt that took an hour to refine is worth saving.
Common mistakes to avoid
| Mistake | Why it fails | Do this instead |
|---|---|---|
| Vague request | Model guesses your intent | State topic, length, audience, format |
| No context | Model invents facts | Paste reference text, cite it |
| Negative-only rules | No target to aim at | Say what to do, in positive terms |
| One giant prompt | Errors compound | Split into steps, check each one |
| Step-by-step for reasoning models | Unnecessary, can hinder | Brief instructions, defined end goal |
| Never testing | One example hides regressions | Test changes on several examples |
Bottom line
Good prompting is good briefing. Be specific. Supply the context the model cannot guess. Show three to five examples. Structure the prompt with headings or tags. Split big jobs into small steps. Then test the result and keep the prompts that work. These six habits come straight from the labs that build the models, and they work on every major chatbot today.