Free Interactive Course · Prompt Engineering

Prompt Engineering

Learn prompt engineering by doing — a free, hands-on course. Edit real prompts and run them against a live AI model right in your browser, then master roles, few-shot examples, structured output, chain-of-thought, and more. No signup.

How this course works

Every example below is a live prompt cell. Edit the prompt, press Run, and a real language model (Llama 3.3 70B) responds — so you learn by watching your words change the output. Work top to bottom, or jump around with the contents on the left.

Each lesson ends with a mission from Priya, the founder of a fictional tea shop, graded by an AI examiner. Solve all eight, then beat the Boss Battle to earn a shareable Proof-of-Skill card.

01

The Anatomy of a Prompt

A prompt is the instruction you give a large language model (LLM). The model reads your text and predicts a helpful continuation. The whole skill of prompt engineering is shaping that text so the output is reliably useful — not left to luck. Press Run below to send your first prompt to a live model (Llama 3.3 70B) and see what comes back:

PROMPT
⌘/Ctrl + Enter

It works — but a bare instruction leaves a lot to chance. Strong prompts usually contain four ingredients:

1. Instruction — what to do.   2. Context — who/what it's for.   3. Input — the specific data to work on.   4. Output format — the shape you want back.

Watch what those ingredients do. Run both prompts below and compare the two responses side by side — same task, wildly different usefulness:

PROMPTBare instruction
⌘/Ctrl + Enter
PROMPTAll four ingredients
⌘/Ctrl + Enter
🧠 Quick check
Which ingredient is missing from this prompt?
You are a support agent. A customer asks why their order is late. Reply politely.
P
PriyaFounder · Kettle & Co.now
Morning! ☕ New sign-ups are pouring in and our welcome email feels generic. Can you get the model to write a warm welcome message for a new Kettle & Co. customer? Keep it to 2 sentences, mention a 10% first-order discount, and end with a friendly sign-off from “The Kettle & Co. team”. 🙏
🎯 Your mission Write a prompt that produces a 2-sentence welcome message mentioning a 10% first-order discount and signed off by “The Kettle & Co. team”.
PROMPT
⌘/Ctrl + Enter
02

Be Specific: Clarity, Context & Constraints

The single biggest upgrade to any prompt is specificity. Vague prompts force the model to guess your intent — and it guesses average. Every constraint you add removes a whole class of wrong answers. Run this vague prompt first:

PROMPT
⌘/Ctrl + Enter

Notice how generic that is. Now pin down the audience, the goal, the count, and the format. Run the sharpened version and compare:

PROMPTVague
⌘/Ctrl + Enter
PROMPTSpecific + constrained
⌘/Ctrl + Enter
The specificity checklist: Who is it for? What's the goal? How long / how many? What format? What should it avoid? Answer those in the prompt and the output sharpens dramatically.

