AI & MLQuick
Beginner

Prompt Engineering

10 min read

Learn
Quick Reading
Estimated 10 mins
Prereq
Foundational
No experience required
Interactive
Static Playbook
Static guide & reference tables

Why prompting actually matters

The same model with different prompts can produce responses that range from useless to genuinely impressive. Prompt engineering is the practice of structuring your inputs to reliably get the outputs you need.

This isn't a soft skill. It's a technical discipline with measurable effects on accuracy, consistency, and cost. The difference between a poorly prompted and well-prompted system is often the difference between a demo and a production-ready product.

System prompts

The system prompt is the instruction layer that runs before every conversation. It defines the model's persona, constraints, output format, and context.

A weak system prompt: You are a helpful assistant.

A strong system prompt:

You are a support agent for Acme SaaS. You help users troubleshoot
billing issues and account settings.

Rules:
- Only answer questions about billing and account settings
- If asked about anything else, say "That's outside my area —
contact support@acme.com"
- Always respond in under 100 words
- Format steps as a numbered list
- Never promise refunds without escalating to a human

Context: Today's date is {date}. User plan: {plan_type}.


The system prompt is where you invest most of your prompting effort. It's the configuration layer of your AI product.

Chain-of-thought prompting

For complex reasoning tasks, telling the model to "think step by step" before answering dramatically improves accuracy.

Without CoT: Is 17 a prime number? Answer: Yes.

With CoT:

Is 17 a prime number? Think step by step.
Answer: 17 divided by 2 is 8.5 — not integer. By 3 is 5.67 — not integer.
By 5 is 3.4 — not integer. By 7 is 2.43 — not integer.
Since we've checked all primes up to √17 ≈ 4.1, 17 has no factors.
Yes, 17 is prime.


The intermediate reasoning steps catch errors before they become final answers. Accuracy improvements of 20–40% on math and logic tasks are well-documented.

When to use it: multi-step problems, math, code reasoning, logical deductions. Not needed for simple factual queries.

Few-shot prompting

Show the model examples of the pattern you want before asking it to do the task.

Zero-shot: Classify this review as positive or negative: 'The battery life is terrible.'

Few-shot:

Review: "Fast shipping, exactly what I ordered." → Positive
Review: "Broke after one week. Waste of money." → Negative
Review: "Works as described but instructions unclear." → Mixed
Review: "The battery life is terrible." → ?


The examples calibrate the model's output format, tone, and classification scheme. Especially powerful when your categories are non-standard or your output format is specific.

Rule of thumb: 3–5 examples is usually enough. More than 10 rarely helps and increases cost.

Output formatting

Specifying your output format in the prompt eliminates post-processing work.

Respond as valid JSON with keys: sentiment (positive/negative/mixed), confidence (0-1), reason (one sentence).


Respond in this exact format:
SUMMARY: [one sentence]
ACTION ITEMS:
- [item 1]
- [item 2]
PRIORITY: [high/medium/low]


For structured outputs in production, use JSON mode (OpenAI) or tool calling with a schema — these guarantee valid JSON rather than hoping the model follows instructions.

Techniques that work in practice

Persona assignment: "You are a senior security engineer reviewing code for vulnerabilities." The persona primes the model's tone and knowledge domain.

Negative instructions: "Do not include preamble. Do not apologize. Do not say 'As an AI...'" Explicitly telling the model what not to do is often more effective than only specifying what to do.

Delimiters: use XML tags or markdown to separate sections. <document>, <instructions>, <examples>. Helps the model parse complex prompts correctly.

Ask for confidence: "After your answer, state your confidence from 0-10 and explain why." Models that express uncertainty are more trustworthy than ones that always sound sure.

Iterative refinement: prompt → get output → identify failure mode → fix prompt → repeat. Most production prompts went through 20+ iterations.

Prompting is not a substitute for architecture

You can't prompt your way to a reliable AI product. If your system is fundamentally unreliable, better prompts reduce the failure rate but don't eliminate it. Build evaluation sets. Measure failure rates. Know when the problem requires fine-tuning, RAG, or tool use instead of a more elaborate prompt.

I build these systems professionally.

Whether it's a RAG pipeline, analytics migration, or AI workflow — let's talk.

Need custom AI or MarTech setup? Let's build together.