Prompt engineering
Writing clear, testable instructions for models and checking them on real inputs.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkOn this page
Overview
Prompt engineering is the practice of writing instructions that get a model to do a specific job reliably. Good prompts state the task, the audience, the constraints and the output format, and give an example when the format matters. The skill is less about magic phrases and more about being explicit: the model only knows what you tell it.
The second half of the skill is testing. A prompt that works once may fail on the next input, so practitioners keep a handful of representative inputs, run the prompt against all of them after each change, and compare the results side by side before deciding a change is an improvement.
What you will practise
- State task, audience, constraints and output format in one clear prompt
- Use a few varied examples when the format is hard to describe
- Tell the model what to do when information is missing
- Compare prompt versions on the same set of test inputs
Learning paths
- AI for test engineers
An AI course for testers: apply generative AI to everyday test automation, from AI-assisted test design to generating, healing and reviewing Playwright tests.
- AI foundations
A free AI foundations course: the working vocabulary of modern AI, from prompting and structured output to retrieval, MCP, Agent Skills and prompt injection.
- AI for data analysts
An AI course for data analysts: clean spreadsheets, profile data with skills, go from SQL to a dashboard, extract PDF tables and catch invented numbers.
- AI for marketers
An AI course for marketers: prompts you can reuse, research and competitor briefs with sources, brand-voice drafts, slides, A/B test reading and AI search.
- AI for non-developers
An AI course for non-developers: use AI assistants for real work without code, from clear requests and checkable research to meeting notes and spreadsheets.
- AI for product managers
An AI course for product managers: prompt for usable drafts, research with sources, write a PRD from evidence, prototype with app builders and read evals.
- Building with the Claude API
Learn to build with the Claude API from your own code: the Messages API, tool use, structured output and prompt caching, then evaluate and trace what you built.
- Prompt and context engineering
A prompt and context engineering course: go from single prompts to deciding what a model sees at each step, from instructions and examples to files and tools.
Tutorials
- Make and edit images with AI for work
AI image generation for work, without code: write a brief, generate drafts, edit one region, keep a set consistent, then check rights, disclosure and alt text.
- Optimise a prompt automatically with DSPy
Write a signature and a metric, run three optimisers on 30 labelled examples, score 20 held-out ones, and see when hand-tuning wins.
- Prompting reasoning models
What changes when a model thinks before it answers: write goals instead of steps, choose an effort level, use fewer examples and check the answer properly.
- AI at work: a practical start for non-developers
Pick the tasks an assistant does well, write instructions you can reuse, work with your own files and check every answer before you use it.
- Context engineering techniques: what the model should see
What to put in a model's context at each step, what to leave out, and how instruction files, retrieval and tools fit.
- Prompting fundamentals: clear tasks, examples and formats
How to write a good prompt: frame the task, say who the output is for, show an example and specify the format, so a model's answers are useful and repeatable.
- Get reliable JSON from an LLM with structured outputs
Describe the output as a schema, let the provider enforce it, validate it with Pydantic AI or the AI SDK, and handle failures.
- Getting started with AI test case design
Use a language model to draft test cases for a feature, prompt it for coverage rather than happy paths, and review its ideas like a tester before you automate.
Workflow recipes
- Translate app strings with AI and keep them consistent
A glossary per language, protected placeholders, plural and length checks in code, then human review.
- Build a no-code AI inbox triage
An AI step labels each email and drafts replies, and a person approves every message before anything is sent.
- Prototype an internal tool with an app builder
Build an internal tool prototype with AI with v0, Lovable or Bolt in an afternoon, test it with real users, and list what must change before it meets real data.
- Write release notes from git history
Turn merged pull requests into notes users can read, with every line checked against the diff before publishing.
- From business question to SQL dashboard with AI
The assistant writes the SQL, you define the metrics and check every number before anyone acts.
- Draft a weekly status update from your tools
Draft an AI weekly status report from merged work, tickets and notes in your team's format, with a source for every claim and the judgement calls left to you.
- Turn meeting recordings into decisions and actions
Turn a meeting recording into AI meeting notes listing decisions, owners and dates, each tied to a quote from the transcript so attendees can check every line.
Articles
- Why AI hallucinates, and how to reduce it
AI hallucinations are fluent answers that are false. Why language models produce them, which ones you can prevent, and a checklist for work you depend on.
- Prompt patterns cheat sheet
Copyable prompt patterns for Claude, ChatGPT and Gemini: briefing, examples, output formats, long documents, checking the work and avoiding made-up answers.
- What is context engineering?
Context engineering is deciding what a model sees at each step. Why the term replaced prompt engineering for people building agents, and what the work involves.
Tools for this skill
ChatGPT
OpenAI's assistant with files, web search, agents and custom GPTs.
Claude
Anthropic's assistant with projects, files, skills and connectors.
DSPy
Write LLM programs as declarative modules and let optimisers tune the prompts.
Gemini
Google's assistant, integrated with Gmail, Docs, Drive and other Workspace apps.
LLM
CLI and Python library for prompting many models.
Outlines
Python library for structured LLM outputs via constrained decoding.
Key terms
Words you will meet while learning this, defined in the glossary.
- Chain-of-thought
Having a model work through intermediate reasoning steps before it gives a final answer, either by prompting or by training.
- Extended thinking
A model setting that gives it a budget of reasoning tokens to use before writing its final answer, trading time and cost for accuracy.
- Few-shot prompting
Including a few input and output examples in the prompt so the model can copy their pattern, format and level of detail.
- Prompt
The input given to a model: instructions, context, examples and the question or task itself, sent as one or more messages in a request.
- Prompt chaining
Splitting a task into a fixed sequence of model calls where each call works on the output of the previous one, with checks in between.
- Prompt engineering
Designing, testing and refining prompts so a model produces the output you need reliably, across many inputs and not just one.
- Prompt template
A prompt with placeholders, such as {question} or {context}, that code fills in at run time so the instructions are reused.
- Reasoning model
A model trained to spend extra tokens thinking through a problem before it answers, trading speed and cost for accuracy on hard tasks.
- Role prompting
Telling a model to take on a role, such as a security reviewer or a patient tutor, to shape its focus, tone and level of detail.
- Self-consistency
Sampling several reasoning paths for the same question and taking the most common final answer, instead of trusting a single response.
- Stop sequence
A string sent with a request that makes the model stop generating as soon as it produces that text.
- System prompt
Instructions set by the application developer that frame every conversation, such as the assistant's role, rules and output format.
- Temperature
A sampling setting that controls randomness: lower values favour the most likely tokens, higher values spread probability more evenly.
- Top-p
A sampling setting that restricts the model to the smallest set of likely tokens whose probabilities add up to p, then samples from that set.
- Zero-shot prompting
Asking a model to perform a task from instructions alone, without giving it any worked examples of the inputs and outputs.