Prompt Engineering
Universal techniques for crafting effective prompts across any LLM.
Core Principles
1. Structure with XML Tags
Use XML tags to create clear, parseable prompts:
<context>Background information here</context>
<instructions>
1. First step
2. Second step
</instructions>
<examples>Sample inputs/outputs</examples>
<output_format>Expected structure</output_format>
Benefits:
- Clarity: Separates context, instructions, and examples
- Accuracy: Prevents model from mixing up sections
- Flexibility: Easy to modify individual parts
- Parseability: Enables structured output extraction
Best practices:
- Use consistent tag names throughout (
<instructions>, not sometimes <steps>)
- Reference tags explicitly: "Using the data in
<context> tags..."
- Nest tags for hierarchy:
<examples><example id="1">...</example></examples>
- Combine with other techniques:
<thinking> for chain-of-thought, <answer> for final output
2. Control Output Shape
Specify explicit constraints on length, format, and structure:
<output_spec>
- Default: 3-6 sentences or ≤5 bullets
- Simple yes/no questions: ≤2 sentences
- Complex multi-step tasks:
- 1 short overview paragraph
- ≤5 bullets: What changed, Where, Risks, Next steps, Open questions
- Use Markdown with headers, bullets, tables when helpful
- Avoid long narrative paragraphs; prefer compact structure
</output_spec>
3. Prevent Scope Drift
Explicitly constrain what the model should NOT do:
<constraints>
- Implement EXACTLY and ONLY what is requested
- No extra features, components, or embellishments
- If ambiguous, choose the simplest valid interpretation
- Do NOT invent values, make assumptions, or add unrequested elements
</constraints>
4. Handle Ambiguity Explicitly
Prevent hallucinations and overconfidence:
<uncertainty_handling>
- If the question is ambiguous:
- Ask 1-3 precise clarifying questions, OR
- Present 2-3 plausible interpretations with labeled assumptions
- When facts may have changed: answer in general terms, state uncertainty
- Never fabricate exact figures or references when uncertain
- Prefer "Based on the provided context..." over absolute claims
</uncertainty_handling>
5. Long-Context Grounding
For inputs >10k tokens, add re-grounding instructions:
<long_context_handling>
- First, produce a short internal outline of key sections relevant to the request
- Re-state user constraints explicitly before answering
- Anchor claims to sections ("In the 'Data Retention' section...")
- Quote or paraphrase fine details (dates, thresholds, clauses)
</long_context_handling>
Agentic Prompts
Tool Usage Rules
<tool_usage>
- Prefer tools over internal knowledge for:
- Fresh or user-specific data (tickets, orders, configs)
- Specific IDs, URLs, or document references
- Parallelize independent reads when possible
- After write operations, restate: what changed, where, any validation performed
</tool_usage>
User Updates
<user_updates>
- Send brief updates (1-2 sentences) only when:
- Starting a new major phase
- Discovering something that changes the plan
- Avoid narrating routine operations
- Each update must include a concrete outcome ("Found X", "Updated Y")
- Do not expand scope beyond what was asked
</user_updates>
Self-Check for High-Risk Outputs
<self_check>
Before finalizing answers in sensitive contexts (legal, financial, safety):
- Re-scan for unstated assumptions
- Check for ungrounded numbers or claims
- Soften overly strong language ("always", "guaranteed")
- Explicitly state assumptions
</self_check>
Structured Extraction
For data extraction tasks, always provide a schema:
<extraction_spec>
Extract data into this exact schema (no extra fields):
{
"field_name": "string",
"optional_field": "string | null",
"numeric_field": "number | null"
}
- If a field is not present in source, set to null (don't guess)
- Re-scan source for missed fields before returning
</extraction_spec>
Web Research Prompts
<research_guidelines>
- Browse the web for: time-sensitive topics, recommendations, navigational queries, ambiguous terms
- Include citations after paragraphs with web-derived claims
- Use multiple sources for key claims; prioritize primary sources
- Research until additional searching won't materially change the answer
- Structure output with Markdown: headers, bullets, tables for comparisons
</research_guidelines>
Example: Before/After
Without structure:
You're a financial analyst. Generate a Q2 report for investors. Include Revenue, Margins, Cash Flow. Use this data: {{DATA}}. Make it professional and concise.
With structure:
You're a financial analyst at AcmeCorp generating a Q2 report for investors.
<context>
AcmeCorp is a B2B SaaS company. Investors value transparency and actionable insights.
</context>
<data>
{{DATA}}
</data>
<instructions>
1. Include sections: Revenue Growth, Profit Margins, Cash Flow
2. Highlight strengths and areas for improvement
3. Use concise, professional tone
</instructions>
<output_format>
- Use bullet points with metrics and YoY changes
- Include "Action:" items for areas needing improvement
- End with 2-3 bullet Outlook section
</output_format>
Prompt Migration Checklist
When adapting prompts across models or versions:
- Switch model, keep prompt identical — isolate the variable
- Pin reasoning/thinking depth to match prior model's profile
- Run evals — if results are good, ship
- If regressions, tune prompt — adjust verbosity/format/scope constraints
- Re-eval after each small change — one change at a time
Quick Reference
| Technique |
Tag Pattern |
Use Case |
| Separate sections |
<context>, <instructions>, <data> |
Any complex prompt |
| Control length |
<output_spec> with word/bullet limits |
Prevent verbosity |
| Prevent drift |
<constraints> with explicit "do NOT" |
Feature creep |
| Handle uncertainty |
<uncertainty_handling> |
Factual queries |
| Chain of thought |
<thinking>, <answer> |
Reasoning tasks |
| Extraction |
<schema> with JSON structure |
Data parsing |
| Research |
<research_guidelines> |
Web-enabled agents |
| Self-check |
<self_check> |
High-risk domains |
| Tool usage |
<tool_usage_rules> |
Agentic systems |
| Eagerness control |
<persistence>, <context_gathering> |
Agent autonomy |
| Persona |
<role> + behavioral constraints |
Tone & style |
Prompting Techniques Catalog
Comprehensive catalog of prompting techniques. Full details, examples, and academic references in references/prompting-techniques.md.
| Technique |
Use Case |
| Zero-Shot Prompting |
Direct task execution without examples; classification, translation, summarization |
| Few-Shot Prompting |
In-context learning via exemplars; format control, label calibration, style matching |
| Chain-of-Thought (CoT) |
Step-by-step reasoning; arithmetic, logic, commonsense reasoning tasks |
| Meta Prompting |
LLM as orchestrator delegating to specialized expert prompts; complex multi-domain tasks |
| Self-Consistency |
Sample multiple CoT paths, pick majority answer; boost accuracy on math & reasoning |
| Generated Knowledge |
Generate relevant knowledge first, then answer; commonsense & factual QA |
| Prompt Chaining |
Break complex tasks into sequential subtasks; document analysis, multi-step workflows |
| Tree of Thoughts (ToT) |
Explore multiple reasoning branches with lookahead/backtracking; planning, puzzles |
| RAG |
Retrieve external documents before generating; knowledge-intensive tasks, fresh data |
| ART (Auto Reasoning + Tools) |
Auto-select and orchestrate tools with CoT; tasks requiring calculation, search, APIs |
| APE (Auto Prompt Engineer) |
LLM generates and scores candidate prompts; prompt optimization at scale |
| Active-Prompt |
Identify uncertain examples, annotate selectively for CoT; adaptive few-shot |
| Directional Stimulus |
Add a hint/keyword to guide generation direction; summarization, dialogue |
| PAL (Program-Aided LM) |
Generate code instead of text for reasoning; math, data manipulation, symbolic tasks |
| ReAct |
Interleave reasoning traces with tool actions; search, QA, decision-making agents |
| Reflexion |
Agent self-reflects on failures with verbal feedback; iterative improvement, debugging |
| Multimodal CoT |
Two-stage: rationale generation then answer with text+image; visual reasoning tasks |
| Graph Prompting |
Structured graph-based prompts; node classification, relation extraction, graph tasks |
Prompting Fundamentals
LLM settings, prompt elements, formatting, and practical examples — see references/prompting-introduction.md. Covers:
- LLM Settings — temperature, top-p, max length, stop sequences, frequency/presence penalties
- Prompt Elements — instruction, context, input data, output indicator
- Design Tips — start simple, be specific, avoid impreciseness, say what TO do (not what NOT to do)
- Task Examples — summarization, extraction, QA, classification, conversation, code generation, reasoning
Risks & Misuses
Adversarial attacks, factuality issues, and bias mitigation — see references/prompting-risks.md. Covers:
- Adversarial Prompting — prompt injection, prompt leaking, jailbreaking (DAN, Waluigi Effect), defense tactics
- Factuality — ground truth grounding, calibrated confidence, admit-ignorance patterns
- Biases — exemplar distribution skew, exemplar ordering effects, balanced few-shot design
Prompt Audit / Review
When asked to audit, review, or improve a prompt, follow this workflow. Full checklist with per-check references: prompt-audit-checklist.md.
Workflow
- Read the prompt fully — identify its purpose, target model, and deployment context (interactive chat, agentic system, batch pipeline, RAG-augmented)
- Walk 8 dimensions — check each, note issues with severity (Critical / Warning / Suggestion):
| # |
Dimension |
What to Check |
| 1 |
Clarity & Specificity |
Task definition, success criteria, audience, output format, conflicting constraints |
| 2 |
Structure & Formatting |
Section separation (XML tags), prompt smells (monolithic, mixed layers, negative bias) |
| 3 |
Safety & Security |
Control/data separation, secrets in prompt, injection resilience, tool permissions |
| 4 |
Hallucination & Factuality |
Role framing, grounding, citation-without-sources, uncertainty handling |
| 5 |
Context Management |
Info placement (not buried in middle), context size, RAG doc count, re-grounding |
| 6 |
Maintainability & Debt |
Hardcoded values, regenerated logic, model pinning, testability |
| 7 |
Model-Specific Fit |
Model-specific params and gotchas (see Model-Specific Guides below) |
| 8 |
Evaluation Readiness |
Eval criteria, adversarial test cases, schema enforcement, monitoring |
- Produce a report — issues table (dimension, check, severity, issue, fix) + rewritten prompt or targeted fix suggestions. Use the report template from the checklist reference.
- For each issue, cite the relevant reference file so the user can dive deeper.
Quick Decision: Which Dimensions to Prioritize
- User-facing chatbot → prioritize Safety (#3), Hallucination (#4), Clarity (#1)
- Agentic system with tools → prioritize Safety (#3), Context (#5), Maintainability (#6)
- Batch/pipeline → prioritize Structure (#2), Evaluation (#8), Maintainability (#6)
- RAG-augmented → prioritize Context (#5), Safety (#3), Hallucination (#4)
Common Mistakes & Anti-Patterns
Three complementary layers — use the one matching your need:
Deep-dives by category — root causes, mechanisms, prevention checklists (from "The Architecture of Instruction", 2026):
| Mistake Category |
Key Issues |
Reference |
| Hallucinations & Logic |
Ambiguity-induced confabulation, automation bias, overloaded prompts, logical failures in verification tasks, no role framing |
mistakes-hallucinations.md |
| Structural Fragility |
Formatting sensitivity (up to 76pp variance), reproducibility crisis, prompt smells catalog (6 anti-patterns), deliberation ladder |
mistakes-structure.md |
| Context Rot |
"Lost in the middle" U-shaped attention, RAG over-retrieval, naive data loading, context engineering shift |
mistakes-context.md |
| Prompt Debt |
Token tax of regenerative code, debt taxonomy (prompt/hyperparameter/framework/cost), multi-agent solutions, automated repair |
mistakes-debt.md |
| Security |
Direct/indirect injection, jailbreaking, system prompt leakage (OWASP LLM07:2025), RAG poisoning, multimodal injection, adversarial suffixes |
mistakes-security.md |
Quick reference — 18-category taxonomy with MRPs, risk scores, case studies, action items: failure-taxonomy.md. Start here for an overview or to prioritize which categories to address first. Covers: control-plane vs data-plane model, heuristic risk scoring, real-world incidents (EchoLeak CVE-2025-32711, Mata v. Avianca, Samsung shadow AI).
How to measure & test — eval metrics, CI gating, red-teaming, tooling: evaluation-redteaming.md. Covers: TruthfulQA, FActScore, SelfCheckGPT, PromptBench, AILuminate, LLM-as-judge pitfalls, guardrail libraries, open research questions.
Model-Specific Guides
Each model family has unique parameters, gotchas, and patterns. Consult the reference for your target model:
- Claude Family — Opus 4.7 / 4.6 / Sonnet 4.6 / 4.5 / Haiku 4.5: adaptive thinking (
effort with new xhigh on 4.7), task_budget agentic-loop ceiling, legacy thinking.budget_tokens 400-error on 4.7, new tokenizer (~1.35× text, ~3× images), tool under-triggering on 4.7 (vs 4.6 over-triggering), more literal instruction-following, server-side compaction beta, Managed Agents memory beta, Cyber Verification gate, prefill deprecation, Structured Outputs, prompt caching, citations, context engineering, vision crop tool, migration paths 4.5 → 4.6 → 4.7
- GPT-5 Family — GPT-5 / 5.1 / 5.2 / 5.4 / 5.5:
reasoning_effort (last-mile knob in 5.4/5.5), text.verbosity, named tools (apply_patch), agentic eagerness templates, completeness/verification contracts, compaction API, phase field, outcome-first prompts, personality vs collaboration style, retrieval budgets, mini/nano guidance, migration paths
- Gemini 3 Family — Gemini 2.5/3/3.1: temperature MUST be 1.0,
thinking_budget vs thinking_level, constraint placement (end of prompt), persona priority, function calling, structured output, multimodal, image generation
- GPT-5.2 Specifics — Compaction API code examples, web research agent prompt, full XML specification blocks
1---2name: prompt-engineering3description: Universal prompt engineering techniques for any LLM. Use when crafting, optimizing, or reviewing prompts for AI models. Triggers on requests like "improve this prompt", "write a system prompt", "optimize my instructions", "help me prompt engineer", "audit this prompt", "review my prompt", or when building agentic systems that need structured prompts.4---5
6# Prompt Engineering
7
8Universal techniques for crafting effective prompts across any LLM.
9
10## Core Principles
11
12### 1. Structure with XML Tags
13
14Use XML tags to create clear, parseable prompts:
15
16```xml
17<context>Background information here</context>
18<instructions>
191. First step
202. Second step
21</instructions>
22<examples>Sample inputs/outputs</examples>
23<output_format>Expected structure</output_format>
24```
25
26**Benefits:**
27- **Clarity**: Separates context, instructions, and examples
28- **Accuracy**: Prevents model from mixing up sections
29- **Flexibility**: Easy to modify individual parts
30- **Parseability**: Enables structured output extraction
31
32**Best practices:**
33- Use consistent tag names throughout (`<instructions>`, not sometimes `<steps>`)
34- Reference tags explicitly: "Using the data in `<context>` tags..."
35- Nest tags for hierarchy: `<examples><example id="1">...</example></examples>`
36- Combine with other techniques: `<thinking>` for chain-of-thought, `<answer>` for final output
37
38### 2. Control Output Shape
39
40Specify explicit constraints on length, format, and structure:
41
42```xml
43<output_spec>
44- Default: 3-6 sentences or ≤5 bullets
45- Simple yes/no questions: ≤2 sentences
46- Complex multi-step tasks:
47 - 1 short overview paragraph
48 - ≤5 bullets: What changed, Where, Risks, Next steps, Open questions
49- Use Markdown with headers, bullets, tables when helpful
50- Avoid long narrative paragraphs; prefer compact structure
51</output_spec>
52```
53
54### 3. Prevent Scope Drift
55
56Explicitly constrain what the model should NOT do:
57
58```xml
59<constraints>
60- Implement EXACTLY and ONLY what is requested
61- No extra features, components, or embellishments
62- If ambiguous, choose the simplest valid interpretation
63- Do NOT invent values, make assumptions, or add unrequested elements
64</constraints>
65```
66
67### 4. Handle Ambiguity Explicitly
68
69Prevent hallucinations and overconfidence:
70
71```xml
72<uncertainty_handling>
73- If the question is ambiguous:
74 - Ask 1-3 precise clarifying questions, OR
75 - Present 2-3 plausible interpretations with labeled assumptions
76- When facts may have changed: answer in general terms, state uncertainty
77- Never fabricate exact figures or references when uncertain
78- Prefer "Based on the provided context..." over absolute claims
79</uncertainty_handling>
80```
81
82### 5. Long-Context Grounding
83
84For inputs >10k tokens, add re-grounding instructions:
85
86```xml
87<long_context_handling>
88- First, produce a short internal outline of key sections relevant to the request
89- Re-state user constraints explicitly before answering
90- Anchor claims to sections ("In the 'Data Retention' section...")
91- Quote or paraphrase fine details (dates, thresholds, clauses)
92</long_context_handling>
93```
94
95## Agentic Prompts
96
97### Tool Usage Rules
98
99```xml
100<tool_usage>
101- Prefer tools over internal knowledge for:
102 - Fresh or user-specific data (tickets, orders, configs)
103 - Specific IDs, URLs, or document references
104- Parallelize independent reads when possible
105- After write operations, restate: what changed, where, any validation performed
106</tool_usage>
107```
108
109### User Updates
110
111```xml
112<user_updates>
113- Send brief updates (1-2 sentences) only when:
114 - Starting a new major phase
115 - Discovering something that changes the plan
116- Avoid narrating routine operations
117- Each update must include a concrete outcome ("Found X", "Updated Y")
118- Do not expand scope beyond what was asked
119</user_updates>
120```
121
122### Self-Check for High-Risk Outputs
123
124```xml
125<self_check>
126Before finalizing answers in sensitive contexts (legal, financial, safety):
127- Re-scan for unstated assumptions
128- Check for ungrounded numbers or claims
129- Soften overly strong language ("always", "guaranteed")
130- Explicitly state assumptions
131</self_check>
132```
133
134## Structured Extraction
135
136For data extraction tasks, always provide a schema:
137
138```xml
139<extraction_spec>
140Extract data into this exact schema (no extra fields):
141{
142 "field_name": "string",
143 "optional_field": "string | null",
144 "numeric_field": "number | null"
145}
146- If a field is not present in source, set to null (don't guess)
147- Re-scan source for missed fields before returning
148</extraction_spec>
149```
150
151## Web Research Prompts
152
153```xml
154<research_guidelines>
155- Browse the web for: time-sensitive topics, recommendations, navigational queries, ambiguous terms
156- Include citations after paragraphs with web-derived claims
157- Use multiple sources for key claims; prioritize primary sources
158- Research until additional searching won't materially change the answer
159- Structure output with Markdown: headers, bullets, tables for comparisons
160</research_guidelines>
161```
162
163## Example: Before/After
164
165**Without structure:**
166```
167You're a financial analyst. Generate a Q2 report for investors. Include Revenue, Margins, Cash Flow. Use this data: {{DATA}}. Make it professional and concise.
168```
169
170**With structure:**
171```xml
172You're a financial analyst at AcmeCorp generating a Q2 report for investors.
173
174<context>
175AcmeCorp is a B2B SaaS company. Investors value transparency and actionable insights.
176</context>
177
178<data>
179{{DATA}}
180</data>
181
182<instructions>
1831. Include sections: Revenue Growth, Profit Margins, Cash Flow
1842. Highlight strengths and areas for improvement
1853. Use concise, professional tone
186</instructions>
187
188<output_format>
189- Use bullet points with metrics and YoY changes
190- Include "Action:" items for areas needing improvement
191- End with 2-3 bullet Outlook section
192</output_format>
193```
194
195## Prompt Migration Checklist
196
197When adapting prompts across models or versions:
198
1991. **Switch model, keep prompt identical** — isolate the variable
2002. **Pin reasoning/thinking depth** to match prior model's profile
2013. **Run evals** — if results are good, ship
2024. **If regressions, tune prompt** — adjust verbosity/format/scope constraints
2035. **Re-eval after each small change** — one change at a time
204
205## Quick Reference
206
207| Technique | Tag Pattern | Use Case |
208|-----------|-------------|----------|
209| Separate sections | `<context>`, `<instructions>`, `<data>` | Any complex prompt |
210| Control length | `<output_spec>` with word/bullet limits | Prevent verbosity |
211| Prevent drift | `<constraints>` with explicit "do NOT" | Feature creep |
212| Handle uncertainty | `<uncertainty_handling>` | Factual queries |
213| Chain of thought | `<thinking>`, `<answer>` | Reasoning tasks |
214| Extraction | `<schema>` with JSON structure | Data parsing |
215| Research | `<research_guidelines>` | Web-enabled agents |
216| Self-check | `<self_check>` | High-risk domains |
217| Tool usage | `<tool_usage_rules>` | Agentic systems |
218| Eagerness control | `<persistence>`, `<context_gathering>` | Agent autonomy |
219| Persona | `<role>` + behavioral constraints | Tone & style |
220
221## Prompting Techniques Catalog
222
223Comprehensive catalog of prompting techniques. Full details, examples, and academic references in [references/prompting-techniques.md](references/prompting-techniques.md).
224
225| Technique | Use Case |
226|-----------|----------|
227| **Zero-Shot Prompting** | Direct task execution without examples; classification, translation, summarization |
228| **Few-Shot Prompting** | In-context learning via exemplars; format control, label calibration, style matching |
229| **Chain-of-Thought (CoT)** | Step-by-step reasoning; arithmetic, logic, commonsense reasoning tasks |
230| **Meta Prompting** | LLM as orchestrator delegating to specialized expert prompts; complex multi-domain tasks |
231| **Self-Consistency** | Sample multiple CoT paths, pick majority answer; boost accuracy on math & reasoning |
232| **Generated Knowledge** | Generate relevant knowledge first, then answer; commonsense & factual QA |
233| **Prompt Chaining** | Break complex tasks into sequential subtasks; document analysis, multi-step workflows |
234| **Tree of Thoughts (ToT)** | Explore multiple reasoning branches with lookahead/backtracking; planning, puzzles |
235| **RAG** | Retrieve external documents before generating; knowledge-intensive tasks, fresh data |
236| **ART (Auto Reasoning + Tools)** | Auto-select and orchestrate tools with CoT; tasks requiring calculation, search, APIs |
237| **APE (Auto Prompt Engineer)** | LLM generates and scores candidate prompts; prompt optimization at scale |
238| **Active-Prompt** | Identify uncertain examples, annotate selectively for CoT; adaptive few-shot |
239| **Directional Stimulus** | Add a hint/keyword to guide generation direction; summarization, dialogue |
240| **PAL (Program-Aided LM)** | Generate code instead of text for reasoning; math, data manipulation, symbolic tasks |
241| **ReAct** | Interleave reasoning traces with tool actions; search, QA, decision-making agents |
242| **Reflexion** | Agent self-reflects on failures with verbal feedback; iterative improvement, debugging |
243| **Multimodal CoT** | Two-stage: rationale generation then answer with text+image; visual reasoning tasks |
244| **Graph Prompting** | Structured graph-based prompts; node classification, relation extraction, graph tasks |
245
246### Prompting Fundamentals
247
248LLM settings, prompt elements, formatting, and practical examples — see [references/prompting-introduction.md](references/prompting-introduction.md). Covers:
249- **LLM Settings** — temperature, top-p, max length, stop sequences, frequency/presence penalties
250- **Prompt Elements** — instruction, context, input data, output indicator
251- **Design Tips** — start simple, be specific, avoid impreciseness, say what TO do (not what NOT to do)
252- **Task Examples** — summarization, extraction, QA, classification, conversation, code generation, reasoning
253
254### Risks & Misuses
255
256Adversarial attacks, factuality issues, and bias mitigation — see [references/prompting-risks.md](references/prompting-risks.md). Covers:
257- **Adversarial Prompting** — prompt injection, prompt leaking, jailbreaking (DAN, Waluigi Effect), defense tactics
258- **Factuality** — ground truth grounding, calibrated confidence, admit-ignorance patterns
259- **Biases** — exemplar distribution skew, exemplar ordering effects, balanced few-shot design
260
261## Prompt Audit / Review
262
263When asked to audit, review, or improve a prompt, follow this workflow. Full checklist with per-check references: [prompt-audit-checklist.md](references/prompt-audit-checklist.md).
264
265### Workflow
266
2671. **Read the prompt fully** — identify its purpose, target model, and deployment context (interactive chat, agentic system, batch pipeline, RAG-augmented)
2682. **Walk 8 dimensions** — check each, note issues with severity (Critical / Warning / Suggestion):
269
270| # | Dimension | What to Check |
271|---|-----------|---------------|
272| 1 | **Clarity & Specificity** | Task definition, success criteria, audience, output format, conflicting constraints |
273| 2 | **Structure & Formatting** | Section separation (XML tags), prompt smells (monolithic, mixed layers, negative bias) |
274| 3 | **Safety & Security** | Control/data separation, secrets in prompt, injection resilience, tool permissions |
275| 4 | **Hallucination & Factuality** | Role framing, grounding, citation-without-sources, uncertainty handling |
276| 5 | **Context Management** | Info placement (not buried in middle), context size, RAG doc count, re-grounding |
277| 6 | **Maintainability & Debt** | Hardcoded values, regenerated logic, model pinning, testability |
278| 7 | **Model-Specific Fit** | Model-specific params and gotchas (see Model-Specific Guides below) |
279| 8 | **Evaluation Readiness** | Eval criteria, adversarial test cases, schema enforcement, monitoring |
280
2813. **Produce a report** — issues table (dimension, check, severity, issue, fix) + rewritten prompt or targeted fix suggestions. Use the report template from the checklist reference.
2824. **For each issue**, cite the relevant reference file so the user can dive deeper.
283
284### Quick Decision: Which Dimensions to Prioritize
285
286- **User-facing chatbot** → prioritize Safety (#3), Hallucination (#4), Clarity (#1)
287- **Agentic system with tools** → prioritize Safety (#3), Context (#5), Maintainability (#6)
288- **Batch/pipeline** → prioritize Structure (#2), Evaluation (#8), Maintainability (#6)
289- **RAG-augmented** → prioritize Context (#5), Safety (#3), Hallucination (#4)
290
291## Common Mistakes & Anti-Patterns
292
293Three complementary layers — use the one matching your need:
294
295**Deep-dives by category** — root causes, mechanisms, prevention checklists (from "The Architecture of Instruction", 2026):
296
297| Mistake Category | Key Issues | Reference |
298|-----------------|------------|-----------|
299| **Hallucinations & Logic** | Ambiguity-induced confabulation, automation bias, overloaded prompts, logical failures in verification tasks, no role framing | [mistakes-hallucinations.md](references/mistakes-hallucinations.md) |
300| **Structural Fragility** | Formatting sensitivity (up to 76pp variance), reproducibility crisis, prompt smells catalog (6 anti-patterns), deliberation ladder | [mistakes-structure.md](references/mistakes-structure.md) |
301| **Context Rot** | "Lost in the middle" U-shaped attention, RAG over-retrieval, naive data loading, context engineering shift | [mistakes-context.md](references/mistakes-context.md) |
302| **Prompt Debt** | Token tax of regenerative code, debt taxonomy (prompt/hyperparameter/framework/cost), multi-agent solutions, automated repair | [mistakes-debt.md](references/mistakes-debt.md) |
303| **Security** | Direct/indirect injection, jailbreaking, system prompt leakage (OWASP LLM07:2025), RAG poisoning, multimodal injection, adversarial suffixes | [mistakes-security.md](references/mistakes-security.md) |
304
305**Quick reference** — 18-category taxonomy with MRPs, risk scores, case studies, action items: [failure-taxonomy.md](references/failure-taxonomy.md). Start here for an overview or to prioritize which categories to address first. Covers: control-plane vs data-plane model, heuristic risk scoring, real-world incidents (EchoLeak CVE-2025-32711, Mata v. Avianca, Samsung shadow AI).
306
307**How to measure & test** — eval metrics, CI gating, red-teaming, tooling: [evaluation-redteaming.md](references/evaluation-redteaming.md). Covers: TruthfulQA, FActScore, SelfCheckGPT, PromptBench, AILuminate, LLM-as-judge pitfalls, guardrail libraries, open research questions.
308
309## Model-Specific Guides
310
311Each model family has unique parameters, gotchas, and patterns. Consult the reference for your target model:
312
313- **[Claude Family](references/claude-family-prompting.md)** — Opus 4.7 / 4.6 / Sonnet 4.6 / 4.5 / Haiku 4.5: adaptive thinking (`effort` with new `xhigh` on 4.7), `task_budget` agentic-loop ceiling, legacy `thinking.budget_tokens` 400-error on 4.7, new tokenizer (~1.35× text, ~3× images), tool under-triggering on 4.7 (vs 4.6 over-triggering), more literal instruction-following, server-side compaction beta, Managed Agents memory beta, Cyber Verification gate, prefill deprecation, Structured Outputs, prompt caching, citations, context engineering, vision crop tool, migration paths 4.5 → 4.6 → 4.7
314- **[GPT-5 Family](references/gpt5-family-prompting.md)** — GPT-5 / 5.1 / 5.2 / 5.4 / 5.5: `reasoning_effort` (last-mile knob in 5.4/5.5), `text.verbosity`, named tools (`apply_patch`), agentic eagerness templates, completeness/verification contracts, compaction API, `phase` field, outcome-first prompts, personality vs collaboration style, retrieval budgets, mini/nano guidance, migration paths
315- **[Gemini 3 Family](references/gemini3-family-prompting.md)** — Gemini 2.5/3/3.1: temperature MUST be 1.0, `thinking_budget` vs `thinking_level`, constraint placement (end of prompt), persona priority, function calling, structured output, multimodal, image generation
316- **[GPT-5.2 Specifics](references/gpt5-prompting-guide.md)** — Compaction API code examples, web research agent prompt, full XML specification blocks