Skip to content
Badr Academy Education
العربية
Badr Academy Education

Browse by topic

Artificial intelligence

Prompt engineering: how to write prompts that get more accurate results

A practical prompt framework – role, task, context, constraints, output format – with before-and-after examples and a way to check answers.

  • Updated:
  • 8 min read
Prompt engineering: how to write prompts that get more accurate results

Try asking an AI tool to “write me an article about nutrition”. Then ask it: “You are a nutritionist writing for secondary-school students. Write a 400-word article about a healthy breakfast before exams, in simple language, with three examples of easy meals and a list of common mistakes.” You will notice a big difference between the two results, even though the tool itself has not changed. What changed is the prompt, and the skill of writing clear, effective prompts is called prompt engineering. In this article we give you a practical framework you can use from today, with examples, common mistakes and a way to evaluate answers.

What you will learn

  • Why the wording of a prompt affects the quality of the answer so much.
  • A five-part framework for writing any prompt: role, task, context, constraints and output format.
  • More advanced techniques: examples, step-by-step reasoning and splitting a task.
  • How to review a model’s answer before you rely on it.

Why does the wording of a prompt matter?

As we explained in what large language models are, a model generates the most likely text based on what is in front of it. When a prompt is general, the range of likely answers is very wide, so the model picks an “average” answer that suits the largest number of readers – and it often does not suit you in particular. The more you add about your goal, your audience and the shape you want, the narrower the range becomes and the closer the answer gets to what you actually need.

Think of it as briefing a new colleague. If you say “prepare a presentation”, they will need many answers: about what? For whom? How many slides? By when? A model usually does not ask you; it guesses. Your job is to reduce the room for guessing.

The five-part framework for a good prompt

There is no magic template that fits every case, but these five parts cover most of what you need. You do not have to use all of them every time; use what suits the task.

1RoleWho should the modelbe? A teacher, aneditor, a programmer2TaskA clear verb:explain, summarise,compare, write3ContextThe audience, thegoal and theinformation it needs4ConstraintsLength, language,tone and what toavoid5Output formatA list, a table,paragraphs or code1RoleWho should the model be? A teacher,an editor, a programmer2TaskA clear verb: explain, summarise,compare, write3ContextThe audience, the goal and theinformation it needs4ConstraintsLength, language, tone and what toavoid5Output formatA list, a table, paragraphs or code
A five-part framework for writing a clear AI prompt

1. Role

A line such as “You are a physics teacher for lower-secondary students” steers the level of language and the kind of examples. A role does not give the model new expertise, but it helps it choose the right style from the many it has learned.

2. Task

Start with a clear, specific verb. “Explain” is different from “summarise”, and “compare” is different from “suggest”. If you have more than one task, number them instead of merging them into one long sentence.

3. Context

This is where you put what the model does not know: who is the audience? What is the text for? Which information must it rely on? If you have a text or data, paste it, separate it with clear markers such as three quotation marks, and tell the model to rely on it.

4. Constraints

State the approximate length, the language, the level of formality and the things you do not want. For example: “Do not use technical terms without explaining them”, or “Do not mention commercial product names”.

5. Output format

If you want a table, ask for a table and name its columns. If you want bullet points, say so. Stating the format saves you time rearranging later and makes it easier to compare answers.

Before-and-after examples

Weak prompt Improved prompt What changed?
Explain fractions to me. You are a maths teacher for a child in year four. Explain adding fractions with different denominators using the example of sharing a pizza, then give me three exercises with their answers at the end. We added the role, the audience, the example and the output format.
Write a post about the course. Write a Facebook post of about 80 words announcing a Python course for beginners. The audience is parents of students aged 12 to 16. Focus on the practical benefit, end with an invitation to visit the course page, and do not exaggerate. We set the platform, the length, the audience, the message and the constraints.
Fix this code. This Python code is supposed to calculate the average mark but raises an error when the list is empty. Explain the cause of the error first, then suggest a simple change with a comment on every line you altered. We described the expected behaviour and the problem, and asked for the explanation before the fix.

More advanced techniques worth trying

Give it examples

When you want a specific style or format, the easiest way is to show two or three examples. This is called “few-shot” prompting. For instance, if you want to classify customer messages, give it three messages with their correct category, then the new message.

Ask for step-by-step reasoning

For problems that need reasoning, such as calculations or planning, it helps to ask the model to show its steps before the final answer. That makes mistakes easier to spot, because you can see where the reasoning went off course.

Split a large task

Instead of asking for “a complete marketing plan” in one message, start with the audience analysis, then the key messages, then the channels, then the timeline. Each step builds on the one before, and you can correct the course at every stage. The same idea is the foundation of AI agents, which split tasks automatically.

Ask it to ask you

A simple line such as “Before you start, ask me for any information you need” turns the model from a guesser into a partner in the conversation, and it often reveals angles you had not thought of.

For a deeper understanding of how these models work and where their limits lie, Andrej Karpathy – one of the best-known researchers in the field – gives an accessible talk of about an hour:

Video: “[1hr Talk] Intro to Large Language Models” – Andrej Karpathy on YouTube (in English).

Common beginner mistakes

  • The crowded prompt: ten tasks in one paragraph with no order. The result is usually that some are ignored.
  • Assuming the model knows what is in your head: your project’s name, a decision you made yesterday, your organisation’s style. Write it down.
  • Accepting the first answer: the conversation is a chance to improve. Say “make it shorter”, “add an everyday example” or “rewrite it for a younger audience”.
  • Sharing sensitive data: do not put passwords or the personal data of students or customers into public tools.
  • Treating the answer as final truth: especially for numbers, references, and medical or legal information.

How to evaluate an answer before using it

Keep a short checklist: did it answer the question you actually asked? Did it respect the constraints? Is there information that needs checking? Is the tone right for your audience? If the task matters, ask the model itself to review its answer against criteria you set, and then review it yourself. Human review remains the final step you cannot skip.

A practical exercise to start today

Choose a real task you do every week, such as summarising a lesson or writing an email. Write a prompt for it using the five-part framework and save it in a file. Each time you use it, improve one sentence based on the result. Within a few weeks you will have a set of tested prompts that save you real time.

Prompt engineering is a core skill in the artificial intelligence course at Badr Academy Education, where we practise it on real tasks with peer review. To see where this skill sits in a wider learning journey, read a beginner’s map for learning AI or try the Find your path tool, and browse the learning library for further resources.

The takeaway

A good prompt is like a clear brief for a clever colleague who knows nothing about your situation: set the role and the task, give the context, add the constraints and ask for the format you want. Then improve through conversation, and review before you rely on it.

© 2026 Badr Academy Education – this content is exclusive to Badr Academy Education. Short quotations are welcome with the source and a link to this page.

Share this article

Comments (0)

You can comment without an account; your comment appears after review, and the academy may edit it before publishing.

Add a comment

Your e-mail will not be published. Required fields are marked *

No comments yet – be the first to join in.