Prompt Engineering

Last updated: Jan 2026

Overview

Prompt engineering is the art of crafting instructions that guide AI models to produce the outputs you need. Well-designed prompts are the difference between unreliable results and consistent, high-quality automation.

A good prompt has three essential elements: Clear Intent (what you want the model to do), Context (background information), and Format (how the output should be structured).

Prompt Structure

A well-structured prompt has distinct sections that work together to guide the model effectively.

1

Role / Context

Define who the AI should be and the context it's operating in.

You are an expert customer support agent for a SaaS company...
2

Task / Instruction

Clearly state what you want the model to do.

Analyze the following customer email and classify its intent...
3

Input Data

The content to process, clearly delimited from instructions.

<email>[The email content will appear here]</email>
4

Output Format

Specify exactly how the response should be structured.

Respond with JSON: {"intent": "...", "priority": "...", "summary": "..."}

Key Techniques

These proven techniques improve prompt effectiveness and output quality.

Few-Shot Examples

Show the model what you want with examples of input to output pairs.

text
Classify the sentiment of these reviews:

Example 1:
Input: "This product changed my life! Best purchase ever."
Output: positive

Example 2:
Input: "Terrible quality. Broke after one week."
Output: negative

Now classify the provided review.
Output:

Chain of Thought

Ask the model to think step-by-step for complex reasoning tasks.

text
Analyze this support ticket and determine the appropriate action.

Think through this step by step:
1. What is the customer's main issue?
2. What is their emotional state?
3. Is this urgent or can it wait?
4. What department should handle this?

Then provide your final recommendation.

Clear Delimiters

Use XML tags, quotes, or other delimiters to separate sections.

text
<instructions>
Summarize the article in exactly 3 bullet points.
</instructions>

<article>
[The article content will appear here]
</article>

<output_format>
- Point 1
- Point 2
- Point 3
</output_format>

Constraints

Set explicit boundaries on what the output should or shouldn't include.

text
Generate a product description.

Constraints:
- Maximum 150 words
- Include exactly 3 key features
- Do not mention competitor products
- Use second person ("you", "your")
- End with a call to action

Examples & Templates

Here are ready-to-use prompt templates for common workflow tasks.

Email Classification
You are an email routing assistant.

Classify the provided email into exactly one category:
- support: Technical issues, bugs, how-to questions
- billing: Payments, invoices, subscription changes
- sales: Pricing inquiries, demos, enterprise questions
- feedback: Suggestions, complaints, praise
- other: Doesn't fit other categories

Respond with only the category name, nothing else.
Content Summarization
Summarize the provided content for a busy executive.

Requirements:
- 3-5 bullet points maximum
- Focus on actionable insights and key decisions
- Omit background information and context
- Use plain language, no jargon
Data Extraction
Extract the following information from the provided text.
If a field is not present, use null.

Required fields:
- name: Person's full name
- email: Email address
- phone: Phone number
- company: Company name
- role: Job title

Respond with valid JSON only, no explanation:
{"name": "...", "email": "...", "phone": "...", "company": "...", "role": "..."}

Common Mistakes

Avoid these common pitfalls when writing prompts.

MistakeHow to Fix
Vague instructionsBe specific: "Write a summary" becomes "Write a 2-sentence summary focusing on the main argument"
No output format specifiedAlways define expected format: JSON, bullet points, single word, etc.
Ambiguous input boundariesUse delimiters like <input>...</input> to clearly mark dynamic content
Too many instructions at onceBreak complex tasks into multiple prompts or use step-by-step guidance
Assuming model knowledgeProvide necessary context - don't assume the model knows your business rules
No examples for complex tasksInclude 2-3 examples of desired input to output for clarity

Testing Prompts

Test your prompts thoroughly before deploying to production.

  • Test edge cases: Empty inputs, very long inputs, unusual formats
  • Verify consistency: Run the same input multiple times to check stability
  • Try adversarial inputs: Test with inputs designed to confuse or break the prompt
  • Measure quality: Score outputs against a rubric for your use case

Iterate and Improve

Prompt engineering is iterative. Start with a basic prompt, test with real data, identify failures, and refine. Track what changes improve results.

Key Takeaways

Structure prompts with role, task, input, and output format sections.

Provide few-shot examples for complex or ambiguous tasks.

Use clear delimiters to separate instructions from data.

Set explicit constraints on output length, format, and content.

Test prompts with edge cases and verify consistency.