LearnAIAI Builder deep dives ← Roadmap

Station 4 · Prompting

Prompt engineering

The single highest-leverage skill for a builder. You already know the AI is just predicting the next chunk of text — prompting is how you aim that prediction. Same engine, wildly different results, depending on what you feed it.

4 of 9 · ~9 min

What you'll walk away with

Concept 1

Why prompting works at all

Back in Station 1 you learned the core idea: an LLM reads the text so far and predicts the most likely text to come next. Hold onto that — it's the entire reason prompting is a thing.

Your prompt is the "text so far." When the model looks at it and asks "what would most likely come next?", everything you wrote is steering that guess. A vague, sloppy prompt looks — statistically — like the start of a vague, sloppy answer. A precise, well-framed prompt looks like the start of a precise, well-framed one. You're not begging the AI to try harder. You're changing the road it predicts down.

🔑 The core idea

You can't reach into the model and make it smarter. But you can rewrite the text it's continuing. Prompt engineering is just: carefully crafting the input so the most-likely continuation is the answer you actually want.

🧑‍💼 Analogy: briefing a brand-new intern

Imagine a sharp but brand-new intern on day one. Say "handle this" and you'll get something — probably not what you pictured. Say "Write a 3-sentence reply to this customer, apologize for the delay, offer a 10% coupon, keep it warm," and you'll get exactly what you need. The intern didn't get smarter between those two requests. Your instructions did. The AI is that intern: eager, capable, and completely dependent on how well you brief it.

Concept 2

Anatomy of a strong prompt

Most great prompts quietly contain the same five ingredients. You don't always need all five, but knowing them turns "why is this answer bad?" into a checklist you can fix.

1 · Role

Who should the AI be?

"You are a patient middle-school math tutor." Setting a role pulls the prediction toward how that kind of person writes.

2 · Task

What exactly to do?

The one clear action: "Explain why the answer is 12." Not "help with math" — that's a topic, not a task.

3 · Context

What does it need to know?

Background, the student's grade, the actual problem, past attempts. The facts the answer must be built on.

4 · Format

How should output look?

"Give 3 bullet points, then one encouraging sentence." Shape the output or you'll get a shapeless wall of text.

5 · Constraints

What are the rules?

Length, tone, what to avoid: "Under 80 words. Never give the final answer outright. No jargon."

Put together

Role + Task + Context + Format + Constraints

Stack them and a fuzzy request becomes a tight brief the model can't misread.

Weak vs. strong: the same question, two worlds

Watch what happens to the exact same underlying request when you go from a one-liner to a fully-briefed prompt.

Vague

What you might type first

"Help me write an email to my teacher about a late assignment."

No role, no tone, no length, no details. The model has to guess all of it — and its guess is generic, maybe too formal, maybe too long.

Specific

What gets a usable draft

"You are helping a high school student. Write a short, respectful email to my history teacher, Mr. Lee. Context: I missed the essay deadline because I was sick 2 days. Ask for a 3-day extension. Format: greeting, 3 sentences, sign-off. Polite, not groveling."

Same goal. The second one has all five ingredients, and the answer barely needs editing. That's the whole game.

strong-prompt.txt
# ROLE
You are a patient middle-school math tutor.

# TASK
Help the student understand why the answer is 12 —
# guide them, don't just announce it.

# CONTEXT
Problem: "A pack has 3 rows of 4 stickers. How many stickers?"
Student guessed 7 (they added instead of multiplied).

# FORMAT
1) One friendly sentence naming what they did well.
2) One question that nudges them toward multiplying.
3) The rule in one line.

# CONSTRAINTS
Under 70 words. Warm tone. Never state "12" outright.
why it worksEvery ingredient narrows the field of "likely next text." The model isn't guessing your intent anymore — you handed it to them.

Concept 3

Zero-shot vs. few-shot

Sometimes you just ask. Sometimes you show. Knowing which is a superpower.

Zero-shot means you ask with zero examples — "Classify this message as Happy or Sad." Often that's plenty. But when you have a specific style, format, or judgment call in mind, words alone can be slippery. That's where few-shot comes in: you paste a few solved examples first, then give the real one. Because the model predicts the next chunk of text, those examples set the pattern it continues.

few-shot-classify.txt
# Show the pattern with 2 labeled examples first:
Message: "I got the lead in the play!!"   → Happy
Message: "My best friend is moving away."  → Sad

