AI-Prompt-Development/prompt-engineering-guide
About
Complete guide to prompt engineering — techniques, patterns, anti-patterns, and real-world examples for GPT-4, Claude, Gemini, and open-source LLMs
AI & Machine LearningMeasured star growth
- in 24h
- +1
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalPrompt Engineering Guide
The most comprehensive open-source guide to prompt engineering for large language models.
Live Site · Issues · Contribute
What is Prompt Engineering?
Prompt engineering is the discipline of designing, testing, and optimizing inputs to large language models (LLMs) to reliably produce desired outputs. A well-engineered prompt can be the difference between a useless response and a production-ready solution.
Why it matters:
- Same model, different prompt → 10x quality difference
- Poor prompts waste tokens → higher API costs
- Ambiguous prompts → unpredictable outputs
- Correct prompt structure → reproducible, auditable results
Core Techniques
1. Zero-Shot Prompting
No examples provided. Relies entirely on the model's training.
Translate the following English text to French:
"The quick brown fox jumps over the lazy dog."
Best for: Simple, well-defined tasks where the model has strong training signal.
2. Few-Shot Prompting
Provide 2–8 examples before the actual task.
Classify sentiment:
Text: "I love this product!" → Positive
Text: "This is terrible." → Negative
Text: "It's okay, nothing special." → Neutral
Text: "Best purchase I've made this year!" → ?
Best for: Tasks requiring consistent formatting, domain-specific classification.
3. Chain-of-Thought (CoT)
Instruct the model to reason step by step.
Q: A store had 15 apples. They sold 8 and received 20 more. How many apples do they have?
A: Let me think step by step.
- Started with: 15 apples
- Sold: 8 → 15 - 8 = 7 apples
- Received: 20 → 7 + 20 = 27 apples
Answer: 27 apples
Best for: Mathematical reasoning, logical deduction, multi-step problems.
4. Role Prompting
Assign an expert persona to the model.
You are a senior software engineer with 15 years of experience in Python and distributed systems.
Review the following code for performance issues and security vulnerabilities:
[code here]
Best for: Technical tasks, creative writing, specialized domain knowledge.
5. Structured Output Prompting
Request responses in a specific format.
Extract the following information from the text and return as JSON:
- person_name (string)
- organization (string)
- date_mentioned (ISO 8601)
- key_topics (array of strings)
Text: [input]
Return only valid JSON, no explanation.
Best for: Downstream processing, data extraction, API integrations.
6. Constrained Prompting
Set explicit boundaries on the response.
Answer the following question in exactly 3 bullet points.
Each bullet point must be under 20 words.
Do not include any introduction or conclusion.
Question: What are the main benefits of containerization?
Best for: Content generation with strict format requirements.
Anti-Patterns to Avoid
| Anti-Pattern | Problem | Fix |
|---|---|---|
| Vague instructions | "Write something about AI" | Specify audience, length, format, topic |
| Overloading a single prompt | Multiple unrelated tasks | Split into focused prompts |
| No output format specified | Inconsistent structure | Always specify format |
| Assuming context | "Fix the bug" without code | Include all necessary context |
| Contradictory constraints | "Be concise but comprehensive" | Prioritize and clarify |
Token Efficiency Rules
- Remove unnecessary politeness ("Please", "Thank you", "Could you kindly")
- Use structured delimiters (###, ---, code fences) instead of verbose transitions
- Specify output length explicitly
- Use abbreviations in system prompts where unambiguous
- Batch related sub-tasks into one prompt when context allows
Before (47 tokens): "Could you please take a look at this code and let me know if there are any bugs or issues I should be aware of?"
After (12 tokens): "Review this code. List bugs only. No explanations."
Model Comparison
| Feature | GPT-4o | Claude 3.5 | Gemini 1.5 | Llama 3.1 |
|---|---|---|---|---|
| Context window | 128K | 200K | 1M | 128K |
| JSON mode | Yes | Yes | Yes | Varies |
| Function calling | Yes | Yes | Yes | Varies |
| Best for | General | Long docs | Multimodal | Privacy |
Multilingual
TR: Prompt mühendisliği, büyük dil modellerine verilen girdileri optimize etme disiplinidir. DE: Prompt Engineering ist die Disziplin, Eingaben für große Sprachmodelle zu optimieren. FR: L'ingénierie de prompts est la discipline d'optimisation des entrées pour les LLM. ES: La ingeniería de prompts es la disciplina de optimizar las entradas para los LLM. ZH: 提示工程是优化大型语言模型输入的学科。 RU: Инжиниринг промптов — дисциплина оптимизации запросов к LLM. JA: プロンプトエンジニアリングは、大規模言語モデルへの入力を最適化する学問です。 KO: 프롬프트 엔지니어링은 대형 언어 모델의 입력을 최적화하는 학문입니다. AR: هندسة المطالبات هي تحسين المدخلات لنماذج اللغة الكبيرة. PT: Engenharia de prompts é a disciplina de otimizar entradas para LLMs.
Contributing
- Fork this repository
- Add your prompt technique or template to the relevant section
- Include: description, example, best-use-case, anti-patterns
- Open a pull request
License
MIT License — Free to use, modify, and distribute with attribution.
Keywords
prompt engineering LLM prompting ChatGPT prompts GPT-4 guide Claude prompting
AI prompts prompt design few-shot learning chain of thought zero-shot prompting
prompt template AI prompt library prompt optimization NLP prompting guide
prompt mühendisliği LLM rehberi yapay zeka prompt prompt yazma teknikleri
Prompt-Engineering Leitfaden ingénierie de prompts ingeniería de prompts
提示工程指南 промпт инжиниринг プロンプトエンジニアリング 프롬프트 엔지니어링 가이드
Explore related projects
Loading…