Skip to main content

Module 1 — Anatomy of an effective prompt

A large language model does not read a request the way a human colleague does. It has no memory of your project, no idea what "the usual format" means, and no way to ask a clarifying question. Everything the model uses to answer must be inside the prompt. This module opens the four compartments that a prompt is really made of, then shows the running case study failing without them.

Four elements, in this order

Every prompt that works, whatever its length, contains the same four elements. The order below matches how the model weighs them.

ElementQuestion it answersFailure symptom when missing
Taskwhat to producemodel writes a summary instead of the requested fields
Contextwhat the model needs to knowinvented product names, fabricated facts
Constraintswhat is forbidden or requiredinvented headers, extra commentary, wrong length
Formathow the answer must lookfree-form prose when JSON was expected

The order matters because a model that has understood only the first two produces a plausible-looking answer that is still unusable. The last two are what turns "readable" into "parseable by the next step".

The naive version of our running case

The whole course rewrites one single prompt. Here it is at the start, written the way most people first try:

from openai import OpenAI

client = OpenAI()
email = """Subject: Order 4728 broken headphones
Hi, my QuietPro X3 headphones stopped charging on the right side
after ten days. I fly Wednesday and need them for the trip.
Replace or refund please. Sarah"""

response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Extract information from this email: " + email}],
)
print(response.choices[0].message.content)

On this single example the model probably answers something sensible. Run it on twenty emails and the trouble starts: some answers are paragraphs, some are bullet lists, some quote the email back at you, one invents a customer name that never appeared. Nothing failed loudly — it failed differently every time, which is worse.

What the model ignores

A frequent illusion is that the model reads the prompt "carefully". It does not. Three categories of content are largely ignored:

  • Politeness and filler. "Please", "thanks in advance", "if you don't mind" cost tokens and change nothing measurable.
  • Adjectives without a scale. "Concise", "professional", "clear" are interpreted differently on every call. Module 6 replaces them with counted constraints.
  • Meta-commentary about the prompt itself. "This is a hard task", "be careful with edge cases", "do your best" do not improve outputs and sometimes trigger the model into producing the very disclaimers you were trying to avoid.

What the model does read closely is verbs, nouns, and any example you provide. Module 3 exploits the third point in detail.

Longer is not clearer

Adding paragraphs of explanation to a failing prompt is the most common overreaction. The model then has to weigh contradictory instructions against each other, and picks whichever came last more often than not. Before adding a sentence, delete one that says the same thing with different words.

Diagnosing a failing prompt

When an output disappoints, resist the reflex of rewriting from scratch. Diagnose which of the four compartments is empty. A short protocol:

  1. Read the answer next to the prompt with a single question: which element could I add so that this specific failure becomes impossible?
  2. If several elements are missing, add them one at a time and re-run on the same input. A single change explains a single variation.
  3. Test on five varied inputs, not one. A prompt that works on the example you had in mind is only proof that the example was easy.

Applied to the naive version above, the diagnosis is straightforward: the task is under-specified ("extract information"), the context is absent (what fields, in what unit of urgency), the constraints are missing (no invention, no commentary), and the format is left to the model's imagination.

A better first draft

Rewriting with the four elements in mind produces something like this:

prompt = """Task: extract four fields from the customer complaint email below.
Context: the email is from a support inbox. The customer describes a problem
with a physical product they purchased from us.
Constraints: use only information present in the email. If a field is not
mentioned, write "not stated". Do not add commentary.
Format: four labelled lines, one per field, in this order:
reason, product, urgency, requested_action.

Email:
""" + email

response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": prompt}],
)

The output is now stable across inputs, and any deviation is a real model error rather than a prompt ambiguity. Modules 2 to 6 refine each of the four compartments in turn.

In summary

  • A prompt has four compartments — task, context, constraints, format — and every failing prompt has at least one of them empty.
  • The model ignores politeness, vague adjectives and meta-commentary; it weighs verbs, nouns and examples heavily.
  • Diagnose a failure by naming the missing compartment, add elements one at a time, and test on at least five varied inputs, not one.
  • The naive version of the running case fails differently every time; the rewritten one produces stable, comparable outputs that later modules can then improve.

Next module: the system prompt, where we put the durable framing that should not depend on which email comes in.