في هذه الصفحة
الدّرس 1 من 6
تشريح المطالبة
ما ستتعلّمه
- تجزئة المطالبة إلى أجزائها الوظيفيّة السّتّة
- تشخيص المطالبة الفاشلة بمعرفة الجزء الغائب
- بناء قالب شخصي أوضح ممّا تكتبه اليوم
Every prompt you write has anatomy, whether you designed it or not. A vague one-liner like "write me something about dogs" still has an instruction ("write") and a topic ("dogs"). The problem is everything it does not have. This lesson teaches you the six functional parts of a prompt so you can diagnose failures instead of guessing.
The six parts
Every effective prompt is built from up to six parts. Not every prompt needs all six, but knowing the full set lets you decide what to include deliberately rather than by accident.
1. Instruction — The verb. What should the model do? Summarize, classify, translate, generate, compare. A prompt without a clear instruction forces the model to guess your intent.
2. Context — The background the model needs. This could be a document to summarize, a codebase description, or domain knowledge the model lacks. Without context, the model fills gaps with its training data, which may not match your situation.
3. Constraints — Guardrails. "No more than 3 sentences." "Use formal English." "Do not mention competitor products." Constraints prevent the model from wandering.
4. Examples — Input/output pairs that show the model what you want. We will dedicate an entire lesson to these later, but even one example can dramatically shift output quality.
5. Output spec — The shape of the response. JSON with specific keys? A markdown table? Bullet points? When downstream code needs to parse the output, this part is non-negotiable.
6. Persona — The role the model adopts. "You are a senior Python developer" changes tone, vocabulary, and the depth of assumed knowledge. Persona shapes everything else.
A weak prompt vs. a strong one
Here is a prompt that fails in production:
Analyze this customer feedback and tell me what to do.
What is missing? There is no context (which feedback?), no constraints (how long should the analysis be?), no output spec (a report? a score? a JSON object?), and no persona. The model will produce something, but it will be generic and unpredictable.
Now compare:
import anthropic
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-opus-4-0",
max_tokens=1024,
system="""You are a product analyst at a B2B SaaS company.
You write concise, actionable analysis.
Never recommend generic advice like 'improve communication.'""",
messages=[
{
"role": "user",
"content": """Analyze the following customer feedback.
<feedback>
We've been using the API for 6 months. The latency is fine but
every time there's a schema change we break. No changelog, no
deprecation warnings. We're evaluating alternatives.
</feedback>
Return your analysis as JSON:
{
"sentiment": "positive" | "neutral" | "negative",
"primary_issue": "string",
"churn_risk": "low" | "medium" | "high",
"recommended_action": "string (one sentence, specific)"
}"""
}
]
)
This second prompt has all six parts: instruction (analyze), context (the feedback in XML tags), constraints (concise, no generic advice), examples (implicitly via the JSON shape), output spec (the JSON schema), and persona (product analyst at a B2B SaaS company). The model now has almost no room to drift.
The diagnostic
When a prompt produces bad output, do not rewrite it from scratch. Instead, run this checklist:
- Is the instruction clear and specific? ("Analyze" is weaker than "classify the sentiment and extract the primary issue.")
- Did I provide enough context, or is the model hallucinating to fill gaps?
- Are my constraints actually constraining? Vague constraints like "be concise" rarely work; "maximum 2 sentences" does.
- Would an example clear up the ambiguity faster than more instructions?
- Did I specify the output format? If the model is giving you prose when you need JSON, this is the missing piece.
- Is the persona appropriate? A "helpful assistant" persona produces different output than a "senior security engineer" persona.
Most failing prompts are missing exactly one or two parts. Finding the gap is faster than rewriting.
Building your template
Once you internalize the six parts, create a personal template. It does not need to be elaborate:
[PERSONA]: Who is the model?
[CONTEXT]: What does it need to know?
[INSTRUCTION]: What should it do?
[CONSTRAINTS]: What should it avoid?
[OUTPUT SPEC]: What shape should the answer take?
[EXAMPLES]: (optional) Show, don't tell.
Fill in the parts that matter for your task. Skip the ones that genuinely do not apply. The template is a thinking tool, not a bureaucratic form.
What's next
Now that you can see the parts, the next lesson — System vs user messages — teaches you where to put them. The split between system and user messages is the structural decision that makes your prompts reusable, cacheable, and maintainable.
كلّ مطالبة تكتبها لها تشريح، صمّمتَه أو لم تصمّمه. عبارة غامضة مثل "اكتب لي شيئًا عن الكلاب" فيها تعليمة ("اكتب") وموضوع ("الكلاب"). المشكلة في ما لا تحتويه. هذا الدّرس يعلّمك الأجزاء الوظيفيّة السّتّة حتّى تشخّص الإخفاقات بدل التّخمين.
الأجزاء السّتّة
كلّ مطالبة فعّالة تتكوّن من ستّة أجزاء كحدّ أقصى. ليست كلّ مطالبة تحتاجها جميعًا، لكن معرفة المجموعة الكاملة تتيح لك الاختيار عمدًا لا مصادفةً.
1. التّعليمة — الفعل. ماذا على النّموذج أن يفعل؟ لخّص، صنّف، ترجم، ولّد، قارن. مطالبة بلا تعليمة واضحة تجبر النّموذج على تخمين نيّتك.
2. السّياق — الخلفيّة التي يحتاجها النّموذج. قد تكون وثيقة للتّلخيص أو وصف قاعدة كود أو معرفة مجال لا يملكها النّموذج. بدون سياق، يملأ النّموذج الفجوات من بيانات تدريبه وقد لا تناسب وضعك.
3. القيود — الحواجز. "لا تتجاوز ثلاث جمل." "استعمل لغة رسميّة." "لا تذكر منتجات المنافسين." القيود تمنع النّموذج من الشّرود.
4. الأمثلة — أزواج مدخل/مخرج تُري النّموذج ما تريده. سنخصّص درسًا كاملًا لها لاحقًا، لكن حتّى مثال واحد قد يغيّر جودة المخرج جذريًّا.
5. مواصفات المخرَج — شكل الاستجابة. JSON بمفاتيح محدّدة؟ جدول Markdown؟ نقاط؟ حين يحتاج كود آخر لتحليل المخرج، هذا الجزء لا يُساوَم عليه.
6. الشّخصيّة — الدّور الذي يتبنّاه النّموذج. "أنت مطوّر Python متقدّم" يغيّر النّبرة والمفردات وعمق المعرفة المفترضة.
التّشخيص
حين تُنتج المطالبة مخرجًا سيّئًا، لا تعد كتابتها من الصّفر. بل شغّل هذه القائمة:
- هل التّعليمة واضحة ومحدّدة؟
- هل قدّمت سياقًا كافيًا أم أنّ النّموذج يهلوس لملء الفجوات؟
- هل القيود تقيّد فعلًا؟
- هل مثال واحد يزيل الغموض أسرع من تعليمات إضافيّة؟
- هل حدّدت شكل المخرج؟
- هل الشّخصيّة مناسبة؟
أغلب المطالبات الفاشلة ينقصها جزء أو اثنان فقط. إيجاد الفجوة أسرع من إعادة الكتابة.
ما التّالي
الآن وقد أصبحت ترى الأجزاء، الدّرس القادم — رسائل النّظام مقابل المستخدم — يعلّمك أين تضعها. التّقسيم بين رسائل النّظام والمستخدم هو القرار البنيوي الذي يجعل مطالباتك قابلة لإعادة الاستعمال والتّخزين المؤقّت والصّيانة.
جرّب بنفسك
خذ مطالبة فشلت مؤخّرًا. عَنوِنْ كلّ جزء فيها. أيّ جزء غائب؟ أضفه. أعد التّشغيل.
تأمّل
أيّ جزء من السّتّة تنساه أكثر؟ لماذا تظنّ ذلك؟