prompt-engineering-patterns
Fungsinya
Alat ini membantu membuat instruksi untuk kecerdasan buatan (AI) yang lebih baik dan efektif. Alat ini mengajarkan teknik-teknik lanjutan agar AI benar-benar memahami apa yang Anda inginkan, sehingga jawaban yang diberikan lebih akurat dan dapat diandalkan.
Kapan dipakai
- ✓Saat Anda ingin AI menghasilkan jawaban yang lebih akurat.
- ✓Saat membangun sistem AI untuk tugas-tugas yang kompleks.
- ✓Untuk membuat AI mengikuti format jawaban tertentu.
Link skill
https://github.com/wshobson/agents/blob/main/plugins/llm-application-dev/skills/prompt-engineering-patterns/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
“Bagaimana cara memperbaiki prompt ini untuk AI: 'Tulis ringkasan tentang Perang Dunia II'?”
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Alat ini bekerja dengan cara mengajarkan AI untuk berpikir langkah demi langkah, belajar dari contoh, dan menyusun jawaban dengan format yang terstruktur. Dengan begitu, AI lebih mudah memahami instruksi dan terhindar dari kesalahan.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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
…
Pertanyaan umum
Apa itu 'Chain-of-Thought'?
Ini adalah teknik ketika AI diminta untuk menunjukkan alur penalarannya langkah demi langkah sebelum sampai pada jawaban, seolah-olah sedang berpikir dengan suara keras.
Apa itu 'Few-Shot Learning'?
Ini adalah cara memberikan beberapa contoh jawaban yang Anda inginkan sebelum mengajukan pertanyaan utama. AI akan belajar dari contoh-contoh tersebut.
Mengapa menggunakan 'Structured Outputs'?
Teknik ini memastikan AI mengembalikan informasi dalam format yang dapat diprediksi, seperti JSON, sehingga lebih mudah digunakan oleh program lain.
Detail
Deskripsi asli dari pembuat
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
Popularitas
- Bintang GitHub
- 41k
- Peringkat
- #6724
- Lisensi
- MIT
- Diperbarui
- 15/10/2026
Komentar
- …
Skill lain dari repositori ini
screen-reader-testing
41kMeminta agent Anda menguji website menggunakan screen reader untuk memastikan website dapat diakses.
wcag-audit-patterns
41kMembantu agent Anda mengaudit aksesibilitas website dan memperbaiki masalah sesuai panduan WCAG.
multi-reviewer-patterns
41kMemungkinkan agent Anda mengoordinasikan code review paralel, menghapus temuan ganda, dan menggabungkan laporan.
parallel-debugging
41kMemungkinkan agent Anda men-debug masalah rumit dengan investigasi paralel dan analisis akar masalah.
Skill serupa
writing-skills
311kMengajari agent Anda menulis skill baru dan menguji setiap skill lebih dulu, memastikan skill itu benar-benar mengubah perilaku agent.
writing-for-agents
310kMenjelaskan cara menulis instruksi yang jelas untuk agent AI, termasuk file skill, AGENTS.md, dan CLAUDE.md, agar perilaku agent dapat diprediksi.
bengali-nlp
280kMembuat agent Anda memproses teks Bahasa Bengali. Membantu memahami dan mengolah bahasa tersebut, termasuk normalisasi teks dan karakteristik uniknya.