AI Prompt Engineering lessons
What is prompt engineering?
Prompt builder: switch the role, context, examples and format on and off and watch the reply go from vague to sharp.
A prompt is the message you give an AI model. Prompt engineering is the skill of writing prompts that get useful, accurate replies.
It is not about tricks. A good prompt says what you want, gives the background the AI needs, and describes the result you expect.
By the end of this course you will write sharp prompts, and brief AI agents that use tools to get real work done.
Tokens: how AI reads text
AI language models do not read whole words. They read tokens: short chunks of text such as a common word, part of a long word, or a punctuation mark.
Token chips: four kinds of text split into tokens, with token, word and character counts.
In English, one token is roughly four characters, or about three quarters of a word. Tokens matter because models are priced and limited by how many they handle.
One token at a time
A model writes its reply one token at a time. At each step it scores the possible next tokens and picks one of the likely ones.
Next-token bars: a sentence grows one picked token at a time, with the likely candidates at each step.
That pick has a little randomness in it, so the same prompt can give different replies. Some tools let you turn the randomness up or down with a setting called temperature.
Your prompt, the chat so far and any files you add all sit in the model's context window. If something is not in that window, like a file you forgot to attach, the model cannot see it.
Practice: Estimate the tokens
Use a rule of thumb to estimate a token count or a cost, typed as maths.
The anatomy of a prompt
Every prompt needs a task: the job you want done. Four optional parts make it sharper.
A role says who the AI should act as, and context gives the facts it cannot guess. Examples show the style you want, and a format says how to lay out the reply.
A full prompt split into its five parts, each lighting up with what it does.
Quick questions need only the task. Bigger jobs, like a report or a lesson plan, use every part.
Practice: Label the parts
Drag each part name onto the piece of the prompt it labels.
Be clear and specific
Write as if you were briefing a smart new colleague who knows nothing about your situation. Say who the result is for, what it is for, and what good looks like.
Swap vague words for exact ones, and say what to do rather than what to avoid. "Use short sentences" works better than "don't be wordy".
Vague and specific versions of the same request, side by side with the reply each one gets.
Practice: Spot the weak spot
A prompt went wrong: tap the part of it that caused the problem.
Show, don't just tell
Asking with no examples is called zero-shot prompting. Adding a few examples of input and output is called few-shot prompting.
Examples are the fastest way to show a format or a set of labels. The model copies the pattern closely, so keep your examples consistent.
The same labelling job with zero, one and three examples in the prompt.
Practice: Continue the pattern
Type the next example of a few-shot prompt so it follows the same pattern.
Give it room to think
Problems with several steps go better when the model works through them before it answers. This is called chain-of-thought prompting.
Many current models have a built-in thinking mode that does this for you. With others, ask them to work step by step, then check the steps as well as the answer.
A rushed answer beside one that works through the steps first.
Practice: When to ask for reasoning
Sort tasks by whether they need step-by-step reasoning.
System prompts
A system prompt is a set of standing instructions that applies to a whole conversation. Apps use it to give their AI a job, rules and a tone.
Developers write the system prompt into their app, and users usually never see it. Chat apps offer something similar, such as custom instructions.
A pizza shop's chat with and without its system prompt.
Practice: Build a system prompt
Fill a system prompt's role, rules and format from a bank of lines.
Ask for the format you need
Say exactly how the reply should be laid out: bullet points, a table, numbered steps or something else. A short sample of the layout works even better.
When a program will read the reply, ask for JSON, a text format that programs read easily. Many AI APIs can even force a reply to match a fixed JSON layout, called a schema.
One request in three layouts: bullets, a table and JSON.
Practice: Pick the format
Choose the format line that suits where the reply is going.
Refine with follow-ups
Treat the first reply as a draft. Use follow-up messages that name exactly what to change.
"Make it better" gives the model nothing to act on. "Cut it to 50 words and add the price" does.
A product description refined over three rounds of follow-ups.
For big jobs, split the work into a chain of smaller prompts, one step each. This is called prompt chaining, and it makes each step easier to check.
Practice: Choose the best follow-up
Pick the follow-up message that will fix the draft.
What is an AI agent?
An AI agent is a model that can take actions, not just write text. It works towards a goal using tools such as web search, a calendar or a code editor.
Agents run in a loop: think about the next step, act with a tool, then observe the result. This loop, often called ReAct (reason and act), repeats until the goal is met.
The think, act, observe loop, with an agent booking a gym class lap by lap.
Practice: Order the agent's steps
Put an agent's steps in order, from reading the goal to reporting back.
How tools work
Each tool has a name, a description and the inputs it needs. The model reads the descriptions to choose the right tool for the next step.
The model does not run the tool itself. It asks for a call, and the app runs it and hands back the result.
A tool definition beside a chat where the model asks for it and the app runs it.
Clear tool descriptions matter as much as clear prompts.Many apps plug tools in through the Model Context Protocol (MCP), a common standard for connecting AI to tools and data.
Practice: Match the tool
Match each request to the tool an agent would call.
Briefing an agent
An agent prompt is a brief, not a question. Give the goal, the context, the limits, and how to tell when the job is done.
Two habits make agents more reliable. Ask for a plan before work starts, and ask the agent to check its own work against the goal before it stops.
Many coding agents also read a standing instructions file kept in the project, such as AGENTS.md. Rules that apply to every task belong there.
A coding agent's brief, each part lighting up with why it is there, beside its project files.
Keeping agents safe
Agents read text from web pages, emails and files. Some of that text may hide instructions meant to hijack the agent, a trick called prompt injection.
So give an agent only the tools it needs. Let it read and search freely, but make it ask you before anything that is hard to undo.
Sort an agent's actions into ones it can just do and ones that need your say-so.
Multi-agent workflows
A multi-agent workflow splits a big job across several agents. An orchestrator agent plans the work and hands each part to a subagent.
Each subagent gets a short brief and its own tools, and works in its own context window. It sends back a short summary, so the orchestrator stays focused.
An orchestrator splits a trip plan between three subagents and gathers their summaries.
Agents can also form a pipeline, each handing its output to the next. Either way, clear handoffs matter most: say exactly what each agent receives and returns.
Practice: Pick the pattern
Choose the simplest pattern that fits each job, from one prompt to a team of agents.