Prompt engineering sounds technical, but at its core it is the practice of writing instructions that consistently produce useful results from an AI model. The best way to start is with a simple framework you can reuse: role, context, task and format. This article explains each part and shows templates you can adapt.
The framework in one line
Tell the model who it is, what it needs to know, what to do, and how to present the result.
Let us break down each element.
1. Role
The role sets perspective, tone and focus. Examples: "You are an experienced technical editor", "You are a patient maths tutor for school students", "You are a customer support agent for a small online shop".
A role does not give the model real credentials, but it nudges vocabulary, depth and style in a useful direction. Keep it specific and realistic. "You are a world-famous genius" adds nothing; "You are a careful proofreader who only fixes errors and does not rewrite style" gives a clear behaviour.
2. Context
Context is the background the model cannot guess: the audience, the situation, the goal, previous decisions and any facts it must use.
Good context answers questions like:
- Who will read this?
- What is it for?
- What has already been decided?
- What facts or data should it rely on?
If the model must use specific information, include it in the prompt. Do not assume it knows your private documents or recent events.
3. Task
State exactly what you want done, using a clear verb: summarise, classify, extract, rewrite, compare, translate, draft, critique, brainstorm. When a job has several steps, number them.
Avoid mixing many goals in one request. Instead of "Fix, improve, shorten and translate this", break it into steps or specify the order.
4. Format
Describe the structure of the answer: bullet points, a table, JSON, a numbered plan, an email with subject line, a maximum word count. Format instructions make outputs predictable and easy to use in other tools.
If you will process the output with code, ask for strict JSON and give the field names.
A complete example
Role: You are a friendly customer support writer for an online clothing store in Nepal.
Context: A customer received the wrong size. Our policy is free exchange within
7 days and we pay shipping. The customer name is Sita.
Task: Write a reply apologising and explaining the next steps.
Format: A short email (under 120 words) with a subject line and a clear call to action.
This single prompt removes ambiguity, so the result is likely to be close to what you need.
Extracting structured data
Prompt engineering is especially valuable when you need machine-readable output. Here is an example prompt for turning messy text into JSON:
Role: You are a data extraction tool.
Task: Extract the fields from the message below.
Format: Return only valid JSON with keys: name, phone, product, quantity.
If a field is missing, use null.
Message: "Hi, this is Ramesh, 9800000000. Please send 3 water filters."
A good result would be:
{"name": "Ramesh", "phone": "9800000000", "product": "water filter", "quantity": 3}
In real software you should still validate the JSON in code, because models can occasionally produce malformed output.
Testing and improving prompts
Treat a prompt like a small piece of software.
- Write a first version using the framework.
- Try it on several different inputs, including difficult ones.
- Note failures: too long, wrong tone, missing facts, wrong format.
- Adjust one thing at a time so you know what helped.
- Save good versions with a note on when to use them.
For production applications, keep a small test set of example inputs and expected outputs, and re-run it whenever you change the prompt or the model.
Common pitfalls
- Conflicting instructions: "Be brief" and "explain in detail" confuse the model.
- Hidden assumptions: words like "recent" or "usual" without definition.
- No success criteria: say what a good answer looks like.
- Overlong prompts: pile-ups of rules are hard to follow. Prioritise.
- Blind trust: always review facts, calculations and citations.
Frequently Asked Questions
Is prompt engineering a real job?
Writing good prompts is a real skill, but it is usually part of broader roles such as developer, analyst or content specialist rather than a stand-alone career.
Will prompt engineering become obsolete?
Models get better at understanding vague requests, but clearly stating goals, context and format will remain valuable, especially in software that depends on reliable output.
Do I need to know programming?
No for everyday use. Programming helps when you want to automate prompts, test them systematically or build apps.
How is it different from searching on Google?
A search engine finds existing pages. A language model generates a new answer from your instructions, so the structure and detail of your request shape the result.
Conclusion
Start with role, context, task and format, then test and refine. This simple structure makes AI answers more relevant, consistent and easier to use, whether you are writing an email or building an application.