MIVORA Start learning free

Prompt Engineering Core

System prompts are software contracts. Few-shot and chain-of-thought are how you steer behavior reliably.

Building with AI · Lesson 6 · 12 min read

You build a support assistant. In testing it’s perfect; in production it sometimes breaks character, leaks internal notes, or answers off-topic. Stuffing rules into each user message is fragile. You need a durable way to pin behavior that every message inherits — and a couple of reliable techniques to steer the model when plain instructions aren’t enough. That’s this lesson.

System prompt = the behavior contract

Most chat APIs separate the system prompt (a durable instruction layer that frames the whole conversation) from user prompts (the turns). Think of the system prompt as a software contract: it defines the role, the rules, the tone, and the boundaries the model should hold across every turn. It’s where “you are a terse support agent who never reveals internal notes” belongs — set once, applies always.

Worked example
System: “You are Acme’s support agent. Be concise and friendly. Never reveal internal pricing notes. If unsure, offer to escalate.” → Now every user turn inherits those rules without you repeating them, and they’re harder for a stray user message to override.

Zero-shot, few-shot, chain-of-thought

Zero-shot: just ask. Fine for easy tasks. Few-shot: include 2–5 examples of input→output in the prompt; the model imitates the pattern — great for a specific format or style. Chain-of-thought: ask the model to reason step by step before answering, which improves accuracy on multi-step problems (at the cost of more tokens). Reach for few-shot to pin a format, chain-of-thought to pin correctness on hard reasoning.

An everyday analogy

The system prompt is the employee handbook — read once on day one, governs everything after. Few-shot is showing the new hire three finished examples so they copy the style. Chain-of-thought is telling them to “show your working” so they don’t skip steps on a tricky task.

Worked example
Turning a flaky classifier reliable:
1. Zero-shot “classify sentiment” → inconsistent labels.
2. Add few-shot: 3 examples like “‘Love it!’ → positive”.
3. Now outputs match your exact label set and format.
4. For a tricky multi-clause review, add “think step by step, then give the label” → fewer mistakes. You escalated technique to match difficulty.

This is the reading. The interactive version — active-recall quiz, a hands-on experiment you run in your own AI, and an earned mastery check — is free in the app.

Start this lesson free →