المشروع الختامي — شحن PR من 200 سطر عبر الأوامر فقط

Code-explainer system prompt

5 دقيقة للقراءة

معظم المهندسين بيستخدموا system prompts قليل. بيحطوا كل حاجة في رسالة الـ user وبيعيدوا لصق نفس التعليمات كل محادثة. الـ system prompt هو فين دور المساعد بيعيش — وللمشروع الختامي، عايز مساعد ضيق شغله الوحيد هو شرح الكود اللي مش متعوّد عليه في الملف اللي هتلمسه.

تمرين تصميم prompt كويس: اكتب الـ system prompt بنفسك الأول، وبعدين اطلب من الموديل يكتب واحد وقارن. دي النسخة بتاعت الموديل:

Write a tight system prompt (under 200 words) for an internal AI tool whose ONLY job is to explain unfamiliar code to junior developers. Constraints the prompt must enforce on the assistant:

  • Always start the answer with a 1-sentence "what this code does" summary.
  • Then a numbered walkthrough, line by line, max 8 numbered items.
  • Refuse to write or modify code; this tool only EXPLAINS.
  • If the code seems intentionally malicious (rm -rf, credential exfil), refuse and say why in 1 sentence.
  • Never invent imports or behaviour not visible in the code.
  • Output in plain markdown only.

Output ONLY the system-prompt text. No commentary around it.

Claude Sonnet 4.5 رجّع:

You are a code explanation assistant for junior developers. Your sole purpose
is to explain unfamiliar code clearly and safely.

Mandatory structure for every response:
1. Start with exactly one sentence summarizing what the code does
2. Follow with a numbered walkthrough (maximum 8 items) explaining the code
   line-by-line or section-by-section
3. Use plain markdown only

Strict constraints:
- NEVER write, modify, suggest, or generate code
- If asked to write or modify code, refuse and redirect to explanation only
- If code appears malicious (e.g., rm -rf, credential theft, data
  exfiltration), refuse in one sentence explaining why
- Only explain what's actually present in the provided code—never assume or
  invent imports, functions, or behavior not shown
- Stick to factual explanation of the code's mechanics, not opinions on quality

If the user provides no code or asks non-explanation questions, remind them
you only explain existing code snippets.

Captured from Claude Sonnet 4.5 (claude-sonnet-4-5) on 2026-04-27. Re-runs may differ slightly.

ده الـ system prompt اللي هتستخدمه لمرحلة الاستكشاف في مشروعك. حطه كرسالة system في chat client بتاعك. دلوقتي كل لصقة لكود مش متعوّد عليه بتجيب شرح منظّم: ملخص جملة، walkthrough لحد 8 خطوات، مفيش imports مخترعة، مفيش آراء عن الستايل.

ليه الـ constraints المحددة دي؟ كل واحدة بتقفل failure mode شفته بيحرق مهندسين:

الـ Constraintالفشل اللي بيمنعه
ملخص جملة الأول"بيعمل إيه؟" مدفون تحت 6 فقرات تفصيل
حد أقصى 8 خطواتWalkthrough بيوصل لـ 30 خطوة ويعيد شرح نفسه
رفض كتابة كودTool drift — الاستكشاف بيبقى refactor بالغلط
رفض الكود الخبيثحواجز قانونية وأخلاقية
ما يخترعش imports/behaviourشروحات مخترعة لكود مش موجود
Markdown عادي بسمخرج أنضف للـ pipe في notes

Constraint "رفض كتابة كود" هو أكتر واحد مفيد. من غيره، المساعد هيشوف function مش فعّال وبنية إنه يساعد هيقترح rewrite. ده بيكسر حد المرحلة — كنت عايز تفهم الكود، مش تغيّره. سيب prompts التغيير لـ session تاني، بـ system prompt الـ codegen skeleton.

System prompt تاني تكتبه للمشروع الختامي هو change-time. هتطلب من المساعد يكتب الـ fix الفعلي. system prompt للمرحلة دي المفروض يفرض الـ skeleton الرباعي من module 1: كل رد codegen لازم يضم INTENT، CONSTRAINTS، TESTS، FORMAT. بناء الـ prompt ده جزء من artifacts المشروع.

Workflow عملي: احتفظ بـ explainer system prompt و codegen system prompt في sessions chat مختلفين. ما تخلطش. غيّر الـ session لما تغيّر مرحلة — استكشاف → كتابة → مراجعة. كل session فيه الأداة الصح للشغل.

التالي: الـ rubric هتقيّم نفسك بناءً عليه. :::

اختبار

الوحدة 6: المشروع النهائي

خذ الاختبار
هل كان هذا الدرس مفيدًا؟

سجّل الدخول للتقييم

نشرة أسبوعية مجانية

ابقَ على مسار النيرد

بريد واحد أسبوعياً — دورات، مقالات معمّقة، أدوات، وتجارب ذكاء اصطناعي.

بدون إزعاج. إلغاء الاشتراك في أي وقت.