Skip to main content
This appendix provides reusable prompt templates and patterns for common agentic operations.

System Prompt Structure

The system prompt establishes identity, capabilities, and constraints.
You are a [role] that [primary function].

Your capabilities:
- [capability 1]
- [capability 2]

Your constraints:
- [constraint 1]
- [constraint 2]

[Additional context or instructions]
Example:
You are a research analyst that synthesizes information from multiple sources into clear, accurate reports.

Your capabilities:
- Search the web for current information
- Analyze and compare multiple sources
- Identify gaps and contradictions in information
- Produce structured summaries with citations

Your constraints:
- Only use information from provided sources or search results
- Always cite sources for factual claims
- Acknowledge uncertainty when information is incomplete
- Never fabricate statistics or quotes

When researching, prioritize authoritative sources over general content.

Few-Shot Pattern

Show examples before requesting completion.
Here are examples of [task]:

Example 1:
Input: [example input]
Output: [example output]

Example 2:
Input: [example input]
Output: [example output]

Now complete this:
Input: [actual input]
Output:
Example - Classification:
Classify customer inquiries into categories.

Examples:
Input: "I can't log into my account"
Output: {"category": "account", "intent": "login_issue"}

Input: "How much does the premium plan cost?"
Output: {"category": "billing", "intent": "pricing_inquiry"}

Input: "The app crashes when I try to upload photos"
Output: {"category": "technical", "intent": "bug_report"}

Now classify:
Input: "I was charged twice this month"
Output:

Chain of Thought

Request explicit reasoning before conclusions.
Think through this step by step:
1. First, [identify/analyze/consider] [aspect 1]
2. Then, [evaluate/determine/assess] [aspect 2]
3. Finally, [conclude/decide/synthesize] [outcome]

Show your reasoning before giving the final answer.
Example:
Determine if this code change is safe to deploy.

Think through this step by step:
1. First, identify what the change modifies (files, functions, interfaces)
2. Then, evaluate the potential impact (what could break, who is affected)
3. Then, consider edge cases and error scenarios
4. Finally, provide a deployment recommendation with confidence level

Show your reasoning for each step before the final recommendation.

Code change:
[diff content]

Structured Output

Request specific JSON or formatted output.
Analyze [input] and return a JSON object with this structure:
{
  "field1": "description of field1",
  "field2": ["array", "of", "items"],
  "field3": {
    "nested": "object"
  }
}

Only return valid JSON, no additional text.
Example:
Extract entities from this customer message.

Return JSON with this structure:
{
  "entities": [
    {"type": "product|order|date|amount", "value": "extracted value", "confidence": 0.0-1.0}
  ],
  "sentiment": "positive|neutral|negative|frustrated",
  "urgency": "low|medium|high"
}

Message: "I ordered the blue widget (order #12345) last Tuesday but it still hasn't arrived and I need it for an event this weekend!"

Evaluation and Critique

Request assessment of content quality.
Evaluate this [content type] on the following criteria:
- [criterion 1]: [what it means]
- [criterion 2]: [what it means]
- [criterion 3]: [what it means]

For each criterion:
1. Score from 0-10
2. Provide specific evidence for the score
3. Suggest improvements if score < 8

[Content to evaluate]
Example:
Evaluate this customer service response on the following criteria:
- Accuracy: Information is factually correct
- Completeness: Fully addresses the customer's question
- Tone: Professional, empathetic, and helpful
- Clarity: Easy to understand, well-organized

For each criterion:
1. Score from 0-10
2. Provide specific evidence for the score
3. Suggest improvements if score < 8

Customer question: "Why was I charged $50 when the website says $40?"

Response: "The $50 charge includes the $40 product price plus $10 shipping. You can see the shipping cost during checkout. Let me know if you need anything else!"

Decomposition

Break complex tasks into subtasks.
Break this [task/problem] into smaller steps:

Task: [description]

For each step:
1. Describe what needs to be done
2. Identify dependencies (what must complete first)
3. Estimate relative complexity (simple/medium/complex)

Return as a numbered list with dependencies noted.
Example:
Break this feature request into implementation steps:

Feature: Add user authentication with email/password and OAuth (Google, GitHub)

For each step:
1. Describe what needs to be done
2. Identify dependencies (what must complete first)
3. Estimate relative complexity (simple/medium/complex)
4. Note which steps can be parallelized

Return as a structured plan.

