Course

Prompt engineering from the ground up

Instructions that survive contact with users

  • Beginner
  • 10 chapters
  • 150 min read

How to write prompts that behave the same way twice: the four parts every prompt needs, constraints a program can check, few-shot examples that do not leak or unbalance, structured output with a retry path, decomposition in code, the system/user hierarchy, and defences against prompt injection.

What You'll Learn

  • Write a prompt as instruction, context, input and output contract
  • Turn vague requirements into checkable constraints
  • Choose and balance few-shot examples, and avoid leakage
  • Validate structured output and retry with the actual error
  • Decide when reasoning steps help and when to decompose in code
  • Keep instructions and data in separate message channels
  • Recognise direct and indirect prompt injection, and bound the damage
  • Run a prompt harness that compares variants and gates a release

Prerequisites

  • No programming experience needed beyond reading short Python
  • The Evaluation course is a good follow-on, not a prerequisite
  • No API key is required — every example runs on plain Python

Vocabulary

The terms the chapters assume, in plain words.

constraint
A limit on the answer that a program can check, such as a length, an allowed label or a required citation.
context
The background material the model needs to answer well, kept separate from the thing it must act on.
continuation
The text a model writes next, given everything that came before it.
delimited block
Text wrapped by matching markers, such as triple backticks, so its edges are unmistakable.
distribution
The pattern of how often each possible value appears, or how likely each one is.
few-shot example
A worked input and answer pair placed in the prompt so the model can copy the pattern.
instruction
The sentence that names the task, usually starting with a verb.
JSON
A text format for structured data built from names, values, lists and nested braces.
model
The trained program that reads text and predicts what comes next.
output contract
The part of a prompt that states the shape of a valid answer, in words a checker can enforce.
parser
The code that turns the model's text into a value your program can use.
prompt
Everything sent to the model in one request: instructions, background, the input and the answer's required shape.
prompt injection
Text that tries to give the model orders, either typed by a user or hidden inside a document it reads.
register
The level of formality and the kind of wording suited to a particular audience or setting.
schema
A named set of fields with their types and allowed values, used to check an answer's shape.
system message
The opening instruction the model treats as standing policy for the whole exchange.
temperature
A setting that controls how much randomness the model adds when choosing each token.
token
A chunk of text — often part of a word — that the model reads and bills for.
user message
A turn written by the person using the app, treated as data rather than standing policy.

Course Content

  1. 01
    What a prompt is

    Four parts, not one blob: the instruction, the context, the input and the output contract. Most bad prompts are missing one of them.

    Beginner · 13 min read

    Not started
  2. 02
    Specificity and constraints

    A model cannot infer a limit you did not state. Every constraint you add is one fewer dimension the answer can drift in — as long as the constraint is checkable.

    Beginner · 14 min read

    Not started
  3. 03
    Few-shot examples

    An example teaches a pattern faster than a paragraph of instructions. The risks are the ones a teacher would recognise: the wrong examples, too few of a class, and giving away the answer.

    Beginner · 14 min read

    Not started
  4. 04
    Structured output

    A schema turns a reply into a value. The prompt promises the shape, the validator enforces it, and the retry tells the model exactly what it broke.

    Intermediate · 15 min read

    Not started
  5. 05
    Reasoning and decomposition

    Asking for the steps helps on multi-step problems and hurts on simple ones. The reliable version is to decompose the task in code, not to hope the model narrates.

    Intermediate · 15 min read

    Not started
  6. 06
    Roles and system prompts

    The system message is the rule; the user message is the data. The moment they share a string, the data can rewrite the rule.

    Intermediate · 14 min read

    Not started
  7. 07
    Prompt injection

    Any text that reaches the model can try to give it orders. Wording helps; permissions are what actually stop it.

    Advanced · 16 min read

    Not started
  8. 08
    Versioning and review

    A prompt is a decision the product makes on every request, so it needs a history, a reviewer and a way back. Versions stay fixed; labels move.

    Intermediate · 14 min read

    Not started
  9. 09
    Prompts across models

    A prompt tuned on one model is a draft, not a portable asset. Porting it is a measurement exercise: find what the new model lacks, adapt the smallest part, and re-test.

    Advanced · 15 min read

    Not started
  10. 10
    Capstone: a prompt harness

    Three prompt variants, one set of cases, and a table that says which one to ship. The whole course, applied to the decision people actually argue about.

    Advanced · 20 min read

    Not started