You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c9aecfb
Browse filesBrowse the repository at this point in the historyBrowse files
Book review (week 2): fix chapters 2-5 in English and all 16 locales (#1363)
* book(ch02-05): fix factual and consistency issues in English chapters
- ch02: add an Example section so the 'complete prompt' really uses all six
components; correct the last TryIt that claimed six components but has five
- ch03: update Principle 3 and quiz for assistants with memory/files/tools;
fix the Python example (SyntaxError, 2 vs 3 items); correct principle
numbers in the FillInTheBlank explanation; align the InteractiveChecklist
with the chapter's actual eight principles
- ch04: note that personas shape tone more than factual accuracy
- ch05: mention native schema-constrained structured outputs vs JSON mode;
replace EOL Node.js 18; correct the self-validation claim
Co-authored-by: Fatih Kadir Akın <fka@linux.com>
* book(tr): sync ch02-05 with English updates and fix translation issues
Co-authored-by: Fatih Kadir Akın <fka@linux.com>
* book(ar): sync ch02-05 with English updates and fix translation issues
Co-authored-by: Fatih Kadir Akın <fka@linux.com>
* book(az): sync ch02-05 with English updates and fix translation issues
Co-authored-by: Fatih Kadir Akın <fka@linux.com>
* book(de): sync ch02-05 with English updates and fix translation issues
Co-authored-by: Fatih Kadir Akın <fka@linux.com>
* book(el): sync ch02-05 with English updates and fix translation issues
Co-authored-by: Fatih Kadir Akın <fka@linux.com>
* book(es): sync ch02-05 with English updates and fix translation issues
Co-authored-by: Fatih Kadir Akın <fka@linux.com>
* book(fa): sync ch02-05 with English updates and fix translation issues
Co-authored-by: Fatih Kadir Akın <fka@linux.com>
* book(fr): sync ch02-05 with English updates and fix translation issues
Co-authored-by: Fatih Kadir Akın <fka@linux.com>
* book(he): sync ch02-05 with English updates and fix translation issues
Co-authored-by: Fatih Kadir Akın <fka@linux.com>
* book(it): sync ch02-05 with English updates and fix translation issues
Co-authored-by: Fatih Kadir Akın <fka@linux.com>
* book(ja): sync ch02-05 with English updates and fix translation issues
Co-authored-by: Fatih Kadir Akın <fka@linux.com>
* book(ko): sync ch02-05 with English updates and fix translation issues
Co-authored-by: Fatih Kadir Akın <fka@linux.com>
* book(nl): sync ch02-05 with English updates and fix translation issues
Co-authored-by: Fatih Kadir Akın <fka@linux.com>
* book(pt): sync ch02-05 with English updates and fix translation issues
Co-authored-by: Fatih Kadir Akın <fka@linux.com>
* book(ru): sync ch02-05 with English updates and fix translation issues
Co-authored-by: Fatih Kadir Akın <fka@linux.com>
* book(zh): sync ch02-05 with English updates and fix translation issues
Co-authored-by: Fatih Kadir Akın <fka@linux.com>
---------
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
@@ -293,7 +297,7 @@ Format: For each feature, provide:
293
297
1. Feature name
294
298
2. One-sentence description
295
299
3. Why it matters for remote teams`}
296
-
description="This prompt uses all six components. Try it and see how the structured approach produces focused, actionable results."
300
+
description="This prompt uses five of the six components (everything except examples). Try it and see how the structured approach produces focused, actionable results."
Copy file name to clipboardExpand all lines: src/content/book/03-core-prompting-principles.mdx
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,13 +84,13 @@ Each level adds specificity and dramatically improves output quality.
84
84
85
85
## Principle 3: Context Is King
86
86
87
-
Models have no memory, no access to your files, and no knowledge of your situation. Everything relevant must be in the prompt.
87
+
A model knows nothing about your situation beyond what reaches it in the conversation. Even assistants with memory features, uploaded files, or connected tools see only what has actually been shared with them, and they recall it selectively. When something matters, put it in the prompt.
88
88
89
89
### Provide Sufficient Context
90
90
91
91
<Compare
92
92
before={{ label: "Insufficient context", content: "Why isn't my function working?" }}
93
-
after={{ label: "Sufficient context", content: "I have a Python function that should filter a list of dictionaries by a specific key value. It's returning an empty list when it should return 3 items.\n\nFunction:\ndef filter_items(items, key, value):\n return [item for item in items if item[key] = value]\n\nCall: filter_items(items, 'status', 'active')\nExpected: 2 items, Got: empty list" }}
93
+
after={{ label: "Sufficient context", content: "I have a Python function that should filter a list of dictionaries by a specific key value. It's returning an empty list when it should return 3 items.\n\nFunction:\ndef filter_items(items, key, value):\n return [item for item in items if item.get(key) == value]\n\nSample item: {'id': 7, 'status': 'active'}\nCall: filter_items(items, 'Status', 'active')\nExpected: 3 items, Got: empty list" }}
94
94
/>
95
95
96
96
### The Context Checklist
@@ -321,7 +321,7 @@ List any issues found.
321
321
"Iterate and Refine"
322
322
]}
323
323
correctIndex={2}
324
-
explanation="Context Is King emphasizes that AI models have no memory between sessions and cannot read your mind. Including relevant background, constraints, and goals helps the model understand your needs."
324
+
explanation="Context Is King emphasizes that AI models cannot read your mind: they only know what reaches them in the conversation. Including relevant background, constraints, and goals helps the model understand your needs."
325
325
/>
326
326
327
327
## Practice: Fill in the Blanks
@@ -353,7 +353,7 @@ Format: Return your answer as {{format}}.`}
353
353
{ id: "focus", correctAnswers: [], hint: "What aspect should be prioritized?", context: "A quality or aspect relevant to the task" },
354
354
{ id: "format", correctAnswers: [], hint: "How should the output be structured?", context: "An output format type" }
355
355
]}
356
-
explanation="A well-structured prompt includes: a clear role (Principle 1), sufficient context (Principle 3), specific task (Principle 2), constraints (Principle 4), and output format (Principle 5). The AI checks if your choices are internally consistent."
356
+
explanation="A well-structured prompt includes a clear role (Principle 6), sufficient context (Principle 3), a specific task with constraints (Principle 2), and an explicit output format (Principle 7). The AI checks if your choices are internally consistent."
357
357
/>
358
358
359
359
<InteractiveChecklist
@@ -362,10 +362,10 @@ Format: Return your answer as {{format}}.`}
362
362
{ id: "clarity", label: "Clarity Over Cleverness", description: "Is your prompt explicit and unambiguous?" },
363
363
{ id: "specificity", label: "Specificity Yields Quality", description: "Have you included audience, length, tone, and format?" },
364
364
{ id: "context", label: "Context Is King", description: "Does the prompt include all necessary background information?" },
365
-
{ id: "examples", label: "Examples Beat Explanations", description: "Have you shown what you want, not just described it?" },
366
-
{ id: "constraints", label: "Constraints Focus Output", description: "Are there clear boundaries on scope and format?" },
365
+
{ id: "guide", label: "Guide, Don't Just Ask", description: "Have you laid out the steps or reasoning you want, not just asked for an answer?" },
367
366
{ id: "iteration", label: "Iterate and Refine", description: "Are you prepared to improve based on results?" },
368
-
{ id: "persona", label: "Persona Shapes Perspective", description: "Does the AI know what role to play?" },
367
+
{ id: "strengths", label: "Leverage the Model's Strengths", description: "Are you showing patterns and using roles the model handles well?" },
368
+
{ id: "structure", label: "Control Output Structure", description: "Have you specified the exact format you need?" },
369
369
{ id: "verify", label: "Verify and Validate", description: "Have you built in checks for accuracy?" }
Copy file name to clipboardExpand all lines: src/content/book/04-role-based-prompting.mdx
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,8 @@ Think of it this way: if you ask "What should I do about this cough?" the model
29
29
30
30
<Callouttype="info"title="Why This Matters">
31
31
The model isn't pretending or role-playing in a theatrical sense. It's statistically biasing its outputs toward patterns it learned from real experts, professionals, and specialists during training. A "doctor" role activates medical knowledge pathways; a "poet" role activates literary patterns.
32
+
33
+
Roles mostly shape tone, vocabulary, and focus. They can't add knowledge the model never learned, and research has found that a persona on its own rarely makes answers to factual questions more accurate. Pair roles with good context, and verify anything that matters.
If you call a model through an API, you don't have to rely on wording alone. OpenAI, Anthropic, and Google all offer structured output modes that take a JSON Schema and constrain the response to match it, so required fields and allowed values are enforced rather than merely requested. Older "JSON mode" options only guarantee syntactically valid JSON, not your schema. Even with a schema enforced, the values themselves can still be wrong, so keep validating what matters.
175
+
</Callout>
176
+
173
177
## YAML Output
174
178
175
179
YAML is more human-readable than JSON, using indentation instead of brackets. It's the standard for configuration files (Docker, Kubernetes, GitHub Actions) and works well when the output will be read by humans or used in DevOps contexts. YAML is sensitive to indentation, so be specific about formatting requirements.
@@ -181,7 +185,7 @@ YAML is more human-readable than JSON, using indentation instead of brackets. It
Self-validation prompts the model to check its own output before responding. This catches common issues like missing sections, placeholder text, or constraint violations. The model will iterate internally to fix problems, improving output quality without additional API calls.
360
+
Self-validation prompts the model to check its own output before responding. This catches common issues like missing sections, placeholder text, or constraint violations. This often improves quality without an extra API call, but it isn't a guarantee: a model can report that a check passed when it didn't, so still verify critical output in your own code.
Copy file name to clipboardExpand all lines: src/content/book/ar/03-core-prompting-principles.mdx
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,13 +84,13 @@
84
84
85
85
## المبدأ الثالث: السياق هو الملك
86
86
87
-
النماذج ليس لديها ذاكرة، ولا وصول إلى ملفاتك، ولا معرفة بوضعك. كل شيء ذو صلة يجب أن يكون في المطالبة.
87
+
لا يعرف النموذج شيئاً عن وضعك سوى ما يصل إليه في المحادثة. وحتى المساعدات الذكية التي تملك ميزات الذاكرة أو الملفات المرفوعة أو الأدوات المتصلة لا ترى إلا ما تمت مشاركته معها فعلاً، وتستحضره بشكل انتقائي. فحين يكون أمرٌ ما مهماً، ضعه في المطالبة.
88
88
89
89
### قدم سياقاً كافياً
90
90
91
91
<Compare
92
92
before={{ label: "سياق غير كافٍ", content: "لماذا لا تعمل دالتي؟" }}
93
-
after={{ label: "سياق كافٍ", content: "لدي دالة Python يجب أن تفلتر قائمة من القواميس حسب قيمة مفتاح محدد. إنها تعيد قائمة فارغة بينما يجب أن تعيد 3 عناصر.\n\nالدالة:\ndef filter_items(items, key, value):\n return [item for item in items if item[key] = value]\n\nالاستدعاء: filter_items(items, 'status', 'active')\nالمتوقع: عنصران، النتيجة: قائمة فارغة" }}
93
+
after={{ label: "سياق كافٍ", content: "لدي دالة Python يجب أن تفلتر قائمة من القواميس حسب قيمة مفتاح محدد. إنها تعيد قائمة فارغة بينما يجب أن تعيد 3 عناصر.\n\nالدالة:\ndef filter_items(items, key, value):\n return [item for item in items if item.get(key) == value]\n\nعنصر نموذجي: {'id': 7, 'status': 'active'}\nالاستدعاء: filter_items(items, 'Status', 'active')\nالمتوقع: 3 عناصر، النتيجة: قائمة فارغة" }}
94
94
/>
95
95
96
96
### قائمة التحقق من السياق
@@ -321,7 +321,7 @@
321
321
"كرر وحسّن"
322
322
]}
323
323
correctIndex={2}
324
-
explanation="يؤكد مبدأ 'السياق هو الملك' أن نماذج الذكاء الاصطناعي ليس لديها ذاكرة بين الجلسات ولا يمكنها قراءة أفكارك. تضمين الخلفية والقيود والأهداف ذات الصلة يساعد النموذج على فهم احتياجاتك."
324
+
explanation="يؤكد مبدأ 'السياق هو الملك' أن نماذج الذكاء الاصطناعي لا يمكنها قراءة أفكارك: فهي لا تعرف إلا ما يصل إليها في المحادثة. تضمين الخلفية والقيود والأهداف ذات الصلة يساعد النموذج على فهم احتياجاتك."
325
325
/>
326
326
327
327
## التمرين: املأ الفراغات
@@ -353,7 +353,7 @@
353
353
{ id: "focus", correctAnswers: [], hint: "ما الجانب الذي يجب إعطاؤه الأولوية؟", context: "جودة أو جانب متعلق بالمهمة" },
explanation="المطالبة جيدة الهيكلة تتضمن: دوراً واضحاً (المبدأ 1)، سياقاً كافياً (المبدأ 3)، مهمة محددة (المبدأ 2)، قيوداً (المبدأ 4)، وتنسيق المخرجات (المبدأ 5). يتحقق الذكاء الاصطناعي مما إذا كانت اختياراتك متسقة داخلياً."
356
+
explanation="المطالبة جيدة الهيكلة تتضمن دوراً واضحاً (المبدأ 6)، وسياقاً كافياً (المبدأ 3)، ومهمة محددة مع قيودها (المبدأ 2)، وتنسيقاً صريحاً للمخرجات (المبدأ 7). يتحقق الذكاء الاصطناعي مما إذا كانت اختياراتك متسقة داخلياً."
357
357
/>
358
358
359
359
<InteractiveChecklist
@@ -362,10 +362,10 @@
362
362
{ id: "clarity", label: "الوضوح قبل الذكاء", description: "هل مطالبتك صريحة وغير غامضة؟" },
363
363
{ id: "specificity", label: "الدقة تؤدي إلى الجودة", description: "هل ضمّنت الجمهور والطول والنبرة والتنسيق؟" },
364
364
{ id: "context", label: "السياق هو الملك", description: "هل تتضمن المطالبة جميع المعلومات الخلفية الضرورية؟" },
365
-
{ id: "examples", label: "الأمثلة تتفوق على الشرح", description: "هل أظهرت ما تريد، وليس فقط وصفته؟" },
366
-
{ id: "constraints", label: "القيود تركز المخرجات", description: "هل هناك حدود واضحة للنطاق والتنسيق؟" },
365
+
{ id: "guide", label: "وجّه، لا تسأل فقط", description: "هل وضّحت الخطوات أو طريقة التفكير التي تريدها، بدلاً من مجرد طلب إجابة؟" },
Copy file name to clipboardExpand all lines: src/content/book/ar/04-role-based-prompting.mdx
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,14 +21,16 @@
21
21
22
22
**التكييف الإحصائي**: تعلمت نماذج اللغة الكبيرة من ملايين الوثائق التي كتبها خبراء حقيقيون. عندما تُعيّن دوراً، يُكيّف النموذج توزيعاته الاحتمالية لتتوافق مع الأنماط التي رآها من ذلك النوع من الكُتّاب.
23
23
24
-
**تقليل الغموض**: بدون دور، يُحسب النموذج متوسطاً عبر جميع المستجيبين المحتملين. مع دور محدد، يضيّق النطاق إلى مجموعة فرعية معينة، مما يجعل الاستجابات أكثر تركيزاً واتساقاً.
24
+
**تقليل الغموض**: بدون دور، يحسب النموذج متوسطاً عبر جميع المستجيبين المحتملين. مع دور محدد، يضيّق النطاق إلى مجموعة فرعية معينة، مما يجعل الاستجابات أكثر تركيزاً واتساقاً.
25
25
26
26
**ترسيخ السياق**: يُنشئ الدور مرساة سياقية مستمرة طوال المحادثة. تتأثر كل استجابة لاحقة بهذا التأطير الأولي.
27
27
28
28
فكّر في الأمر بهذه الطريقة: إذا سألت "ماذا يجب أن أفعل بشأن هذه الكحة؟" يمكن للنموذج أن يستجيب كطبيب أو صديق أو صيدلي أو والد قلق. كل منهم سيعطي نصيحة مختلفة. بتحديد الدور مسبقاً، أنت تخبر النموذج أي "صوت" يستخدم من بيانات التدريب الخاصة به.
29
29
30
30
<Callouttype="info"title="لماذا هذا مهم">
31
31
النموذج لا يتظاهر أو يؤدي دوراً بالمعنى المسرحي. إنه يُحيّز إحصائياً مخرجاته نحو أنماط تعلمها من خبراء ومحترفين ومتخصصين حقيقيين أثناء التدريب. دور "الطبيب" يُنشّط مسارات المعرفة الطبية؛ ودور "الشاعر" يُنشّط الأنماط الأدبية.
32
+
33
+
تُشكّل الأدوار في الغالب النبرة والمفردات ومحور التركيز. لكنها لا تستطيع إضافة معرفة لم يتعلمها النموذج قط، وقد وجدت الأبحاث أن الشخصية وحدها نادراً ما تجعل الإجابات عن الأسئلة الواقعية أكثر دقة. فاقرن الأدوار بسياق جيد، وتحقق من كل ما هو مهم.
32
34
</Callout>
33
35
34
36
## أنماط الأدوار الأساسية
@@ -92,7 +94,7 @@ Pitch: \${pitch}`} />
92
94
93
95
### الأدوار التقنية
94
96
95
-
**مهندس البرمجيات**: الأفضل لقرارات تصميم الأنظمة واختيارات التقنية والمفاضلات المعمارية. التركيز على قابلية الصيانة يوجّه الاستجابات نحو حلول عملية طويلة المدى.
97
+
**المهندس المعماري للبرمجيات**: الأفضل لقرارات تصميم الأنظمة واختيارات التقنية والمفاضلات المعمارية. التركيز على قابلية الصيانة يوجّه الاستجابات نحو حلول عملية طويلة المدى.
96
98
97
99
<TryItcompactprompt={`You are a software architect specializing in scalable distributed systems. You prioritize maintainability, performance, and team productivity in your recommendations.
0 commit comments