Skip to main content

Prompt Engineering

Prompt engineering is the art and science of communicating effectively with AI models. Good prompts lead to better, more accurate, and more useful responses. This lesson will teach you how to craft excellent prompts.

What is Prompt Engineering?

Prompt engineering is the practice of designing and refining the text input (prompts) you give to AI models to get the best possible outputs. It's like learning how to ask the right questions in the right way.

Why It Matters

  • Better prompts = better results
  • Saves time by reducing back-and-forth
  • Helps you get more accurate and relevant responses
  • Maximizes the value you get from AI tools

Core Principles of Good Prompts

1. Be Specific and Clear

Poor prompt: "Write something about dogs"

Good prompt: "Write a 300-word informative article about golden retriever care tips for first-time dog owners, focusing on feeding, exercise, and grooming"

2. Provide Context

Poor prompt: "Make this better"

Good prompt: "I'm writing a professional email to a potential client. Please improve this draft for clarity and persuasiveness while maintaining a respectful tone: [insert draft]"

3. Specify the Format

Poor prompt: "Explain machine learning"

Good prompt: "Explain machine learning in a bulleted list format, with 5 main points, each followed by a one-sentence example suitable for a high school student"

4. Set Constraints

Poor prompt: "Plan a vacation"

Good prompt: "Plan a 5-day vacation to Italy for two adults with a $3000 budget, focusing on art museums and local cuisine, avoiding crowded tourist attractions"

The CLEAR Framework

Use this framework to structure your prompts:

C - Context

Provide background information and set the scene

L - Length

Specify how long or short you want the response

E - Examples

Give examples of what you want or don't want

A - Audience

Define who the content is for

R - Role

Ask the AI to take on a specific perspective or expertise

Example Using CLEAR

Context: I'm preparing a presentation for my company's quarterly meeting
Length: I need 5 key talking points, each about 2 sentences long
Examples: Focus on growth metrics, not technical details
Audience: Senior executives who prefer data-driven insights
Role: Act as a business analyst

Task: Summarize our Q3 performance highlighting wins and areas for improvement in our customer acquisition strategy.

Advanced Prompting Techniques

Chain-of-Thought Prompting

Ask the AI to show its reasoning process:

Solve this step-by-step, showing your work:
If a store offers a 20% discount on a $150 item, and then applies a 6% sales tax to the discounted price, what is the final amount the customer pays?

Few-Shot Learning

Provide examples of the pattern you want:

I'll give you some product names, and you create marketing taglines for them. Here are examples:

Product: EcoClean Detergent
Tagline: "Clean clothes, cleaner planet"

Product: SpeedRun Sneakers
Tagline: "Every step counts"

Now create a tagline for: AquaPure Water Filter

Role-Playing

Ask the AI to adopt a specific persona or expertise:

You are an experienced financial advisor speaking to a 25-year-old who just got their first job making $60,000/year. Explain the basics of retirement planning in terms they can understand and relate to.

Comparative Analysis

Ask for comparisons to clarify complex topics:

Explain the difference between copyright, trademark, and patent protection by comparing them to protecting different aspects of a restaurant business.

Common Prompt Patterns

The Question Ladder

Start broad, then get specific:

1. What are the main types of renewable energy?
2. Which type is most suitable for residential use?
3. What are the costs and benefits of residential solar panels?
4. What factors should I consider when choosing a solar installer?

The Template Pattern

Create reusable prompt structures:

Blog Post Template:
Topic: [TOPIC]
Target Audience: [AUDIENCE]
Tone: [professional/casual/humorous]
Length: [word count]
Key Points to Cover: [list 3-4 main points]
Call to Action: [what should readers do next]

Please write a blog post following this template.

The Constraint Pattern

Use limitations to guide creativity:

Write a product description with these constraints:
- Exactly 50 words
- Include the benefits "durable" and "eco-friendly"
- Use a conversational tone
- End with a question
- Target audience: outdoor enthusiasts

Iterative Refinement

