Skip to content
Prompt Engineering

Prompt Engineering Guide: How to Write Better AI Prompts

AIblogly Team August 5, 2026
Prompt Engineering Guide: How to Write Better AI Prompts

In short: prompt engineering is the skill of writing instructions that get useful answers from an AI model. The core techniques are: say exactly what you want (length, audience, format), give the background the model cannot guess, show an example or two of the output, ask it to work through hard problems step by step, and refine the answer in follow-up messages. They work with any current chat assistant, including ChatGPT, Claude and Gemini.

What is a prompt?

A prompt is the text you give an AI model - a question, an instruction, plus any examples or documents you include. The model reads the whole prompt and writes the reply most likely to fit it. A short, vague prompt leaves the model guessing; a clear one narrows the possible answers down to the kind you want.

Anthropic's prompting best practices put it this way: think of the model as "a brilliant but new employee who lacks context on your norms and workflows". Its suggested test: show your prompt to a colleague with little context on the task, and if they would be confused, the model probably will be too.

How do you write a good prompt?

State the task, the audience, the length and the format, and give any background the model cannot know.

Weak:

Write about solar power.

Better:

Write a 200-word explanation of how solar panels turn sunlight into electricity, for a reader with no science background. Use one everyday comparison and no technical terms.

The second prompt sets four things - length, audience, angle and a constraint - and each one removes answers you did not want. A useful checklist:

  • Task - what should it produce? An email, a summary, a list, code.
  • Audience - who is it for? A child, a customer, an expert.
  • Length - words, sentences or bullet points.
  • Format - paragraphs, a table, a numbered list, JSON.
  • Background - facts about your situation it cannot guess.
  • Purpose - why you need it. Anthropic's guide notes that explaining why an instruction matters helps the model deliver more targeted responses.

What is few-shot prompting?

Few-shot prompting means showing the model a few examples of the input and the output you want, then giving it a new input. Google's prompt design guide defines prompts with a few examples as few-shot and prompts with none as zero-shot, and notes that few-shot prompts are often used to control the format, phrasing and scope of the answers.

Example:

Turn each product into a one-line slogan.

Product: A mug that keeps coffee hot for 6 hours.
Slogan: Coffee that's still hot when you finally get to it.

Product: A backpack with a built-in solar charger.
Slogan: Your phone charges while you walk.

Product: A chopping board made from recycled plastic.
Slogan:

The model picks up the tone, length and structure from the examples and continues the pattern. The ability was described at scale in OpenAI's 2020 GPT-3 paper, Language Models are Few-Shot Learners. See few-shot prompting and in-context learning for more.

What is chain-of-thought prompting?

Chain-of-thought prompting asks the model to work through a problem step by step before giving its final answer. It helps most on problems with several steps, such as maths, logic puzzles and multi-part questions.

The technique comes from a 2022 Google paper, Chain-of-Thought Prompting Elicits Reasoning in Large Language Models, which put worked examples in the prompt. The same year, Large Language Models are Zero-Shot Reasoners reported that simply adding "Let's think step by step" before each answer improved results on arithmetic and other reasoning benchmarks.

Many current models now have a built-in reasoning or "thinking" mode that does this automatically. See chain-of-thought prompting explained.

Does giving the AI a role help?

A role such as "You are an experienced editor" steers the style and focus of the answer, but it does not add knowledge the model lacks. It works because the model has seen how editors, teachers or lawyers write, and leans towards that kind of text. Anthropic's best-practices guide lists role prompting among its techniques. A role is most useful alongside a clear task - it does not rescue a vague one.

How do you get answers in a specific format?

Name the format exactly, and show its shape if you can. "Give me the data" gets inconsistent results; "Return a table with three columns: name, price, link" or "Return a JSON array of objects with the keys name and price, and nothing else" gets something you can paste or parse.

Two more structuring habits from the vendors' guides:

  • Separate parts of a long prompt. Anthropic's guide covers wrapping instructions, documents and examples in labelled XML tags - for example, putting examples inside <example> tags - so the model can tell them apart from the instructions.
  • Use the platform's own structured-output feature for complex data. Google's guide recommends the Gemini API's structured output feature over prompt instructions for complex JSON schemas.

Why should you refine a prompt instead of starting over?

Treat the first answer as a draft; a short follow-up is usually faster than rewriting the whole prompt. The model keeps the conversation so far, so "shorter", "more formal", "add an example" or "you missed the second question" builds on what it already did.

For bigger jobs, splitting the work into steps - outline first, then each section, then a final edit - gives you a chance to correct each stage. Anthropic's guide calls this prompt chaining.

What can't prompt engineering fix?

A better prompt does not make a model know facts it was never trained on, or reliably avoid mistakes.

  • Hallucination. A model can still state false information confidently, so facts, figures and quotes need checking against an original source.
  • Knowledge cut-off. Without web search, a model does not know about events after its training data ends.
  • Model limits. OpenAI's prompt engineering guide notes that different model types, such as reasoning models and GPT models, may need to be prompted differently, and even different snapshots of the same family can give different results.

Words to know

  • Prompt - the text you give an AI model.
  • Zero-shot - a prompt with no examples.
  • Few-shot - a prompt that includes a few examples of the desired output.
  • Chain of thought - step-by-step reasoning written out before the answer.
  • System prompt - standing instructions that apply to the whole conversation, often set by the app or developer.
  • Role prompting - telling the model to answer as a particular kind of expert.
  • Prompt chaining - splitting a task into several prompts, each using the last one's output.
  • Hallucination - a confident but false answer.

Frequently asked questions

What is prompt engineering in simple words?+

Prompt engineering is writing instructions for an AI model so that it gives you the answer you need. It usually means stating the task, audience, length and format clearly, adding background the model cannot guess, and showing examples of the output you want.

What makes a good AI prompt?+

A good prompt says exactly what to produce, who it is for, how long it should be and what format to use, and includes any facts about your situation the model needs. Adding why you need it and an example of the desired output usually improves the result further.

What is the difference between zero-shot and few-shot prompting?+

A zero-shot prompt asks for a task with no examples. A few-shot prompt includes a few examples of inputs and the outputs you want, so the model can copy their pattern, tone and format.

What is chain-of-thought prompting?+

Chain-of-thought prompting asks the model to reason step by step before giving a final answer. Research published in 2022 found it improves accuracy on multi-step problems such as arithmetic, and many current models have a built-in thinking mode that does it automatically.

Does prompt engineering work with every AI model?+

The core techniques, such as clear instructions, examples and step-by-step reasoning, are described in the prompting guides of Anthropic, Google and OpenAI. Exact wording can work differently between models and model versions, so testing a prompt on the model you use is part of the process.

Can a good prompt stop AI from making mistakes?+

No. Clear prompts reduce misunderstandings, but a model can still state false information confidently and does not know about events after its training data unless it can search the web. Important facts still need checking against an original source.

Is prompt engineering hard to learn?+

The basics come down to a few habits practised on real tasks: be specific, add context, show examples and refine with follow-ups. Free courses, such as those listed on our prompt engineering courses page, cover more advanced techniques.

Enjoyed this? Get more in your inbox.

Up to ten of the week's AI news stories, by email once a week.