Synthesis

Combine multiple inputs into coherent output.
Synthesize these [inputs] into a coherent [output type]:

[Source 1]: [content]
[Source 2]: [content]
[Source 3]: [content]

Requirements:
- [requirement 1]
- [requirement 2]
- Note any contradictions between sources
- Cite sources using [n] notation
Example:
Synthesize these research findings into an executive summary:

[Source 1 - Industry Report]: Market grew 15% YoY, driven primarily by enterprise adoption...
[Source 2 - Competitor Analysis]: Three major players control 70% of market share...
[Source 3 - Customer Survey]: 65% of users cite integration capabilities as primary purchase factor...

Requirements:
- Maximum 3 paragraphs
- Lead with the most important finding
- Note any contradictions between sources
- Cite sources using [n] notation
- Conclude with implications for our strategy

Error Analysis

Transform errors into actionable fixes.
Analyze this error and provide a fix:

Error message:
[error output]

Context:
[relevant code or configuration]

Provide:
1. Root cause (what specifically went wrong)
2. Fix (exact changes needed)
3. Prevention (how to avoid this in future)
Example:
Analyze this error and provide a fix:

Error message:
TypeError: Cannot read property 'map' of undefined
  at ProductList (ProductList.tsx:15:23)

Context:
```typescript
function ProductList({ products }) {
  return (
    <ul>
      {products.map(p => <li key={p.id}>{p.name}</li>)}
    </ul>
  );
}
Provide:
  1. Root cause (what specifically went wrong)
  2. Fix (exact changes needed)
  3. Prevention (how to avoid this in future)

## Role Instruction for Specialized Tasks

Set up specific expertise for domain tasks.

You are an expert [specialist type] with deep knowledge of:
  • [domain knowledge 1]
  • [domain knowledge 2]
Your task is to [specific task]. Approach this as a [specialist] would:
  • [characteristic behavior 1]
  • [characteristic behavior 2]
[Specific instructions for the task]

**Example - Code Review:**

You are an expert code reviewer with deep knowledge of:
  • TypeScript best practices
  • React performance optimization
  • Security vulnerabilities in web applications
Your task is to review this pull request for issues. Approach this as a senior engineer would:
  • Focus on correctness, security, and maintainability
  • Suggest improvements, not just flag problems
  • Prioritize issues by severity
Review this code and categorize findings as:
  • Critical: Must fix before merge
  • Important: Should fix, can merge with follow-up
  • Suggestion: Nice to have improvements
[Code to review]

## Grounded Generation

Ensure outputs are based on provided information.

Based ONLY on the following information, [task]: Information: [provided context] Rules:
  • Only use facts from the provided information
  • If the information doesn’t address something, say so explicitly
  • Do not use general knowledge unless it’s to clarify provided facts
  • Cite specific parts of the information when making claims

**Example:**

Based ONLY on the following product documentation, answer the customer’s question: Documentation: """ The Pro plan includes 100GB storage, unlimited projects, and priority support. The Team plan includes everything in Pro plus SSO, audit logs, and a dedicated account manager. All plans include a 14-day free trial. Annual billing provides a 20% discount. """ Rules:
  • Only use facts from the provided documentation
  • If the documentation doesn’t address something, say “I don’t have information about that” and suggest contacting support
  • Do not make assumptions about features not explicitly mentioned
Customer question: “Does the Pro plan include SSO?”

## Meta-Prompting

Use the model to improve prompts.

You are a prompt engineering expert. Given this prompt and its performance, suggest improvements: Current prompt: [prompt text] Performance issues: [what’s not working well] Desired outcome: [what we want to achieve] Suggest a revised prompt that addresses these issues while maintaining the original intent. Explain why your changes should improve performance.

## Confidence Calibration

Request explicit confidence assessments.

[Task instructions] After completing the task, provide:
  1. Your response/output
  2. Confidence level (0-100%)
  3. What would increase your confidence
  4. What could be wrong with your response
Be well-calibrated: high confidence should mean high accuracy, uncertainty should be expressed as low confidence.

**Example:**

Classify this customer inquiry and suggest a response. Inquiry: “Why did my order arrive damaged?” After classification, provide:
  1. Category and suggested response
  2. Confidence level (0-100%)
  3. What additional information would increase confidence
  4. What assumptions might be wrong
Be well-calibrated: express genuine uncertainty when the inquiry is ambiguous.