The Build-and-Refine Approach

  1. Start with a basic prompt
  2. Evaluate the response
  3. Identify what needs improvement
  4. Refine and try again

Example progression:

First attempt: "Write about climate change"

Response evaluation: Too broad, not actionable

Second attempt: "Write 5 actionable tips for reducing personal carbon footprint"

Response evaluation: Good list, but need more detail

Final prompt: "Write 5 specific, actionable tips for reducing personal carbon footprint, with each tip including the estimated impact and difficulty level for the average person to implement"

Common Refinement Needs

If response is too generic:

  • Add more specific context
  • Include examples of what you want
  • Narrow the scope

If response is too long:

  • Set word or sentence limits
  • Ask for bullet points instead of paragraphs
  • Request a summary version

If response misses the mark:

  • Clarify the purpose or goal
  • Provide more context about your situation
  • Specify the audience or use case

Troubleshooting Common Issues

Problem: AI Gives Outdated Information

Solutions:

  • Acknowledge the knowledge cutoff in your prompt
  • Ask for general principles instead of specific current events
  • Request information that you can verify independently
Knowing that your information might not include the latest developments, what are the general principles for evaluating cryptocurrency investments that have remained consistent over time?

Problem: AI Response is Too Confident About Uncertain Information

Solutions:

  • Ask for uncertainty levels
  • Request multiple perspectives
  • Ask for reasoning behind conclusions
Explain the potential impacts of AI on employment, including your confidence level in each prediction and what factors might change these outcomes.

Problem: AI Doesn't Follow Instructions

Solutions:

  • Break complex requests into smaller parts
  • Use formatting to highlight important requirements
  • Repeat key constraints at the end of the prompt
Please write a product review following these requirements:
1. Exactly 200 words
2. Include both pros and cons
3. Rate on a 1-10 scale
4. Written for budget-conscious consumers

IMPORTANT: Please ensure the review is exactly 200 words and includes a numerical rating.

Platform-Specific Tips

ChatGPT

  • Works well with conversational, natural language
  • Good at following multi-step instructions
  • Benefits from context-building over multiple messages

Claude

  • Excels at nuanced instructions and ethical considerations
  • Good at acknowledging limitations and uncertainty
  • Responds well to polite, conversational prompts

Google Gemini

  • Strong at factual queries and research tasks
  • Good integration with Google services context
  • Works well with structured, specific requests

Measuring Prompt Effectiveness

Quality Indicators

Relevance: Does the response address your actual need? Accuracy: Is the information correct and reliable? Completeness: Does it cover all aspects you requested? Clarity: Is the response easy to understand? Usefulness: Can you immediately apply or use the output?

Testing and Iteration

  1. Save successful prompts for similar future tasks
  2. Create prompt templates for recurring needs
  3. Test variations to see what works best
  4. Document what works for your specific use cases

Practical Exercises

Exercise 1: Prompt Transformation

Take this poor prompt: "Help with my presentation"

Transform it using the CLEAR framework for these scenarios:

  • A sales presentation to potential clients
  • A technical presentation to your development team
  • A progress update to your manager

Exercise 2: Chain-of-Thought Practice

Create a prompt that asks the AI to solve a complex problem step-by-step, such as:

  • Planning a budget for a small business
  • Choosing between different software solutions
  • Analyzing the pros and cons of a career change

Exercise 3: Role-Playing Refinement

Practice the same prompt with different role specifications:

  • As a teacher explaining to students
  • As a consultant advising a client
  • As a peer sharing with a colleague

What's Next?

Now that you understand prompt engineering fundamentals, let's learn about quality control and how to verify and improve AI outputs.

Key Takeaways

  • Specific, clear prompts with context produce better results
  • Use the CLEAR framework: Context, Length, Examples, Audience, Role
  • Iterative refinement helps you discover what works best
  • Different AI platforms respond better to different prompting styles
  • Save and reuse successful prompts for similar tasks
  • Always evaluate responses for relevance, accuracy, and usefulness
  • Good prompt engineering is a skill that improves with practice