# Now the real one — the model continues the pattern:
Message: "We lost the game but I played my best."  → ?
what the model doesHaving seen the "Message → label" shape twice, its most-likely next text is a matching label — here, a nuanced "Happy" (pride) rather than "Sad." The examples taught it your rubric without a single rule written out.

Few-shot is how builders lock in consistency: give 2–5 examples of exactly the input-output pairing you want, and the model mirrors it. It's teaching by demonstration instead of description — often faster and more reliable than trying to explain every edge case in words.

Concept 4

Chain-of-thought: make it show its work

Here's a trick that feels like cheating. For anything with multiple steps — math, logic, planning — telling the model to "think step by step" makes it dramatically more accurate.

Why? Remember the engine. If the model tries to blurt the final answer immediately, it's predicting one lucky chunk of text with no scratch paper. But if it writes out its reasoning, each step becomes part of the "text so far" — so the next step is predicted on top of the work it already did. It's the difference between shouting an answer and actually working the problem out.

No reasoning

Blurts an answer

"A shirt is $40, marked down 25%, then $5 shipping is added. Final price?"

Rushed, it might jump to a wrong number — say "$28" — because it skipped the middle steps.

Chain-of-thought

Works it out

"…Solve it step by step, then give the final price."

"25% of $40 is $10. $40 − $10 = $30. Add $5 shipping = $35." Each step props up the next.

🔑 Remember this phrase

Adding "Let's think step by step" (or "show your reasoning before the final answer") to a tricky prompt is one of the cheapest accuracy upgrades in all of AI building. Reach for it any time the task has more than one moving part.

Concept 5

Prompting is a conversation, not a coin flip

The biggest myth is that a prompt either "works" or it doesn't. In reality, good prompting is iterative — you write, you read what came back, and you refine.

Treat the first answer as a draft, not a verdict. Did it go too long? Add a length constraint. Wrong tone? Name the tone. Missed a fact? Add context. Each round you're nudging the input closer to the output you want — exactly like giving that intern quick feedback until the work lands. Builders who get great results aren't writing perfect prompts on the first try; they're iterating faster.

The three mistakes that wreck most prompts

⚠️ Builder's reality check

A better prompt steers the prediction — it doesn't guarantee truth. From Station 1: the model outputs likely text, not verified text. Great prompting makes answers sharper and better-shaped, but you still verify facts. Prompting improves the aim, not the honesty.

Checkpoint

Your prompt "Summarize this article" keeps returning summaries that are way too long and formal for a casual newsletter. What's the best fix?

Send the exact same prompt again and hope for a shorter result. Add Format + Constraints: "In 3 casual bullet points, under 60 words total, friendly tone." Give up — the model just can't write short summaries.

The model was doing exactly what a bare "summarize this" predicts: a generic, thorough summary. It's not broken — it's under-briefed. Adding a format (3 bullets), a length constraint (under 60 words), and a tone (casual, friendly) reshapes the most-likely output. This is the iteration mindset in one move: read what came back, then add the missing ingredient.

Try it yourself — 15 minutes, no code

Rescue a weak prompt with all five ingredients

Open any free chatbot (ChatGPT, Claude, or Gemini) and run this side-by-side experiment:

  1. Round 1 — the weak prompt. Type just: "Give me ideas for my science project." Read the answer. Notice how generic it is — it had to guess your grade, subject, and interests.
  2. Round 2 — rebuild it. In a fresh chat, layer in all five ingredients. Role: "You are a 9th-grade science teacher." Task: "Suggest project ideas." Context: "I like environmental science and have 2 weeks and a $20 budget." Format: "Give exactly 5 ideas as a numbered list, each with one sentence on what I'd test." Constraints: "Nothing requiring lab equipment."
  3. Compare. Put the two answers next to each other. Which one could you actually use today?
  4. Iterate once. Pick your favorite idea and ask a follow-up that adds a new constraint or format — feel how each round tightens the result.

Keep: save your Round 2 prompt as a template. Swapping the Context line reuses it for any subject — that's a builder's reusable asset.


Recap. Prompting works because your prompt is the "text so far" that steers the model's next-word prediction — you can't make it smarter, but you can aim it. Strong prompts carry five ingredients: Role, Task, Context, Format, Constraints. Show examples (few-shot) when a pattern beats a description, and say "think step by step" (chain-of-thought) when the task has multiple parts. Above all, treat prompting as a conversation — read the answer, add the missing ingredient, repeat. It's the same engine from Station 1; you're just getting better at driving it.