prompt-engineering-patterns
ما الذي تفعله
تساعدك هذه المهارة على كتابة تعليمات أفضل وأكثر فعالية للذكاء الاصطناعي. تعلّمك تقنيات متقدمة ليفهم الذكاء الاصطناعي ما تريده تماما، ويقدم إجابات أدق وأكثر موثوقية.
متى تستخدمها
- ✓عندما تريد من الذكاء الاصطناعي أن يقدم ردودا أدق.
- ✓عندما تبني نظام ذكاء اصطناعي لمهام معقدة.
- ✓عندما تريد من الذكاء الاصطناعي أن يتبع شكل رد محدد.
رابط المهارة
https://github.com/wshobson/agents/blob/main/plugins/llm-application-dev/skills/prompt-engineering-patterns/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“كيف أحسّن هذا الأمر للذكاء الاصطناعي: «اكتب ملخصا عن الحرب العالمية الثانية»؟”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
تعمل المهارة بتعليم الذكاء الاصطناعي أن يفكر خطوة بخطوة، وأن يستفيد من أمثلة يتعلم منها، وأن ينظم ردوده بشكل مهيكل. هكذا يفهم التعليمات بشكل أفضل ويتجنب الأخطاء.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من GitHub.
Prompt Engineering Patterns
Master advanced prompt engineering techniques to maximize LLM performance, reliability, and controllability.
When to Use This Skill
- Designing complex prompts for production LLM applications
- Optimizing prompt performance and consistency
- Implementing structured reasoning patterns (chain-of-thought, tree-of-thought)
- Building few-shot learning systems with dynamic example selection
- Creating reusable prompt templates with variable interpolation
- Debugging and refining prompts that produce inconsistent outputs
- Implementing system prompts for specialized AI assistants
- Using structured outputs (JSON mode) for reliable parsing
Core Capabilities
1. Few-Shot Learning
- Example selection strategies (semantic similarity, diversity sampling)
- Balancing example count with context window constraints
- Constructing effective demonstrations with input-output pairs
- Dynamic example retrieval from knowledge bases
- Handling edge cases through strategic example selection
2. Chain-of-Thought Prompting
- Step-by-step reasoning elicitation
- Zero-shot CoT with "Let's think step by step"
- Few-shot CoT with reasoning traces
- Self-consistency techniques (sampling multiple reasoning paths)
- Verification and validation steps
3. Structured Outputs
- JSON mode for reliable parsing
- Pydantic schema enforcement
- Type-safe response handling
- Error handling for malformed outputs
4. Prompt Optimization
- Iterative refinement workflows
- A/B testing prompt variations
- Measuring prompt performance metrics (accuracy, consistency, latency)
- Reducing token usage while maintaining quality
- Handling edge cases and failure modes
5. Template Systems
- Variable interpolation and formatting
- Conditional prompt sections
- Multi-turn conversation templates
- Role-based prompt composition
- Modular prompt components
6. System Prompt Design
- Setting model behavior and constraints
- Defining output formats and structure
- Establishing role and expertise
- Safety guidelines and content policies
- Context setting and background information
Quick Start
from langchain_anthropic import ChatAnthropic
from langchain_core.prompts import ChatPromptTemplate
from pydantic import BaseModel, Field
# Define structured output schema
class SQLQuery(BaseModel):
query: str = Field(description="The SQL query")
explanation: str = Field(description="Brief explanation of what the query does")
tables_used: list[str] = Field(description="List of tables referenced")
# Initialize model with structured output
llm = ChatAnthropic(model="claude-sonnet-5")
structured_llm = llm.with_structured_output(SQLQuery)
# Create prompt template
prompt = ChatPromptTemplate.from_messages([
("system", """You are an expert SQL developer. Generate efficient, secure SQL queries.
Always use parameterized queries to prevent SQL injection.
Explain your reasoning briefly."""),
("user", "Convert this to SQL: {query}")
])
# Create chain
chain = prompt | structured_llm
# Use
result = await chain.ainvoke({
"query": "Find all users who registered in the last 30 days"
})
print(result.query)
print(result.explanation)
Detailed patterns and worked examples
Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.
Best Practices
- Be Specific: Vague prompts produce inconsistent results
- Show, Don't Tell: Examples are more effective than descriptions
- Use Structured Outputs: Enforce schemas with Pydantic for reliability
- Test Extensively: Evaluate on diverse, representative inputs
- Iterate Rapidly: Small changes can have large impacts
- Monitor Performance: Track metrics in production
- Version Control: Treat prompts as code with proper versioning
- Document Intent: Explain why prompts are structured as they are
Common Pitfalls
- Over-engineering: Starting with complex prompts before trying simple ones
- Example pollution: Using examples that don't match the target task
- Context overflow: Exceeding token limits with excessive examples
- Ambiguous instructions: Leaving room for multiple interpretations
- Ignoring edge cases: Not testing on unusual or boundary inputs
- No error handling: Assuming outputs will always be well-formed
- Hardcoded values: Not parameterizing prompts for reuse
Success Metrics
…
الأسئلة الشائعة
ما هو «التفكير المتسلسل» (Chain-of-Thought)؟
هو أسلوب يُطلب فيه من الذكاء الاصطناعي أن يُظهر تفكيره خطوة بخطوة للوصول إلى الجواب، كأنه يفكر بصوت مسموع.
ما هو «التعلم بأمثلة قليلة» (Few-Shot Learning)؟
هو أن تقدّم له بضعة أمثلة على الشكل الذي تريد أن تكون عليه الإجابة، قبل طرح السؤال الرئيسي. ويتعلم الذكاء الاصطناعي من هذه الأمثلة.
لماذا نستخدم «المخرجات المهيكلة» (Structured Outputs)؟
لأنها تضمن أن يعيد الذكاء الاصطناعي المعلومات بشكل ثابت ومتوقع، مثل JSON، فتسهل على الأنظمة الأخرى الاستفادة منها.
التفاصيل
الوصف الأصلي من المؤلف
This skill should be used when the user asks to "optimize a prompt", "improve prompt performance", "design a prompt template", "write better prompts", "debug prompt issues", "use chain-of-thought", "structured prompting", "few-shot prompting", or wants to apply advanced prompt engineering patterns for production LLM applications.
repo: wshobson/agents
الشعبية
- نجوم GitHub
- 41k
- الترتيب
- #6724
- الترخيص
- MIT
- آخر تحديث
- 15/10/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
screen-reader-testing
41kيجعل وكيلك يختبر مواقع الويب باستخدام قارئات الشاشة للتأكد من أنها سهلة الوصول.
wcag-audit-patterns
41kيساعد وكيلك على تدقيق مواقع الويب من حيث إمكانية الوصول، وإصلاح المشكلات وفق إرشادات WCAG.
multi-reviewer-patterns
41kيمكّن وكيلك من تنسيق مراجعات الشيفرة المتوازية، مع إزالة التكرار في الملاحظات ودمج التقارير.
parallel-debugging
41kيتيح للوكيل تصحيح الأخطاء المعقدة عبر تحقيقات متوازية وتحليل السبب الجذري.
مهارات مشابهة
writing-skills
311kيعلّم وكيلك كتابة مهارات جديدة واختبار كل واحدة أولًا، والتأكد من أنها تغيّر سلوك الوكيل فعلًا.
writing-for-agents
310kيشرح كيفية كتابة تعليمات واضحة لوكلاء الذكاء الاصطناعي، بما في ذلك ملفات المهارات وAGENTS.md وCLAUDE.md، ليتصرف الوكيل بشكل متوقع.
bengali-nlp
280kيعالج وكيلك النصوص البنغالية، فيفهمها ويتعامل معها، ويعيد تنسيقها ويعالج خصائصها اللغوية الخاصة.