Prompt Engineering Guide

Master the art of writing effective prompts to get better, more consistent results from AI models.

1. Prompt Engineering Basics

Prompt engineering is the practice of designing inputs that guide AI models to produce desired outputs. A well-crafted prompt can dramatically improve the quality, accuracy, and usefulness of AI responses.

📝 Clear Instructions

Tell the model exactly what you want it to do. Ambiguity leads to inconsistent results.

🎯 Specific Details

Include relevant constraints, format requirements, and context for better outputs.

📋 Examples

Show the model what good output looks like with one or more examples.

🔄 Iterate

Refine your prompts based on results. Small changes can have big impacts.

2. Be Clear and Specific

Vague prompts get vague answers. The more specific you are about what you want, the better the results.

❌ Too Vague
"Write about dogs."
✅ Clear & Specific
"Write a 200-word blog introduction about the health benefits of adopting a rescue dog, targeting first-time pet owners."

💡 Pro Tip

Include details like: format (list, paragraph, JSON), length (word count, number of items), tone (professional, casual, technical), and audience (beginners, experts, children).

3. Provide Context

Context helps the model understand your situation and provide relevant responses.

✅ Good Context
System: You are a senior software engineer helping junior developers write clean, maintainable code. Focus on best practices and explain your reasoning.

User: How should I structure a React component that fetches user data and displays it in a table?

Use the System Message

The system message sets the overall behavior and context for the conversation:

Python
response = client.chat.completions.create(
    model="mythic-4",
    messages=[
        {
            "role": "system",
            "content": """You are a helpful customer support agent for TechCorp.
            - Always be polite and professional
            - If you don't know an answer, say so honestly
            - For billing issues, direct users to billing@techcorp.com"""
        },
        {
            "role": "user",
            "content": "How do I reset my password?"
        }
    ]
)

4. Use Examples (Few-Shot Prompting)

Show the model what you want by including examples in your prompt. This is especially useful for specific formats or styles.

✅ Few-Shot Example
Classify the sentiment of these product reviews as Positive, Negative, or Neutral.

Review: "Love this product! Works exactly as described."
Sentiment: Positive

Review: "It broke after two days. Complete waste of money."
Sentiment: Negative

Review: "It's okay, nothing special but does the job."
Sentiment: Neutral

Review: "Shipping was fast but the product is mediocre."
Sentiment:

💡 How Many Examples?

Start with 2-3 examples. More examples improve consistency but use more tokens. For simple tasks, even 1 example often works well.

5. Structure Your Output

Request specific output formats for easier parsing and more consistent results.

Request JSON Output

Prompt
Extract the following information from this text and return as JSON:
- person_name: The person's full name
- company: Their company name
- role: Their job title
- email: Their email address (or null if not found)

Text: "Hi, I'm Sarah Chen, Product Manager at Acme Corp. 
Reach me at sarah@acme.com."

Use Delimiters

Clear delimiters help the model understand where different parts of your prompt begin and end:

Prompt with Delimiters
Summarize the text between the triple backticks in one sentence.

```
The quick brown fox jumps over the lazy dog. This sentence 
contains every letter of the alphabet and is often used for
typing practice and font demonstrations.
```

6. Advanced Techniques

Chain of Thought

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

✅ Chain of Thought
Solve this problem step by step:

A store has 150 apples. They sell 40% in the morning and 30 more in the afternoon. How many apples are left?

Let's think through this step by step:

Role Assignment

Assign a specific role or persona for specialized responses:

✅ Role-Based Prompt
You are an expert cybersecurity consultant with 20 years of experience. A client asks:

"Is it safe to use public WiFi for online banking?"

Provide a detailed, expert-level response.

Prompt Chaining

Break complex tasks into multiple prompts for better results:

Quick Checklist