Constraints also include what to exclude. Telling the model what not to do (“no jargon”, “don't mention price”, “avoid clichés”) is often as powerful as telling it what to do. Try editing the prompt below to add one exclusion, then Run:

PROMPT
⌘/Ctrl + Enter
🧠 Quick check
Your prompt returns text that's technically correct but far too long. What's the most direct fix?
P
PriyaFounder · Kettle & Co.now
Our product pages are a mess — every description is a different length and vibe. I need a repeatable prompt I can reuse for any product. For our “Earl Grey Supreme” loose-leaf tea, get me a description that's under 50 words, in a warm but not cheesy tone, and that doesn't mention price. ✨
🎯 Your mission Write a specific prompt that produces an under-50-word, warm (not cheesy) product description for “Earl Grey Supreme” loose-leaf tea, with no mention of price.
PROMPT
⌘/Ctrl + Enter
03

Role & Persona Prompting

Assigning the model a role (“You are a senior tax accountant…”) primes it to draw on the right vocabulary, assumptions, and standards. It's the fastest way to shift both the content and the tone of an answer. The same question, three roles — run each and feel the difference:

PROMPT
⌘/Ctrl + Enter

Roles are even more powerful as a system prompt — a persistent instruction that frames every reply. Below, the role lives in the (hidden) system prompt; the user message is just the question. Run it, then imagine reusing that same system prompt across a whole app:

PROMPT
⌘/Ctrl + Enter

Compare a generic role with a rich, specific persona — specificity beats a bare job title:

PROMPTGeneric role
⌘/Ctrl + Enter
PROMPTRich persona
⌘/Ctrl + Enter
🧠 Quick check
What's the main benefit of putting a role in the system prompt rather than repeating it in every user message?
P
PriyaFounder · Kettle & Co.now
We're launching a live chat widget and I want it to sound like us, not a robot. Design the system prompt for our support persona “Sage”: warm and concise, only talks about tea and Kettle & Co. orders, politely refuses off-topic questions, and never invents a refund policy it isn't sure about. Make it reusable. 🫖
🎯 Your mission Write a system prompt defining the “Sage” support persona: warm + concise tone, stays on-topic (tea / Kettle & Co. orders), politely declines off-topic questions, and won't fabricate policies.
PROMPT
⌘/Ctrl + Enter
04

Few-Shot Prompting: Teaching by Example

Sometimes the easiest way to describe what you want is to show it. Few-shot prompting means including a handful of input→output examples so the model infers the exact pattern, format, and tone. Zero examples is “zero-shot”; a few is “few-shot”. Run this classifier that learns purely from three examples:

PROMPT
⌘/Ctrl + Enter

The model matched the label and the format from the examples alone — no rules needed. Few-shot shines when the format is fiddly. Compare describing a format in words vs. just showing one example:

PROMPTTold in words
⌘/Ctrl + Enter
PROMPTShown by example
⌘/Ctrl + Enter
Few-shot tips: keep examples consistent in format (the model copies quirks too), cover the edge cases you care about, and 2–5 examples is usually plenty — more isn't always better.
🧠 Quick check
Your few-shot examples all end labels with a period (“HAPPY.”) by accident. What will the model most likely do?
P
PriyaFounder · Kettle & Co.now
Support is drowning in messages and I want to auto-route them. Build a few-shot prompt that tags any incoming message as one of ORDER, PRODUCT, or COMPLAINT, and outputs only the tag. Use examples so it nails the format every time. 📬
🎯 Your mission Write a few-shot prompt that classifies a customer message as ORDER, PRODUCT, or COMPLAINT and outputs only that single tag.
PROMPT
⌘/Ctrl + Enter
05

Structured Output: Delimiters, Formats & JSON

When an LLM feeds another system — code, a database, a spreadsheet — you need output in a predictable shape, not prose. Ask for it explicitly. Run this to get clean JSON you could parse in one line of code:

PROMPT
⌘/Ctrl + Enter

Two techniques do the heavy lifting here. Delimiters (triple quotes, XML-style tags, or ###) fence off the input so the model can't confuse instructions with data. And an explicit schema tells it exactly which fields to emit. Run this — the delimiters keep the customer's text from hijacking your instructions:

PROMPT
⌘/Ctrl + Enter

That fence is also your first taste of defending against prompt injection: the customer text tried to hijack the instruction, but fencing + a clear task kept the model on track. Compare a loose format request with a rigid, machine-ready one:

PROMPTLoose
⌘/Ctrl + Enter
PROMPTMachine-ready JSON
⌘/Ctrl + Enter
🧠 Quick check
Why wrap user-supplied text in delimiters like <review>…</review>?
P
PriyaFounder · Kettle & Co.now
I'm building a little dashboard and I need our support inbox turned into structured data. Write a prompt that reads a customer message and returns JSON with category (one of order/product/complaint), sentiment (positive/neutral/negative), and summary (max 10 words). It has to be only JSON so my code can parse it. 🛠️
🎯 Your mission Write a prompt that outputs ONLY JSON with keys category (order/product/complaint), sentiment (positive/neutral/negative), and summary (≤10 words) for a customer message.
PROMPT
⌘/Ctrl + Enter
06

Chain-of-Thought: Make It Reason

For anything involving logic, math, or multiple steps, models are far more accurate when you let them think step by step before answering. This is chain-of-thought (CoT) prompting. Run this word problem — the instruction to reason first is doing real work:

PROMPT
⌘/Ctrl + Enter

The magic phrase is literally “let's think step by step.” Compare demanding an instant answer vs. inviting reasoning — on a tricky question the difference in accuracy is stark:

PROMPTAnswer immediately
⌘/Ctrl + Enter
PROMPTReason first
⌘/Ctrl + Enter
Trade-off: reasoning costs more tokens and adds latency. For simple lookups you don't need it. When you want the reasoning but not the clutter, ask the model to think, then output only the final answer (or put the working inside tags you can strip).
🧠 Quick check
When does chain-of-thought help the most?
P
PriyaFounder · Kettle & Co.now
Customers keep asking us to recommend a tea based on a few preferences, and our replies feel random. Write a prompt that takes a customer's stated preferences and reasons step by step — considering caffeine, flavour, and time of day — before recommending exactly one tea, with a one-line reason. 🍵
🎯 Your mission Write a prompt that reasons step by step over a customer's preferences (caffeine, flavour, time of day) and then recommends exactly one tea with a short reason.
PROMPT
⌘/Ctrl + Enter
07

Prompt Chaining & Decomposition

Complex jobs get more reliable when you break them into a chain of smaller prompts, feeding each output into the next — instead of asking for everything at once. Each step is simpler, easier to check, and easier to fix. Imagine turning a raw customer review into a public reply in three steps.

Step 1 — extract. Pull the structured facts out of messy text:

PROMPT
⌘/Ctrl + Enter

Step 2 — draft. In a real app you'd paste Step 1's output here; then ask for a reply that addresses each point:

PROMPT
⌘/Ctrl + Enter

Step 3 — refine. Polish tone/length as a separate pass. Splitting the work means when the reply is too long, you only re-run this step. Compare doing it all in one mega-prompt vs. the focused final step:

PROMPTOne overloaded prompt
⌘/Ctrl + Enter
PROMPTOne focused step
⌘/Ctrl + Enter
🧠 Quick check
What's the main advantage of chaining prompts instead of one giant prompt?
P
PriyaFounder · Kettle & Co.now
I want to auto-summarise our daily reviews for the team standup. Design the first step of a chain: a prompt that reads a batch of reviews and outputs a tight structured summary — overall sentiment, the top praise, and the top complaint — so a later step can turn it into an action list. 📊
🎯 Your mission Write the first-stage prompt of a chain: read reviews and output a structured summary with overall sentiment, top praise, and top complaint.
PROMPT
⌘/Ctrl + Enter
08

Evaluating & Iterating (and Beating Hallucinations)

A prompt isn't “done” when it works once — it's done when it works reliably across many inputs. Prompt engineering is a loop: draft → test on varied cases → spot failures → tighten the prompt → repeat. The mindset that separates hobbyists from pros is testing on the hard cases, not the easy one you had in mind.

The most important failure to guard against is hallucination — confident, made-up answers. Run this: without a safety valve, the model may invent a policy that doesn't exist:

PROMPT
⌘/Ctrl + Enter

The two anti-hallucination moves: ground the model in provided facts, and give it an escape hatch (“say you don't know”). Compare a prompt that invites guessing with one that forbids it:

PROMPTInvites guessing
⌘/Ctrl + Enter
PROMPTGrounded + escape hatch
⌘/Ctrl + Enter
How to evaluate a prompt: collect 5–10 realistic test inputs (including nasty edge cases), run them all, and check each output against what you actually wanted. Track failures; each one becomes a new constraint in the prompt.
🧠 Quick check
A customer asks something not covered by the facts you gave the model. The safest prompt design makes it:
P
PriyaFounder · Kettle & Co.now
Last thing — our FAQ bot occasionally makes up answers, which is scary for customers. Rewrite its instructions so it only answers from the FAQ we give it, and when the answer isn't there it admits it and offers a human instead of guessing. Ground it and give it an escape hatch. 🛡️
🎯 Your mission Write a prompt for an FAQ bot that answers only from provided FAQ text and, when the answer isn't present, admits it and offers a human instead of guessing.
PROMPT
⌘/Ctrl + Enter
Boss Battle

Ship a Production Support Bot

Priya's giving you the big one: design the prompts behind Kettle & Co.'s real customer-support bot. Beat all three challenges — each is graded by an AI examiner against a professional rubric — to earn your Proof-of-Skill card.

0 / 3 challenges solved
Challenge 1 / 3

The System Prompt

P
PriyaFounder · Kettle & Co.now
First, the bot's identity. Write the system prompt for “Sage”, our support bot: a warm, concise persona that only handles tea & Kettle & Co. orders, politely declines off-topic questions, and refuses to invent policies. This is the foundation everything else sits on.
🎯 Your mission Write a reusable system prompt defining Sage: persona + tone, on-topic scope, off-topic handling, and no inventing policies.
PROMPT
⌘/Ctrl + Enter
Challenge 2 / 3

The Triage Classifier

P
PriyaFounder · Kettle & Co.now
Now make it route tickets. Write a prompt that tags each incoming message as ORDER, PRODUCT, or COMPLAINT and returns structured output our code can read — use examples so it's rock-solid.
🎯 Your mission Write a few-shot prompt that classifies a message as ORDER/PRODUCT/COMPLAINT and returns machine-readable output (only the label or clean JSON).
PROMPT
⌘/Ctrl + Enter
Challenge 3 / 3

The Grounded Answerer

P
PriyaFounder · Kettle & Co.now
Finally, the part that keeps us safe: the bot must answer only from our help-centre text and never make things up. Write the prompt that grounds Sage in a provided FAQ and gives it an escape hatch to a human when it doesn't know. Nail this and the bot's ready to ship. 🚀
🎯 Your mission Write a prompt that answers strictly from provided FAQ/context and defers to a human when the answer isn't present, with no guessing.
PROMPT
⌘/Ctrl + Enter

Frequently asked questions

What is prompt engineering?
Prompt engineering is the practice of writing and refining the instructions (“prompts”) you give a large language model so it produces reliable, useful output. It combines clear instructions, relevant context, examples, and output-format constraints — and an iterative loop of testing and tightening — to get consistent results instead of leaving the answer to chance.
Is this prompt engineering course really free?
Yes — completely free, with no signup, no account, and no paywall. Every lesson runs real prompts against a live language model right in your browser so you learn by doing.
Do I need to know how to code?
No. Prompt engineering is about writing clear instructions in plain English, not programming. If you can write an email, you can do this course. Developers will pick up extra techniques (structured JSON output, prompt chaining) they can drop straight into an app, but no coding is required to complete the course.
Which AI model do the exercises use?
The runnable exercises send your prompt to Meta's Llama 3.3 70B model and stream back a real response, so you see exactly how a production-grade LLM reacts to your wording. The techniques you learn — specificity, roles, few-shot examples, chain-of-thought — transfer directly to ChatGPT, Claude, Gemini, and any other modern LLM.
How long does the course take?
You can work through the eight lessons in about two to three hours, but every lesson is self-contained — you can dip into a single topic (like few-shot prompting or structured output) in a few minutes. Your progress is saved in your browser so you can pick up where you left off.
What will I be able to do after finishing?
You'll be able to write specific, well-structured prompts; assign roles and personas; teach a model by example with few-shot prompting; force clean JSON or other structured output; use chain-of-thought for reasoning tasks; break big jobs into prompt chains; and guard against hallucinations with grounding and escape hatches. The capstone has you design the prompts behind a real production support bot.

Ready to build on the LLM itself?

Prompt engineering is step one. Next, learn to write real queries against a live database — the SQL Mastery course is free and interactive too.

Explore SQL Mastery →