Most guides on prompt engineering throw a list of terms at you: zero-shot, few-shot, chain-of-thought, persona. Each one comes with its own unrelated example, making it hard to see how they connect or when to combine them.
In this post, we do it differently. We take one simple prompt and upgrade it step by step. Each technique builds on the previous one, so you can see exactly what changes and why it helps.
Our running task
Imagine you run a small online store. You want an AI to read customer messages and tell you how the customer feels, so you can decide what to do next.
Here is the customer message we will use throughout:
"My order arrived two days late and the box was damaged, but the support agent who helped me was wonderful."
This message is deliberately tricky: it mixes complaints and praise in the same sentence. That makes it a great stress test for each technique.
1. Zero-shot prompting
What it is: You ask the model to do a task with no examples, just a plain instruction. The model relies entirely on what it already knows.
Prompt:
Classify the sentiment of this customer message. Message: "My order arrived two days late and the box was damaged, but the support agent who helped me was wonderful." Possible output:
Mixed When it works well: Simple, common tasks such as summarizing, translating, or basic classification.
The weakness: The model decides the answer format and labels on its own. Today it might say "Mixed", tomorrow "Neutral", and the next day write a full paragraph. You have no control over consistency.
2. One-shot and few-shot prompting
What it is: You include one example (one-shot) or several examples (few-shot) of the task done right. The model learns the pattern by imitation.
Upgraded prompt:
Classify the sentiment of each customer message as Positive, Negative, or Mixed. Message: "Fast delivery and great packaging!" Sentiment: Positive Message: "The item stopped working after one day. Very disappointed." Sentiment: Negative Message: "The product is fine, but shipping took forever." Sentiment: Mixed Message: "My order arrived two days late and the box was damaged, but the support agent who helped me was wonderful." Sentiment: Output:
Mixed What changed: The model now knows the exact labels to use and the exact format to answer in. Showing examples is often faster and clearer than writing long formatting rules.
Tip: Use 2 to 5 varied examples. Cover different edge cases (positive, negative, and mixed) and keep the structure identical every time.
3. Chain-of-thought (CoT) prompting
What it is: You ask the model to reason step by step before giving the final answer. Working through the logic out loud helps the model handle nuance and multi-part decisions.
(To keep the prompt compact while we test reasoning, we will set the examples aside for a moment and add a step-by-step instruction.)
Upgraded prompt:
Classify the sentiment of the customer message below as Positive, Negative, or Mixed. First, think step by step: 1. List what the customer is happy about. 2. List what the customer is unhappy about. 3. Decide which outweighs the other, or whether both matter. Then give the final answer on a new line starting with "Sentiment:". Message: "My order arrived two days late and the box was damaged, but the support agent who helped me was wonderful." Output:
1. Happy about: The support agent was wonderful. 2. Unhappy about: Late delivery (two days) and a damaged box. 3. There are two complaints about the delivery experience and one strong compliment about customer service. Neither cancels the other out. Sentiment: Mixed What changed: You can now see why the model chose its answer, making mistakes easy to spot. For harder problems like math, planning, or policy checks, this significantly improves accuracy. (Note: Newer "reasoning" models do much of this thinking automatically behind the scenes, though explicitly listing steps still lets you control what the model evaluates.)
Bonus - Few-shot CoT: You can combine steps 2 and 3 by providing examples that include the step-by-step reasoning, not just the final label.
4. Persona (role) prompting
What it is: You assign the model a specific role. The persona shapes its vocabulary, priorities, tone, and what details it flags as important.
Upgraded prompt:
You are a senior customer experience analyst at an e-commerce company. You care about spotting issues that could cause customers to leave. Classify the sentiment of the customer message below as Positive, Negative, or Mixed. First, think step by step: 1. List what the customer is happy about. 2. List what the customer is unhappy about. 3. Decide which outweighs the other, or whether both matter. Then give the final answer on a new line starting with "Sentiment:". Message: "My order arrived two days late and the box was damaged, but the support agent who helped me was wonderful." Output:
1. Happy about: High-quality, empathetic support interaction. 2. Unhappy about: Fulfillment delay (two days late) and damaged packaging. 3. While strong support prevented immediate frustration from boiling over, fulfillment failures create high churn risk if left unresolved. Both signals matter. Sentiment: Mixed What changed: Notice how the language shifted from casual summary to business analysis-framing the delivery issue as a churn risk and the support agent as a retention buffer.
Tip: Be specific. "Senior customer experience analyst who cares about churn risk" outperforms a generic "expert." Personas also control tone, such as "explain like a patient teacher" or "respond like a concise editor."
5. Context and constraints prompting
What it is: You give the model background information and strict boundaries. Context explains the situation; constraints define what to do and what to avoid.
Upgraded prompt:
You are a senior customer experience analyst at an e-commerce company. You care about spotting issues that could cause customers to leave. Context: We sell handmade ceramics. Fragile items often break in transit, and we recently switched courier partners. Classify the sentiment of the customer message below as Positive, Negative, or Mixed. First, think step by step: 1. List what the customer is happy about. 2. List what the customer is unhappy about. 3. Decide which outweighs the other, or whether both matter. Then give the final answer on a new line starting with "Sentiment:". Constraints: Keep the reasoning under 60 words. Do not suggest compensation or refunds. Message: "My order arrived two days late and the box was damaged, but the support agent who helped me was wonderful." Output:
1. Happy about: Responsive, helpful support agent. 2. Unhappy about: Two-day delay and a damaged box—a major risk for fragile handmade ceramics following our recent courier switch. 3. Strong support saved the interaction, but transit damage threatens repeat business and must be flagged immediately. Sentiment: Mixed What changed: The model now understands why a damaged box is critical for a ceramics shop and connects it to the new courier. Meanwhile, the constraints keep the output tight and prevent unauthorized refund promises.
6. Output formatting (structured output)
What it is: You require the model to return data in a strict, machine-readable layout such as JSON, CSV, or a Markdown table. This is essential when another program or spreadsheet will process the result.
(Notice how we replace the free-text reasoning lines with JSON fields, turning our chain-of-thought steps into structured data so the output stays valid JSON.)
Upgraded prompt:
You are a senior customer experience analyst at an e-commerce company. You care about spotting issues that could cause customers to leave. Context: We sell handmade ceramics. Fragile items often break in transit, and we recently switched courier partners. Analyze the customer message below. Return ONLY valid JSON matching this exact schema: { "positives": ["..."], "negatives": ["..."], "reasoning": "One brief sentence explaining the overall impact", "sentiment": "Positive | Negative | Mixed", "churn_risk": "Low | Medium | High" } Constraints: Keep "reasoning" under 30 words. Do not suggest compensation or refunds. Message: "My order arrived two days late and the box was damaged, but the support agent who helped me was wonderful." Output:
{ "positives": ["Support agent was wonderful"], "negatives": ["Delivery was two days late", "Box arrived damaged"], "reasoning": "Great support prevented immediate churn, but box damage poses a serious risk for fragile ceramics.", "sentiment": "Mixed", "churn_risk": "Medium" } What changed: The output is now completely predictable and ready for automation. You can pipe this straight into a database, dashboard, or alerting workflow without manual cleanup.
7. Prompt chaining
What it is: Instead of cramming every job into one giant prompt, you break the workflow into smaller, focused prompts where the output of one becomes the input of the next.
For our task:
- Prompt 1 - Analyze: Run the structured JSON prompt from Step 6 to extract the facts and churn risk.
- Prompt 2 - Decide the next step: Feed the JSON output into a second prompt:
Here is an analysis of a customer message: {paste JSON from Prompt 1} Based on this, recommend one customer-facing follow-up action (such as checking if the ceramic item arrived intact or logging courier feedback) in one sentence. Do not offer refunds. - Prompt 3 - Draft the reply: Feed that recommended action into a final prompt:
Write a warm, 3-sentence reply to the customer. Thank them for praising our support agent, apologize for the shipping delay and damaged box, and include this next step: {action from Prompt 2} What changed: Each prompt has a single, clear responsibility. It is easier to test, cheaper to debug, and much more reliable—if the customer reply sounds off, you only need to tweak Prompt 3 without breaking your data extraction in Prompt 1.
Putting it all together
Here is how our single prompt evolved across all seven upgrades:
| Step | Technique | What we added |
|---|---|---|
| 1 | Zero-shot | Just the core instruction |
| 2 | Few-shot | Examples showing exact labels and format |
| 3 | Chain-of-thought | Step-by-step reasoning before the final answer |
| 4 | Persona | A specific role (senior CX analyst) to shape tone and focus |
| 5 | Context & constraints | Business background (ceramics, new courier) and guardrails |
| 6 | Structured output | A strict JSON schema for downstream tools |
| 7 | Prompt chaining | Splitting analysis, decision, and drafting into linked steps |
Quick guide: which technique should I use?
- Simple, common task? Start with zero-shot.
- Inconsistent format or labels? Add few-shot examples.
- Needs logic, math, or weighing trade-offs? Use chain-of-thought.
- Tone, vocabulary, or domain focus feels off? Assign a persona.
- Answers are too generic or break business rules? Add context and constraints.
- Another app or script needs to read the result? Enforce structured output.
- Workflow has multiple distinct stages? Use prompt chaining.
Final thoughts
You do not need all seven techniques in every prompt. Start simple, inspect where the output falls short, and add one upgrade at a time to fix that specific gap. That habit of iterative refinement—not memorizing buzzwords—is the real skill behind prompt engineering.
Try it yourself: Take one prompt you use regularly at work today and upgrade it by just one or two steps from the list above.