Home / How-To Guides

How-To Guides · 7 min read

Prompt writing basics: 6 patterns that work in any AI chatbot

The six prompt patterns that work in almost any AI chatbot are: be specific about the task and your situation, give the AI a role, show an example of the answer you want, state the format and length, paste the reference text you want it to use, and ask it to work step by step. OpenAI, Google and Anthropic all recommend versions of these in their official prompting guides. Each pattern below has a copy-and-paste example.

Key takeaways

  • Most weak answers come from vague prompts. Say who you are, what you need and what a good answer looks like.
  • Examples are one of the most reliable ways to control format and tone. Google recommends including them in prompts, and Anthropic suggests 3 to 5.
  • Pasting your own notes or syllabus and telling the AI to answer only from them cuts down invented answers.
  • For maths, coding and multi-step questions, ask the AI to show its working step by step.
  • Do not add pressure or flattery. Google's own checklist says to remove it from prompts.

1. Why should your prompt be specific?

A chatbot cannot see your situation, so a short prompt gets a generic answer. Google's Gemini prompting guide calls clear and specific instructions an effective way to shape the model's response. OpenAI's prompt engineering best practices make the same point and advise cutting vague, "fluffy" descriptions.

Compare these two prompts:

Explain recursion.
I am a Year 11 student taking IGCSE Computer Science. I understand loops and functions but not recursion.
Explain recursion in under 200 words, using a factorial example in Python.
Then give me 3 short practice questions, without the answers.

The second one says who you are, what you already know, how long the answer should be and what you want next. It gets you an answer pitched at your level and practice questions to test yourself.

2. Does giving the AI a role help?

Yes, a role tells the AI what kind of expert to be and what tone to use. Google Cloud's prompt design guide lists the persona as a standard part of a prompt, with the example "You are a math tutor here to help students with their math homework."

Roles work best when you also say what the role should do. This one is useful before any exam:

Act as an IB Computer Science examiner.
Mark my answer below out of 4, show which marking points I earned and which I missed, then tell me one change that would gain the missing mark.

Question: [paste]
My answer: [paste]

3. Why should you show the AI an example?

Showing one or two examples of the answer you want is often stronger than describing it. These are called few-shot prompts. Google's guide recommends always including few-shot examples and says prompts without them are likely to be less effective. Anthropic's guide to using examples suggests 3 to 5 relevant, varied examples for best results.

Turn my notes into flashcards in this format.

Example 1
Note: A variable stores a value that can change.
Card: Q: What is a variable? | A: A named store for a value that can change.

Example 2
Note: A constant stores a value that cannot change while the program runs.
Card: Q: What is a constant? | A: A named value that stays the same while the program runs.

Now do the same for these notes:
[paste notes]

The AI copies your pattern for the rest of the notes, so every card comes out in the same format.

4. How do you control the format and length?

Say exactly what shape you want: a table, five bullet points, a 150-word paragraph, code with comments. Google's guide lists constraints and response format as parts of a prompt, with examples such as limiting how long a summary should be and asking for a table or bulleted list.

Useful phrases to add at the end of any prompt:

  • "Answer in under 100 words."
  • "Give the answer as a table with columns for term, meaning and example."
  • "Use simple English for a 15-year-old."
  • "Do not give me the answer. Give me a hint first."

5. How do you stop AI from making things up?

Paste the text you want it to use and tell it to answer only from that text. OpenAI's guide lists "provide reference text" as one of its six strategies and compares it to a sheet of notes that helps a student do better on a test, as summarised by the Marketing AI Institute. Putting the text between triple quotes keeps it separate from your instructions.

Answer using only the text between the triple quotes. If the answer is not in the text, say "Not in the text".

"""
[paste your syllabus section, article or class notes]
"""

Question: [your question]

This is the safest way to use AI for revision, because the answers come from your actual syllabus or class notes instead of the model's memory.

6. When should you ask the AI to think step by step?

Ask for step-by-step working on anything a person would need to think through: maths, physics, code, trace tables or decisions with several factors. Anthropic's guide to chain of thought prompting says breaking a problem into steps leads to more accurate answers, and that the reasoning has to be written out for this to work. OpenAI's guide likewise recommends splitting complex tasks into simpler subtasks.

Solve this step by step. First list what the question gives you, then show each step of working, then give the final answer on its own line.

[paste problem]

A bonus for students: when the working is visible, you can spot exactly where the AI, or you, went wrong.

What is a good prompt template to copy?

Put the six patterns together and you get a template that works for homework help, revision, essays and code. Fill in only the lines you need:

Role: Act as [who should answer: tutor, examiner, editor].
Task: [one clear sentence of what you want].
Context: [who you are, your level, what you already know].
Reference: [paste notes or text between triple quotes, if any].
Format: [table / 5 bullet points / under 150 words / code with comments].
Example: [one sample of what a good answer looks like].
Steps: [think step by step / check your answer before replying].

Two habits make any template better. First, treat the first answer as a draft and reply with what to change. Second, skip pressure and flattery: Google's checklist says to remove emotional appeals, flattery and artificial pressure from prompts. If you want to use these prompts to organise your revision, our guide on using AI to make a study plan shows how.

Frequently asked questions

Do these prompts work in ChatGPT, Gemini and Claude?

Yes. OpenAI, Google and Anthropic each recommend clear instructions, examples, a stated format, reference text and step-by-step reasoning in their official guides, so the same patterns work across all three.

How long should a prompt be?

As long as it needs to be to remove guesswork. A one-line question is fine for simple facts, while tasks like marking an answer or making flashcards work better with a role, an example and a clear format.

Is it cheating to use AI for homework?

It depends on your school's rules, so check them. Using AI to explain topics, quiz you or check your working is usually allowed and helps you learn. Submitting AI-written work as your own usually is not.

Sources

Related reading

Keep going

More free, checked guides on AI tools and tech skills

Browse all guides