Loading
Loading
Professional prompting is not a secret — it's a learnable skill. In this lesson you'll learn the framework that top users employ to get exceptional results.
The most common problem:
❌ "Write me an email"
This gives Claude insufficient information. The result will be generic and unhelpful.
✅ "Write a professional email to a client asking about a delivery delay. Style: professional and respectful. Length: two paragraphs. Explain the 3-day delay due to shipping and confirm the apology."
This prompt gives Claude everything it needs.
| Letter | Meaning | Example | |--------|---------|---------| | C — Context | Full background | "I'm a developer working on a React app..." | | R — Role | Required role | "Act as a Senior Code Reviewer" | | A — Action | Required action | "Review this code and tell me the issues" | | F — Format | Answer format | "Bullet list, most important first" | | T — Tone | Tone | "Direct and practical, no flattery" |
Ask Claude to think out loud:
Think step by step:
1. Explain the problem
2. List possible solutions
3. Compare the solutions
4. Give your final recommendation
This notably increases accuracy for complex problems.
Give examples of what you want:
Convert news headlines to a neutral tone.
Example 1:
Original: "Government fails to manage crisis"
Neutral: "Officials face criticism over crisis management"
Example 2:
Original: "Prime Minister avoids answering"
Neutral: "Prime Minister delays response to questions"
Now convert: "Company ruthlessly exploits workers"
Claude responds excellently to XML tags:
<task>Python code review</task>
<code>
def calculate(x, y):
return x/y
</code>
<requirements>
- Find logical errors
- Suggest performance improvements
- Add error handling
</requirements>
<format>Numbered list by priority</format>
Don't stop at the first answer:
Good answer. Now:
- Make it 30% shorter
- Add a practical example in the second paragraph
- Change the tone to be more motivating
| Mistake | Problem | Solution | |---------|---------|---------| | Vague prompt | Claude guesses your intent | Be specific | | Multiple tasks at once | Scattered focus | One task per prompt | | Ignoring context | Generic answers | Provide ample context | | Accepting first answer | Missing improvement potential | Iterate and refine |
For code:
You are a senior developer expert in [language].
Review the following code, look for: bugs, performance, security.
Answer in a numbered list by severity.
Code: [code here]
For writing:
Write a [type] about [topic].
Audience: [who will read it].
Tone: [formal/informal/technical].
Length: [X words].
Must include: [key points].
For analysis:
Analyze [topic] from two angles: pros and cons.
Then give your final recommendation with justification.
# مثال عملي: مقارنة بين مطالبة ضعيفة ومطالبة قوية
# هذا كود Python يوضح كيف يمكن هيكلة المطالبات برمجياً
import anthropic
client = anthropic.Anthropic()
# ❌ مطالبة ضعيفة
weak_prompt = "اكتب كوداً"
# ✅ مطالبة قوية باستخدام إطار CRAFT
def build_craft_prompt(
context: str,
role: str,
action: str,
output_format: str,
tone: str,
additional: str = ""
) -> str:
return f"""<context>{context}</context>
<role>{role}</role>
<action>{action}</action>
<format>{output_format}</format>
<tone>{tone}</tone>
{f"<additional>{additional}</additional>" if additional else ""}"""
# بناء مطالبة احترافية
professional_prompt = build_craft_prompt(
context="أنا مطور Python أعمل على API لتطبيق ويب يستخدم FastAPI",
role="Senior Python Developer متخصص في APIs وأمان التطبيقات",
action="اكتب دالة للتحقق من صحة الـ JWT token مع error handling كامل",
output_format="كود Python مع تعليقات واضحة، ثم شرح مختصر للاختيارات التقنية",
tone="تقني ودقيق، افترض خبرة متوسطة في Python",
additional="استخدم مكتبة PyJWT، تعامل مع حالات expired/invalid/missing token"
)
print("=== المطالبة المهيكلة ===")
print(professional_prompt)
# إرسال المطالبة لـ Claude
message = client.messages.create(
model="claude-opus-4-8",
max_tokens=1024,
messages=[
{"role": "user", "content": professional_prompt}
]
)
print("
=== رد Claude ===")
print(message.content[0].text)
# ─────────────────────────────────────────
# نموذج: Chain-of-Thought template
cot_template = """
حلّل المشكلة التالية خطوة بخطوة:
المشكلة: {problem}
الخطوات المطلوبة:
1. افهم المشكلة وأعد صياغتها بكلماتك
2. حدد المعطيات والمجاهيل
3. اقترح 3 حلول ممكنة
4. قيّم كل حل (إيجابيات/سلبيات/تكلفة)
5. اختر الأفضل وبرر اختيارك
أجب بتنسيق markdown منظم.
"""
problem = "خادمنا يستهلك 90% من الذاكرة تحت الحمل العالي ونريد تحسين الأداء"
final_prompt = cot_template.format(problem=problem)
print("
=== مطالبة Chain-of-Thought ===")
print(final_prompt[:300] + "...")