Prompt Engineering

Prompt Engineering: How to Talk to the AI

How the words you choose change the answers you get from an AI — and a simple 4-step recipe for better prompts.

Scroll to start

Talking to an AI Is a Skill

A prompt is just the message you send to an AI. That's it. It's a question, a request, a description, or a chunk of text. The AI reads your prompt and writes a reply.

But here's the thing most people miss: how you say something often matters more than what you say. Ask a vague question, get a vague answer. Ask a clear question with enough context, and the same AI can give you something useful enough to use right away. The same AI, the same question, two completely different results — all because of the words.

This is what prompt engineering means. It's not a fancy tech skill. It's just getting good at telling an AI exactly what you want, in a way it can act on. Think of it like giving directions: "go somewhere nice" leads nowhere, but "drive 20 minutes north to the lake with the picnic tables" gets you there.

Same AI, Wildly Different Answers

Watch what happens when you give an AI almost nothing to work with, then give it a clear, specific ask. Same tool, totally different output. The bad prompt gives you a list you have to redo. The good prompt gives you something you can paste and use.

Bad Prompt

  • Too vague — the AI has to guess
  • No idea who the audience is
  • No idea how long or what style
  • You get generic filler you have to rewrite

Good Prompt

  • Names the role, audience, and goal
  • Spells out format, length, and tone
  • Gives an example to copy
  • First draft is close to ready to use

💡 Key Insight

The AI isn't reading your mind — it's reading your words. Two prompts that mean the same thing to a human can produce totally different answers, because the AI is matching patterns, not understanding intent. Adding a few extra sentences of context almost always beats re-running the same vague prompt and hoping for a better roll of the dice.

The 4-Step Prompt Recipe

You don't need a special formula for every prompt. But when you want a really good answer — one you can actually use — running your prompt through these four steps almost always helps. Each step adds a small piece of context the AI was missing before.

The Prompt Recipe Loop
🎭
Set Role
Tell the AI who to be
📋
Add Context
Give background the AI needs
🎯
Be Specific
Format, length, tone, rules
📝
Show Example
A sample of what "good" looks like
repeat and refine

Step 1 — Set the role. "You are a friendly teacher" gets you a different reply than "You are a senior Python developer." The role tells the AI which voice, vocabulary, and level of detail to use.

Step 2 — Give context. Tell the AI who you are, what you're working on, and why you need this. Two sentences of background often saves five follow-up messages.

Step 3 — Be specific. "Write a short answer" is weak. "Write 3 bullet points, each under 20 words, in plain English" is specific. The more concrete the request, the less the AI has to guess.

Step 4 — Show an example. Paste a small sample of the format, tone, or style you want. The AI is much better at copying a pattern than inventing one from scratch.

Asking for a Python Function

Let's say you want a Python function that takes a list of numbers and returns the average. Here's a vague prompt and a structured prompt, side by side. Same AI, same goal — but the structured one saves you a lot of cleanup.

Before — the vague version:

prompt-vague.txt
write a python function for average

The AI will probably give you something that works, but it might use a name you don't like, skip error handling, return a whole number instead of a decimal, or add a docstring you didn't want. You'll have to ask for changes.

After — the structured version using the 4-step recipe:

prompt-structured.txt
You are a senior Python developer helping a beginner.

I'm a 5th-grade teacher writing a small script to average my
students' test scores. I need a function I can paste into a
classroom notebook.

Please write a Python function that:
  - is called average
  - takes a list of numbers (can be empty)
  - returns 0.0 if the list is empty, otherwise the mean
  - includes a short docstring and one example of how to call it
  - is no more than 10 lines total

Example of the style I want:
    def add(a, b):
        """Return the sum of a and b."""
        return a + b

That single prompt gives you a function that's almost certainly ready to use on the first try: right name, right behavior, short docstring, an example. No back-and-forth needed. You added about 30 seconds of writing and saved 10 minutes of cleanup.

Knowledge Check

Test what you learned with this quick quiz.

Quick Quiz — 3 Questions

Question 1
What is a "prompt" in the context of talking to an AI?
Question 2
Why does the same AI give such different answers to two similar prompts?
Question 3
In the 4-step prompt recipe, what is the purpose of "showing an example"?
🏆

You crushed it!

Perfect score on this module.