Prompt Engineering That Actually Works

Learn the prompt patterns that help more often than they hurt, and how to tell when the output still needs checking.

Prompting Is Communication, Not Magic

Plenty of people sell "magic prompts" and secret techniques for getting better AI output. Most of it is noise. The techniques that reliably produce better results from LLMs are based on understanding what the model is doing - predicting the most likely continuation of your text - and structuring your input to make the desired continuation the most likely one.

Prompting is structured communication with a probabilistic system. It is more like writing a clear brief for a contractor than casting a spell.

The Core Principle: Remove Ambiguity

Every word in your prompt shifts the probability distribution over possible outputs. Vague prompts produce average outputs - the model generates whatever is statistically most typical for that kind of request. Specific prompts produce more targeted outputs - you have narrowed the space of likely continuations to the ones you want.

The principle: tell the model exactly what you want, who you are, what format the output should take, and what constraints apply. Leave nothing important implicit.

Vague prompt: "Summarize this article." Produces: a generic summary in whatever format the model defaults to.

Specific prompt: "Summarize the following article in three bullet points for a non-technical executive. Focus on business implications, not technical details. Each bullet should be one sentence." Produces: exactly what you described, because you made the desired output the most predictable continuation.

The Anatomy of a Good Prompt

1. Role / Context Tell the model what it is doing and for whom. "You are a legal research assistant helping a lawyer prepare a client memo." This shifts the model's predictions toward legal-language patterns and professional communication norms.

2. Task Definition State clearly what you want the model to do. "Summarize the key legal issues in the following contract clause." Do not assume the model will infer your task from context.

3. Format Specification Describe the output format you need. "Return your answer as a bulleted list with no more than five items." "Respond in plain English suitable for a non-lawyer." "Return JSON with fields: summary, risk_level, recommended_action."

4. Constraints State what the model should not do. "Do not include personal opinions." "Do not include information not present in the document." "Do not use legal jargon."

5. Input The content the model should work with, clearly separated from the instructions.

Example combining all five:

You are a customer support specialist for a software company.

Your task: respond to the customer message below in a professional, empathetic tone.

Format: 2-3 sentences maximum. Acknowledge the issue, provide one actionable next step, and offer to escalate if needed.

Constraints: Do not make promises about timelines you cannot guarantee. Do not use technical jargon.

Customer message: [paste message here]

Few-Shot Examples: Show, Don't Just Tell

For tasks where the format or tone is hard to describe precisely, showing the model an example is more effective than describing it.

Classify each customer message as: Billing, Technical, Feature Request, or Other.

Examples:
Message: "I was charged twice this month."
Category: Billing

Message: "The app crashes when I upload a PDF."
Category: Technical

Message: "It would be great if you could add dark mode."
Category: Feature Request

Now classify this message:
Message: "My invoice shows a charge I don't recognize."
Category:

The model now has a concrete pattern to complete. It will almost always produce "Billing" - because that is the most statistically likely continuation of this pattern.

Chain-of-Thought: For Complex Reasoning Tasks

For tasks requiring multi-step reasoning - analysis, diagnosis, planning - asking the model to "think step by step" before producing its answer significantly improves accuracy.

Analyze whether the following business decision makes sense.
Think through the pros and cons step by step before reaching your conclusion.
Clearly label your final recommendation at the end.

Decision: [description]

This works because the intermediate reasoning the model generates becomes part of the context that influences the final output - better intermediate reasoning leads to better conclusions.

The Iteration Loop

A prompt is not a one-time creation - it is a hypothesis to be tested and refined. The process:

  1. Write a prompt that you believe should work
  2. Test it on 5-10 representative inputs
  3. Examine the failures - what went wrong?
  4. Add constraints, examples, or clarifications to address the failures
  5. Re-test

Most prompts take 3-5 iterations to produce reliable results. The prompts worth keeping are the ones that have been tested and hardened.

When Prompting Is the Wrong Tool

Prompting has limits. Recognizing them saves time:

  • If the model consistently gets something wrong, no amount of prompting will fix a systematic knowledge gap. The model does not know what it does not know.
  • If you need verified facts, prompting a model is not research. It is generating plausible text. Use primary sources.
  • If the task requires real-time information, the model's training data has a cutoff. It does not know about events after that cutoff unless you provide them.
  • If consistency across many runs is critical, the probabilistic nature of LLMs means variation is inevitable. For high-stakes outputs, build in verification steps.

Where to Go Next

The next module covers the skill that underpins good prompting: knowing when to trust the output you received. Prompting gets you better outputs; evaluating those outputs tells you whether to use them.

Module 6 of 25 · Curious to AI-Fluent

Related Posts

More posts

AI Agents: What They Are, What They Can Do, and How They Go Wrong

An agent is an AI that takes actions, not just answers questions. That changes what safe use looks like. Learn in plain English what agents are, how they connect to your tools, why they can be tricked by what they read, and the one question to ask before letting one act for you.

#ai-literacy#agents#prompt-injection#mcp#llm