Prompt Engineering Basics: Roles, Clear Instructions, Context, Output Format and the Prompt Checklist

LLM Development 50 min min read Updated: Nov 21, 2026 Beginner
Prompt Engineering Basics: Roles, Clear Instructions, Context, Output Format and the Prompt Checklist
Beginner Topic 1 of 3

What Is a Prompt?

A prompt is the text you send to a model. A better prompt gives a better answer. Think of the model as a very fast helper who knows nothing about your situation unless you tell it.

The Roles

RoleUsed for
systemRules and behavior that apply to the whole chat, such as tone and limits
userThe person's request
assistantThe model's earlier replies, sent back as history

The Five Parts of a Good Prompt

  1. Task: what to do, in one clear sentence
  2. Context: facts the model needs
  3. Rules: limits, such as length or things to avoid
  4. Format: how the answer should look
  5. Examples (optional): one or two samples

Before and After

Weak promptBetter prompt
Tell me about our refund policyYou are a support agent. Using only the policy text below, explain the refund rules to a customer in 3 short bullet points. If the answer is not in the text, say 'I do not know'.
Fix this codeFind the bug in this Python function, explain it in one sentence, then show the fixed code only.

Build a Prompt in Code

python def build_prompt(task, context, rules, fmt): return (f"Task: {task}\n\nContext:\n{context}\n\n" f"Rules:\n- " + "\n- ".join(rules) + f"\n\nFormat: {fmt}") p = build_prompt( task="Summarize the customer email.", context="Hi, my order #123 arrived broken. I want a replacement.", rules=["Max 20 words", "Do not invent facts"], fmt="One sentence", ) print(p)
Result

Task: Summarize the customer email. | | Context: | Hi, my order #123 arrived broken. I want a replacement. | | Rules: | - Max 20 words | - Do not invent facts | | Format: One sentence

Tips That Work

  • Be specific about the audience and length
  • Say what to do, not only what to avoid
  • Put long documents inside clear markers such as <document> ... </document>
  • Ask for a format you can parse, such as JSON or a list
  • If something fails, change one thing and test again
Keep prompts in files Store prompts as text files or constants so you can version and test them like code.
Do not put secrets in prompts Anything in a prompt can leak in an answer. Keep keys and private data out.

Practice

  1. Rewrite a vague prompt of your own using the five parts
  2. Run both versions and compare
  3. Save the winner in a file

Conclusion

Clear task, context, rules and format make prompts reliable. Test and version them like code.

Quick Summary: Roles; five parts; before and after; template; tips.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators