Prompt Engineering
A new team member does good work when you tell them the goal, give them the facts, and show them one finished example. A language model is the same. Prompt engineering is the skill of writing that brief well, and then testing it.
7 min read7 মিনিটে পড়া যায় · 6 sections6টি সেকশন · 5 sources5টি সোর্স · updated Nov 2026আপডেট: Nov 2026
In plain words
A prompt is the text that you send to a language model: the instructions, the data, and the question. Prompt engineering is the work of writing these instructions so that the model gives the output you need, again and again Source 3সোর্স 3.
Anthropic gives a useful picture: treat the model like a very capable new employee who does not know your rules or your workflow. The more exactly you say what you want, the better the result Source 2সোর্স 2.
Prompt engineering starts before the first prompt. You need a clear definition of success, a way to test against it, and a first draft to improve Source 1সোর্স 1. Not every problem is a prompt problem. For example, a different model can sometimes fix latency or cost more easily than a new prompt Source 1সোর্স 1.
সহজ English
A prompt is the text that you send to a language model. It holds the instructions, the data, and the question. Prompt engineering is the work of writing these instructions well. The goal is that the model gives the output you need, every time Source 3সোর্স 3.
Anthropic gives a useful picture. Think of the model as a very capable new employee. This employee does not know your rules or your workflow. The more exactly you say what you want, the better the result Source 2সোর্স 2.
The work starts before the first prompt. You need a clear idea of success. You need a way to test against it. You need a first draft to improve Source 1সোর্স 1. Not every problem is a prompt problem. Sometimes a different model fixes speed or cost more easily Source 1সোর্স 1.
বাংলা ব্যাখ্যা
প্রম্পট (prompt) হলো সেই টেক্সট যা আপনি একটা ল্যাঙ্গুয়েজ মডেলকে পাঠান। এতে থাকে নির্দেশনা, ডেটা, আর প্রশ্ন। প্রম্পট ইঞ্জিনিয়ারিং হলো এই নির্দেশনা এমনভাবে লেখার কাজ, যাতে মডেল বারবার আপনার দরকারি আউটপুট দেয় Source 3সোর্স 3।
Anthropic একটা কাজের ছবি দেয়। মডেলকে একজন খুব দক্ষ নতুন কর্মী হিসেবে ভাবুন। এই কর্মী আপনার নিয়ম বা কাজের ধারা জানে না। আপনি যত নিখুঁতভাবে বলবেন কী চান, ফল তত ভালো হবে Source 2সোর্স 2।
কাজটা প্রথম প্রম্পটের আগেই শুরু হয়। আপনার দরকার সাফল্যের একটা পরিষ্কার সংজ্ঞা, তার বিপরীতে টেস্ট করার একটা উপায়, আর উন্নত করার জন্য একটা প্রথম খসড়া Source 1সোর্স 1। সব সমস্যা প্রম্পটের সমস্যা নয়। কখনো অন্য একটা মডেল লেটেন্সি (latency) বা খরচ সহজে ঠিক করে দেয় Source 1সোর্স 1।
How it works
The parts of a good prompt
OpenAI suggests that a developer message often has these parts, usually in this order Source 3সোর্স 3:
| Part | What it gives the model |
|---|---|
| Identity | The purpose, the style, and the high-level goals |
| Instructions | The rules: what to do and what never to do |
| Examples | Sample inputs with the output you want |
| Context | Extra data the model needs, such as private documents. It is often best near the end. |
Techniques that help
- Be clear and direct. Say the output format and the limits. Use a numbered list when the order of the steps matters Source 2সোর্স 2. A quick check: give the prompt to a colleague with little context. If the colleague is confused, the model will be too Source 2সোর্স 2.
- Give the reason. An instruction with its reason helps the model aim its answer, and the model can apply the reason to new cases Source 2সোর্স 2.
- Show examples. A prompt with a few examples is a few-shot prompt. A prompt with none is a zero-shot prompt Source 4সোর্স 4. Anthropic suggests 3 to 5 examples that are relevant and varied, inside
<example>tags Source 2সোর্স 2. Keep the same format in all examples Source 4সোর্স 4. - Mark the parts. XML tags such as
<instructions>,<context>, and<input>keep the parts of a long prompt apart Source 2সোর্স 2. Markdown headings also work. Pick one style and keep it Source 4সোর্স 4. - Say what to do, not what to avoid. "Write flowing paragraphs" works better than "Do not use Markdown" Source 2সোর্স 2.
- Put long documents first. For inputs of about 20,000 tokens or more, put the documents near the top and the question at the end Source 2সোর্স 2.
- Set a role. One sentence in the system prompt can set the focus and the tone Source 2সোর্স 2.
This request sets a role in the system field and sends one user message Source 2সোর্স 2:
import anthropic
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-opus-5-5",
max_tokens=1024,
system="You are a senior QA engineer. You write short, exact test cases.",
messages=[
{"role": "user", "content": "<feature>Password reset by email</feature>\nWrite 5 test cases as a Markdown table: ID, Steps, Expected result."}
],
)
print(message.content)Same prompt, different model
Different models, and even different snapshots of one model family, can answer the same prompt in different ways. OpenAI recommends that you pin production apps to a fixed model snapshot, and that you build evals that measure how prompts behave Source 3সোর্স 3.
সহজ English
OpenAI suggests that a good instruction message has 4 parts, usually in this order Source 3সোর্স 3. The identity gives the purpose, the style, and the goals. The instructions give the rules: what to do and what never to do. The examples show sample inputs and the output you want. The context gives extra data, such as private documents. It is often best near the end.
Some techniques help:
- Be clear and direct. Say the format and the limits. Use a numbered list when the order of steps matters Source 2সোর্স 2. Test it: give the prompt to a colleague who knows little about the task. If the colleague is confused, the model will be too Source 2সোর্স 2.
- Give the reason. Say why a rule exists. The model then aims its answer better, and it can apply the reason to new cases Source 2সোর্স 2.
- Show examples. A prompt with a few examples is a few-shot prompt. A prompt with no examples is a zero-shot prompt Source 4সোর্স 4. Anthropic suggests 3 to 5 relevant and varied examples, inside
<example>tags Source 2সোর্স 2. Use the same format in all of them Source 4সোর্স 4. - Mark the parts. Tags such as
<instructions>and<context>keep the parts of a long prompt apart Source 2সোর্স 2. Markdown headings also work. Pick one style and keep it Source 4সোর্স 4. - Say what to do. "Write flowing paragraphs" works better than "Do not use Markdown" Source 2সোর্স 2.
- Put long documents first. For very long inputs (about 20,000 tokens or more), put the documents at the top and the question at the end Source 2সোর্স 2.
- Set a role. One sentence in the system prompt can set the focus and the tone Source 2সোর্স 2. The code example in the Technical text does this with the
systemfield.
Different models can answer the same prompt in different ways. Even different versions of one model can do this. OpenAI recommends two things. Pin your production app to one fixed model version. Build tests (evals) that measure how your prompts behave Source 3সোর্স 3.
বাংলা ব্যাখ্যা
OpenAI বলে, একটা ভালো নির্দেশনা মেসেজে সাধারণত এই ক্রমে ৪টা অংশ থাকে Source 3সোর্স 3। Identity দেয় উদ্দেশ্য, স্টাইল, আর লক্ষ্য। Instructions দেয় নিয়ম: কী করতে হবে আর কী কখনো করা যাবে না। Examples দেখায় নমুনা ইনপুট আর আপনি যে আউটপুট চান। Context দেয় বাড়তি ডেটা, যেমন প্রাইভেট ডকুমেন্ট। এটা প্রায়ই শেষের দিকে রাখা ভালো।
কিছু কৌশল কাজে দেয়:
- পরিষ্কার ও সরাসরি লিখুন। ফরম্যাট আর সীমা বলে দিন। ধাপের ক্রম জরুরি হলে নম্বর দেওয়া তালিকা ব্যবহার করুন Source 2সোর্স 2। একটা পরীক্ষা: কাজটা কম জানে এমন একজন সহকর্মীকে প্রম্পটটা দিন। সে বিভ্রান্ত হলে মডেলও হবে Source 2সোর্স 2।
- কারণ বলুন। একটা নিয়ম কেন আছে তা বলুন। তাহলে মডেল উত্তর ভালোভাবে লক্ষ্যে রাখে, আর কারণটা নতুন ক্ষেত্রেও খাটায় Source 2সোর্স 2।
- উদাহরণ দেখান। কয়েকটা উদাহরণ সহ প্রম্পট হলো few-shot প্রম্পট। কোনো উদাহরণ ছাড়া প্রম্পট হলো zero-shot প্রম্পট Source 4সোর্স 4। Anthropic বলে
<example>ট্যাগের ভেতরে ৩ থেকে ৫টা প্রাসঙ্গিক ও বৈচিত্র্যময় উদাহরণ দিতে Source 2সোর্স 2। সব উদাহরণে একই ফরম্যাট রাখুন Source 4সোর্স 4। - অংশগুলো চিহ্নিত করুন।
<instructions>আর<context>এর মতো ট্যাগ লম্বা প্রম্পটের অংশগুলো আলাদা রাখে Source 2সোর্স 2। Markdown হেডিংও কাজ করে। একটা স্টাইল বেছে নিয়ে সেটাই রাখুন Source 4সোর্স 4। - কী করতে হবে বলুন। "Do not use Markdown" এর চেয়ে "Write flowing paragraphs" ভালো কাজ করে Source 2সোর্স 2।
- লম্বা ডকুমেন্ট আগে দিন। খুব লম্বা ইনপুটে (প্রায় ২০,০০০ টোকেন বা বেশি) ডকুমেন্ট উপরে আর প্রশ্ন শেষে রাখুন Source 2সোর্স 2।
- একটা রোল (role) দিন। সিস্টেম প্রম্পটে একটা বাক্যই ফোকাস আর টোন ঠিক করতে পারে Source 2সোর্স 2। Technical লেখার কোড উদাহরণ এটা
systemফিল্ড দিয়ে করে।
একই প্রম্পটে ভিন্ন মডেল ভিন্নভাবে উত্তর দিতে পারে। একই মডেলের ভিন্ন ভার্সনও এটা করতে পারে। OpenAI দুটো জিনিস বলে। প্রোডাকশন অ্যাপকে একটা নির্দিষ্ট মডেল ভার্সনে পিন (pin) করুন। আপনার প্রম্পট কেমন আচরণ করে তা মাপতে টেস্ট (evals) বানান Source 3সোর্স 3।
A real-life example
A QA team builds a small tool that turns a user story into test cases. The first prompt is one line: "Write test cases for this story." The output changes every run: sometimes a list, sometimes a table, sometimes with no negative cases.
The team rewrites the prompt with the parts above Source 3সোর্স 3:
You are a senior QA engineer for a banking web app.
<instructions>
1. Read the user story in <story>.
2. Write positive, negative, and boundary test cases.
3. Return only a Markdown table with the columns ID, Type, Steps, Expected result.
Testers paste this table into the test management tool, so keep exactly these columns.
</instructions>
<example>
| ID | Type | Steps | Expected result |
|---|---|---|---|
| TC-01 | Negative | Enter an amount of 0 and select Send | The app shows "Enter an amount above 0" |
</example>
<story>
{{USER_STORY}}
</story>The prompt now has a role, numbered steps, the reason for the format, one example, and tags around the data Source 2সোর্স 2. The team keeps 20 stories with known good outputs, and runs them again after each prompt change. This is the eval that the success criteria need Source 1সোর্স 1.
সহজ English
A QA team builds a small tool. It turns a user story into test cases. The first prompt is one line: "Write test cases for this story." The output changes on every run. Sometimes it is a list. Sometimes it is a table. Sometimes it has no negative cases.
The team rewrites the prompt with the 4 parts Source 3সোর্স 3. The new prompt does these things:
- It gives a role: a senior QA engineer for a banking web app.
- It gives numbered steps: read the story, write positive, negative, and boundary cases, and return only a table with 4 fixed columns.
- It gives the reason: testers paste the table into the test tool.
- It shows one example row.
- It puts the story inside
<story>tags.
These are the techniques from the section above Source 2সোর্স 2. The team also keeps 20 stories with known good outputs. They run them again after each prompt change. This is the test that the success criteria need Source 1সোর্স 1.
বাংলা ব্যাখ্যা
একটা QA টিম একটা ছোট টুল বানায়। এটা একটা ইউজার স্টোরি থেকে টেস্ট কেস বানায়। প্রথম প্রম্পট এক লাইনের: "Write test cases for this story." প্রতিবার আউটপুট বদলে যায়। কখনো তালিকা, কখনো টেবিল, কখনো কোনো নেগেটিভ কেস নেই।
টিম ৪টা অংশ দিয়ে প্রম্পটটা আবার লেখে Source 3সোর্স 3। নতুন প্রম্পট এই কাজগুলো করে:
- একটা রোল দেয়: একটা ব্যাংকিং ওয়েব অ্যাপের সিনিয়র QA ইঞ্জিনিয়ার।
- নম্বর দেওয়া ধাপ দেয়: স্টোরি পড়া, পজিটিভ, নেগেটিভ আর বাউন্ডারি কেস লেখা, আর শুধু ৪টা নির্দিষ্ট কলামের একটা টেবিল দেওয়া।
- কারণ বলে: টেস্টাররা টেবিলটা টেস্ট টুলে পেস্ট করে।
- একটা উদাহরণ সারি দেখায়।
- স্টোরিটা
<story>ট্যাগের ভেতরে রাখে।
এগুলো উপরের অংশের কৌশল Source 2সোর্স 2। টিম জানা ভালো আউটপুট সহ ২০টা স্টোরিও রাখে। প্রতিটা প্রম্পট বদলের পর তারা এগুলো আবার চালায়। সাফল্যের সংজ্ঞার জন্য এই টেস্টটাই দরকার Source 1সোর্স 1।
Common mistakes
- A vague task. "Make a dashboard" gives a basic result. If you want more than the minimum, ask for it in words Source 2সোর্স 2.
- Only "do not" rules. A list of bans tells the model what to avoid, but not what to write. Say the format you want Source 2সোর্স 2.
- Examples in different formats. The model copies the format of the examples, so mixed formats give mixed output Source 4সোর্স 4.
- User text mixed with instructions. Text from a user, a web page, or a file can change the behavior of the model. This is prompt injection, and it can be direct (from the user) or indirect (from outside content) Source 5সোর্স 5. Mark the outside text clearly as untrusted, and check the output format with code Source 5সোর্স 5. Prompt rules can lower the risk, but OWASP says it is unclear whether any method fully prevents prompt injection Source 5সোর্স 5.
- No tests after a change. A new model snapshot can change the behavior of the same prompt Source 3সোর্স 3. Without evals, you do not see the change.
সহজ English
- A vague task. "Make a dashboard" gives a basic result. If you want more than the minimum, ask for it in words Source 2সোর্স 2.
- Only "do not" rules. A list of bans says what to avoid. It does not say what to write. Say the format you want Source 2সোর্স 2.
- Examples in different formats. The model copies the format of the examples. Mixed formats give mixed output Source 4সোর্স 4.
- User text mixed with instructions. Text from a user, a web page, or a file can change what the model does. This is prompt injection. It can be direct (from the user) or indirect (from outside content) Source 5সোর্স 5. Mark the outside text clearly as untrusted. Check the output format with code Source 5সোর্স 5. Prompt rules can lower the risk. OWASP says it is unclear whether any method fully prevents prompt injection Source 5সোর্স 5.
- No tests after a change. A new model version can change how the same prompt behaves Source 3সোর্স 3. Without tests, you do not see the change.
বাংলা ব্যাখ্যা
- অস্পষ্ট কাজ। "Make a dashboard" একটা সাধারণ ফল দেয়। ন্যূনতমের বেশি চাইলে সেটা কথায় বলে দিন Source 2সোর্স 2।
- শুধু "করো না" নিয়ম। নিষেধের তালিকা বলে কী এড়াতে হবে। কী লিখতে হবে তা বলে না। আপনি যে ফরম্যাট চান তা বলুন Source 2সোর্স 2।
- ভিন্ন ফরম্যাটের উদাহরণ। মডেল উদাহরণের ফরম্যাট নকল করে। মেশানো ফরম্যাট মেশানো আউটপুট দেয় Source 4সোর্স 4।
- ইউজারের টেক্সট নির্দেশনার সাথে মেশানো। ইউজার, ওয়েব পেজ, বা ফাইলের টেক্সট মডেলের আচরণ বদলে দিতে পারে। এটা প্রম্পট ইনজেকশন (prompt injection)। এটা সরাসরি (ইউজার থেকে) বা পরোক্ষ (বাইরের কনটেন্ট থেকে) হতে পারে Source 5সোর্স 5। বাইরের টেক্সটকে পরিষ্কারভাবে অবিশ্বস্ত হিসেবে চিহ্নিত করুন। কোড দিয়ে আউটপুট ফরম্যাট চেক করুন Source 5সোর্স 5। প্রম্পটের নিয়ম ঝুঁকি কমাতে পারে, কিন্তু OWASP বলে কোনো পদ্ধতি এটা পুরোপুরি ঠেকাতে পারে কি না তা অস্পষ্ট Source 5সোর্স 5।
- বদলের পর কোনো টেস্ট নেই। নতুন মডেল ভার্সন একই প্রম্পটের আচরণ বদলে দিতে পারে Source 3সোর্স 3। টেস্ট না থাকলে আপনি বদলটা দেখতে পান না।
What a tester can check
Tutorial advice
These test ideas are the tutorial's own advice.
- Keep a golden set. Save 10 to 30 real inputs with outputs that a person approved. Run them after every prompt change and every model change.
- Run each input more than once. The same prompt can give different answers. Run each case 3 to 5 times and compare.
- Check the format with code. If the prompt asks for a table or JSON, parse it in the test. Do not trust the eye.
- Try hostile input. Put "ignore the instructions above" inside the user story or the uploaded file. The output must keep the same role and format.
- Test the edges. Send an empty input, a very long input, and an input in another language.
- Version the prompt. Keep the prompt in the repo, next to its tests, so a review shows each change.
সহজ English
These test ideas are the tutorial's own advice.
- Keep a golden set. Save 10 to 30 real inputs. Keep outputs that a person approved. Run them after every prompt change and every model change.
- Run each input more than once. The same prompt can give different answers. Run each case 3 to 5 times. Compare the results.
- Check the format with code. If the prompt asks for a table or JSON, parse it in the test.
- Try hostile input. Put "ignore the instructions above" inside the story or the file. The output must keep the same role and format.
- Test the edges. Send an empty input, a very long input, and an input in another language.
- Version the prompt. Keep the prompt in the repo, next to its tests. A review then shows each change.
বাংলা ব্যাখ্যা
এই টেস্ট আইডিয়াগুলো টিউটোরিয়ালের নিজের পরামর্শ।
- একটা গোল্ডেন সেট রাখুন। ১০ থেকে ৩০টা আসল ইনপুট সেভ করুন, সাথে একজন মানুষের অনুমোদিত আউটপুট। প্রতিটা প্রম্পট বদল আর মডেল বদলের পর এগুলো চালান।
- প্রতিটা ইনপুট একাধিকবার চালান। একই প্রম্পট ভিন্ন উত্তর দিতে পারে। প্রতিটা কেস ৩ থেকে ৫ বার চালিয়ে তুলনা করুন।
- কোড দিয়ে ফরম্যাট চেক করুন। প্রম্পট টেবিল বা JSON চাইলে টেস্টে সেটা পার্স (parse) করুন।
- ক্ষতিকর ইনপুট দিন। স্টোরি বা ফাইলের ভেতরে "ignore the instructions above" লিখুন। আউটপুটকে একই রোল আর ফরম্যাট রাখতে হবে।
- সীমানা টেস্ট করুন। খালি ইনপুট, খুব লম্বা ইনপুট, আর অন্য ভাষার ইনপুট পাঠান।
- প্রম্পটের ভার্সন রাখুন। প্রম্পটটা রিপোতে তার টেস্টের পাশে রাখুন। তাহলে রিভিউতে প্রতিটা বদল দেখা যায়।
Key words
| Term | Meaning |
|---|---|
| Prompt | The text you send to a model: instructions, data, and the question |
| System prompt | Instructions in a separate field, used for the role and the rules Source 2সোর্স 2 |
| Few-shot prompt | A prompt with a few examples of input and output Source 4সোর্স 4 |
| Zero-shot prompt | A prompt with no examples Source 4সোর্স 4 |
| XML tags | Labels such as <context> that mark the parts of a prompt Source 2সোর্স 2 |
| Prompt injection | Input that changes the behavior of the model in a way you did not intend Source 5সোর্স 5 |
| Model snapshot | One fixed version of a model, which you can pin Source 3সোর্স 3 |