Prompting Techniques
A practical guide to every major prompt engineering technique — what it is, why it works, and how to use it.

Every AI agent, no matter how advanced, is built on three core components working together:
- planning, which lets the model break a goal into steps and reason through them;
- tool use, which lets it call external resources like search engines, calculators, or APIs to go beyond its own memory;
- memory, which lets it retain context across a task instead of treating every step as brand new.
These three components determine how well an agent performs—but none of them matter if the instructions feeding them are poorly designed. That's where prompting techniques come in.
A prompt is the steering wheel for all of this machinery, and the difference between a vague prompt and a well-engineered one is often the difference between an agent that fails halfway through a task and one that completes it reliably.
02. Deep Dive into Every Technique:
To make comparisons easy, every technique below is demonstrated on the same running scenario: helping "Sweet Crumbs," a small independent bakery, plan and grow its business — everything from menu decisions to marketing to sales analysis. Seeing how each technique reshapes the same problem makes the differences between them much clearer than switching topics every time.
2.1. Zero-Shot Prompting:
Zero-shot prompting is the simplest and most direct way to interact with an LLM — you give it a task with no examples, no demonstrations, and no extra scaffolding, relying entirely on the knowledge and reasoning ability the model already has from pretraining.
It works because modern LLMs are trained on such a broad range of instruction-style data that they can generalize to new tasks without being shown how.
The upside is speed: no time spent building examples, no extra tokens spent on context. The downside is that it offers the least amount of control — if your task has a specific format, tone, or edge case the model needs to respect, zero-shot is the technique most likely to miss it.
It's the right starting point for straightforward tasks (summarizing, explaining, classifying) and a poor choice for tasks that are ambiguous, highly specialized, or where output format really matters.
Prompt Example:
promptYou are a small-business consultant.
Sweet Crumbs is a new artisan bakery opening in a mid-sized town. It sells sourdough bread, croissants, and custom cakes, and has a modest $2,000 monthly marketing budget. Without any additional examples or guidance, provide a complete first 90-day marketing plan for Sweet Crumbs. Cover: target customer segments, recommended marketing channels (with reasoning for why each fits a bakery on this budget), a rough weekly social media content cadence, and two low-cost promotional ideas to drive foot traffic in the opening week. Write the plan in a clear, actionable format a first-time business owner could follow without needing to ask follow-up questions.
2.2. Few-Shot Prompting:
Few-shot prompting gives the model a small set of worked examples—typically two to five—before asking it to handle a new case.
This is a form of "in-context learning": the model doesn't update its weights, but it uses the examples in the prompt itself as a live reference for structure, tone, level of detail, and even the specific vocabulary you want.
It's most valuable when the output needs to follow a precise, non-obvious pattern that's hard to describe in words alone—think formatting a product description, replicating a brand's voice, or producing consistent JSON.
The tradeoff is prompt length: every example adds tokens and cost, and poorly chosen examples can bias the model toward the wrong pattern, so example quality matters more than example quantity.
Prompt Example:
promptHere are examples of how Sweet Crumbs writes short product descriptions for its online menu: Product: Classic Sourdough Loaf
Description: Slow-fermented for 24 hours, our sourdough has a crisp, crackling crust and an open, tangy crumb. Baked fresh daily — best enjoyed the same day, or toasted the next. Product: Almond Croissant
Description: Buttery, flaky layers wrapped around a rich almond frangipane, finished with a dusting of powdered sugar. A weekend favorite that pairs perfectly with a strong espresso. Now write a product description in the same tone, length, and structure for: Product: Cinnamon Swirl Babka.
2.3. Chain-of-Thought (CoT) Prompting:
Chain-of-Thought prompting asks the model to externalize its reasoning — to work through a problem in explicit, sequential steps before committing to a final answer, rather than jumping straight to a conclusion.
This matters because LLMs generate text token by token; if a model tries to produce a complex answer in one leap, it has no "scratch space" to catch its own mistakes. By forcing intermediate steps, CoT gives the model room to reason correctly and gives you visibility into how it got its answer, which makes errors easier to spot.
It shines on math, multi-variable decisions, and anything involving cause-and-effect logic. It's less useful (and sometimes counterproductive) for simple factual lookups, and for modern "reasoning" models that already perform this step internally; over-instructing them to "think step by step" can occasionally add noise rather than help.
Prompt Example:
promptSweet Crumbs is deciding whether to open a second location.
Current numbers: the original bakery earns $45,000/month in revenue with a 22% profit margin. A second location would cost $80,000 to build out, plus $6,000/month in additional rent and staff. The owner estimates the second location would generate about 70% of the original store's revenue in its first year. Work through this step by step: Step 1: Calculate the projected monthly revenue and profit for the second location in year one. Step 2: Calculate how many months it would take for the second location's profit to cover the $80,000 build-out cost. Step 3: Weigh the payback period against common small-business risk tolerance (generally under 24 months is considered reasonable). Step 4: Give a final recommendation with your reasoning clearly stated.
2.4. Meta Prompting:
Meta prompting flips the usual order of operations: instead of you writing the ideal instruction, you ask the model to first design (or improve) the prompt it will use to solve the task, and only then execute it.
This works because LLMs are often better at recognizing what a good instruction looks like than the average user, especially for broad or loosely defined tasks.
It's particularly useful when you're not sure how to frame a request, want the model to account for edge cases you haven't thought of, or are building reusable prompt templates for a recurring task. The risk is a small amount of extra latency and the possibility that the self-generated prompt drifts from what you actually wanted, so it's worth reviewing the intermediate prompt before letting the model act on it.
Prompt Example:
promptI want to survey Sweet Crumbs' customers to find out why repeat visits have dropped by 15% over the last two months. I'm not sure how to structure the survey questions effectively.
First, design a high-quality prompt that guides an AI to create an effective 6-question customer survey for this situation—one that avoids leading questions, mixes multiple-choice and open-ended formats, and is short enough that customers will actually finish it. Then, use the prompt you just designed to generate the actual 6-question survey.
2.5. Self-Consistency:
Self-consistency addresses a simple weakness in single-pass reasoning: even a good model can take a wrong turn on any individual attempt. Instead of trusting one chain of reasoning, this technique samples several independent reasoning paths for the same problem — often with some randomness — and then compares the results, keeping the answer that shows up most consistently or holds up best under scrutiny.
It's essentially "ask the same question multiple ways and vote," applied to reasoning rather than raw answers.
This technique is most valuable for problems with a verifiable or comparably scored answer (numeric estimates, forecasts, decisions with clear tradeoffs), because you need a way to judge which path was actually more sound.
It costs more compute and time than a single pass, so it's usually reserved for decisions where getting it right matters more than getting it fast.
Prompt Example:
promptSweet Crumbs needs to price a new custom wedding cake line.
Costs: $18 in ingredients per cake, 3 hours of a baker's time at $25/hour, and $12 in packaging/delivery overhead per order. Generate three independent pricing strategies, each with its own reasoning: 1. A cost-plus strategy targeting a 40% profit margin.
2. A competitor-based strategy assuming similar bakeries in the area charge $180–$220 for comparable cakes.
3. A value-based strategy that accounts for the emotional significance of weddings and willingness to pay a premium. After presenting all three, compare them and recommend the single most defensible price point, explaining why it's more sound than the other two.
2.6. Generate Knowledge Prompting:
Generate Knowledge prompting splits a task into two phases: first, ask the model to produce relevant background facts, definitions, or context related to the task; second, feed that self-generated knowledge back in as grounding for the final answer.
This matters because a model's first instinct on a hard question can skip over foundational context it actually "knows" but wouldn't otherwise surface unprompted. By making the knowledge-gathering step explicit, you reduce the chance the final answer is built on a shaky or incomplete understanding of the topic. It's especially useful for advice-style or analytical tasks where the quality of the answer depends heavily on the quality of the underlying facts — financial planning, health-adjacent topics, or any domain where an ungrounded guess would be risky.
Prompt Example:
promptSweet Crumbs wants to apply for a small business loan to fund the second location discussed earlier.
Before drafting any recommendation, first list the key factors lenders typically evaluate when assessing a small business loan application — things like debt-to-income ratio, time in business, collateral, and cash flow stability. Once you've laid out those factors, use them to assess how strong Sweet Crumbs' loan application would likely look (given: 3 years in business, $45,000/month revenue, 22% profit margin, no existing business debt) and recommend what the owner should prepare or improve before applying.
2.7. Prompt Chaining:
Prompt chaining breaks a large task into a sequence of smaller, focused prompts, where the output of each step becomes the input for the next. Rather than asking a model to do everything in one giant instruction (which increases the odds it drops a requirement or blends steps together), you isolate each stage so it gets the model's full attention and is easy to verify independently.
This is the same principle behind breaking a big function into smaller functions in software engineering — smaller units are easier to test, debug, and reuse.
Prompt chaining is the backbone of most real-world AI workflows and agent pipelines, where a task like "write a report" actually involves research, outlining, drafting, and editing as distinct, dependent stages.
Prompt Example:
promptStep 1 prompt: "List the top 5 factors that typically cause a neighborhood bakery to lose repeat customers."
Step 2 prompt (using the output of Step 1 as input): "Sweet Crumbs has seen a 15% drop in repeat customers over two months. Given the factors from Step 1, which 2–3 are most likely the cause, based on this context: no menu changes, one new competitor opened nearby last month, and average wait times have increased from 5 to 12 minutes." Step 3 prompt (using the output of Step 2 as input): "Based on the most likely causes identified in Step 2, draft a 3-point action plan Sweet Crumbs can implement within the next 30 days to win back repeat customers."
2.8. Tree of Thoughts (ToT):
Tree of Thoughts extends Chain-of-Thought by exploring several possible reasoning paths in parallel rather than committing to a single line of reasoning from the start.
Picture it as a decision tree: at each step, the model generates multiple candidate "next moves," evaluates how promising each one is, and can backtrack away from weak branches instead of being locked into an early mistake.
This mirrors how humans solve hard, open-ended problems—we consider several options before picking one, rather than reasoning in a straight line.
ToT is most useful for planning and strategy problems with several plausible approaches and no single obviously correct path, where a linear CoT approach might latch onto the first idea without properly comparing alternatives.
Prompt Example:
promptSweet Crumbs has a $2,000 marketing budget for the next quarter and needs to decide where to focus it.
Explore three distinct strategic branches: Branch A: Heavy investment in local social media ads and influencer partnerships. Branch B: A loyalty/referral program combined with in-store events. Branch C: Local press, farmers' market pop-ups, and community
partnerships. For each branch, reason through the likely customer reach, cost efficiency, and how quickly it would show measurable results. Rate each branch on a 1–10 feasibility score for a bakery this size. Then select the strongest branch, and if a hybrid of two branches would outperform any single one, propose that instead — explaining why it wins over the alternatives.
2.9. Retrieval Augmented Generation (RAG):
RAG pairs a language model with an external retrieval system — a document store, search index, or database — so the model can pull in specific, current, or proprietary information at the moment it answers, instead of relying solely on what it memorized during training.
The retrieval step typically converts a query into an embedding, searches for the most relevant chunks of text in a knowledge base, and inserts those chunks into the prompt as grounding context before the model generates its answer.
This is the standard technique for reducing hallucination in production AI systems, because the model is reasoning over real, sourced data rather than guessing from memory — and it's essential for any use case involving information that changes over time or that the model was never trained on in the first place (internal company documents, recent sales figures, live inventory, and so on).
Prompt Example:
promptUsing the attached Sweet Crumbs Q3 sales report (retrieved document: product-level revenue, unit sales, and returning-customer percentage by week for July–September), answer the following:
1. Which three products drove the largest share of revenue in Q3? 2. Identify any week where returning-customer percentage dropped sharply, and note what else was happening that week according to the report (promotions, price changes, etc., if mentioned). 3. Based only on the data in this report — not general bakery industry assumptions — recommend one product to promote more heavily in Q4 and explain your reasoning using specific figures from the document.
2.10. Automatic Reasoning and Tool-use (ART)
ART equips the model to autonomously decide, mid-reasoning, when it needs to stop "thinking in words" and instead call an external tool—a calculator, code interpreter, search engine, or API—to get a more reliable intermediate result.
Rather than a developer hardcoding exactly when each tool should be used, the model plans its own multi-step reasoning trace and inserts tool calls where they're actually needed, then continues reasoning with the tool's output folded in.
This matters because language models are unreliable at precise arithmetic and out of date on live facts, so letting the model reach for the right tool at the right moment produces answers that are more accurate and easier to trust than pure text-based reasoning.
Prompt Example:
promptSweet Crumbs wants to know the exact break-even point for the proposed second location.
Given: a one-time setup cost of $80,000, additional fixed monthly costs of $6,000, projected monthly revenue of $31,500, and a 22% profit margin on that revenue. Use a calculator tool to compute the exact monthly net profit from the new location, then calculate precisely how many months it will take to recover the $80,000 setup cost. Show the tool-assisted calculations you used, then explain in plain language what the break-even timeline means for the owner's decision.
2.11. Automatic Prompt Engineer (APE):
APE uses the model itself as a prompt-writing engine: it generates a set of candidate prompts for a given task, evaluates how well each one performs (often by scoring the outputs they produce against some criteria), and selects or refines the best-performing version.
This effectively automates the trial-and-error process a human prompt engineer would normally do by hand, which is valuable when you need to scale prompt design across many similar tasks—for example, generating consistent product descriptions for hundreds of items or building a reusable prompt template for a customer support bot.
It trades some manual control for speed and consistency, and works best when you can clearly define what "a good output" looks like so the evaluation step is meaningful.
Long Prompt Example:
promptSweet Crumbs needs a reusable prompt template for generating Instagram captions for new menu items and wants the best possible version before rolling it out.
Generate three candidate prompt templates for creating Instagram captions that are warm, appetite-appealing, under 150 characters, and end with a call to action. Test each candidate template by using it to write a caption for "Maple Pecan Sticky Buns." Compare the three resulting captions against the goals above, select the strongest-performing template, and present it as the final, ready-to-use prompt.
2.12. Active-Prompt:
Active-Prompt improves on standard few-shot prompting by selectively choosing which examples to include, rather than selecting them randomly or for convenience.
It works by first running the task on a batch of unlabeled cases, measuring where the model's reasoning shows the most uncertainty or disagreement across multiple attempts, and then prioritizing human-verified examples for exactly those uncertain cases when building the final few-shot prompt.
The core insight is that not all examples are equally valuable — a well-chosen example covering the model's actual weak points teaches it far more than an easy example it would have gotten right anyway. This makes it especially useful in specialized domains where labeling every possible example is expensive, so you want to spend that labeling effort where it matters most.
Prompt Example:
promptSweet Crumbs is training an internal assistant to classify customer emails into categories: Complaint, Compliment, Order Question, or Catering Inquiry.
The assistant was run on 50 unlabeled sample emails, and its confidence was lowest (most inconsistent across repeated attempts) on emails that mix a compliment with a complaint, such as: "The cake tasted amazing, but it arrived an hour late for the party." Given this, prioritize adding two to three human-labeled examples of exactly this mixed compliment-plus-complaint pattern to the few-shot prompt, rather than adding more straightforward examples the model already classifies correctly. Then classify this new email using the improved example set: "Your croissants are the best in town, but I waited 20 minutes past my pickup time again."
2.13. Directional Stimulus Prompting (DSP):
Directional Stimulus Prompting steers a model's output toward a specific angle, tone, or focus using small, targeted hints — a keyword, a perspective, a constraint — rather than rewriting the entire instruction from scratch.
Think of it as giving the model a nudge in the right direction instead of a full roadmap: the core task stays the same, but the "stimulus" shapes which aspects the model emphasizes.
This is a lightweight technique, well suited for cases where you need many variations of the same underlying task (the same product description written for different audiences, for example) without maintaining a completely separate prompt for each variation.
Prompt Example:
promptWrite a short announcement about Sweet Crumbs' new gluten-free menu line launching next month.
Directional stimulus: Frame the announcement around inclusivity and the bakery's commitment to ensuring every customer—regardless of dietary restrictions—can enjoy the same quality baked goods as everyone else. Keep the focus on the emotional "finally, something for me" reaction, rather than on technical ingredient details.
2.14. Program-Aided Language Models (PAL):
PAL addresses a well-known weakness of language models—unreliable arithmetic and multi-step calculation—by having the model generate code to perform the computation, rather than attempting the math in natural language.
A real interpreter executes the generated code, and the precise, verifiable output is then handed back to the model to weave into its natural-language response.
This separates "reasoning about what to calculate" (which language models are good at) from "actually calculating it" (which a programming language does far more reliably than token-by-token text generation).
It's the go-to technique for any task involving non-trivial math, data transformation, or anything where a small arithmetic slip would meaningfully change the answer.
Prompt Example:
promptSweet Crumbs sold the following units last month: Sourdough Loaf (420 units @ $7.50), Almond Croissant (610 units @ $4.25), and Custom Cakes (38 units @ $95).
Write Python code to calculate: total revenue per product, total overall revenue, and each product's percentage share of total revenue. Run the code to get exact figures, then use those results to write a summary explaining which product is the biggest revenue driver and whether that matches how much shelf space and staff time it currently gets.
2.15. ReAct:
ReAct (Reason + Act) interleaves explicit reasoning steps ("thoughts") with concrete actions (tool calls, searches, calculations) in a repeating loop: think about what's needed, take an action to get that information, observe the result, then reason again with the new information in hand. This loop continues until the model has everything it needs to give a final answer.
It's the foundational pattern behind most modern AI agents because it mirrors how a competent human researcher works—you don't plan every step in advance; you gather information, adjust your understanding, and decide the next step based on what you just learned. Unlike a single-shot tool call, ReAct lets the model course-correct mid-task if an action reveals something unexpected.
Prompt Example:
promptSweet Crumbs wants to know whether opening on Sundays would be profitable. Thought: I need to know current weekday vs. weekend foot traffic patterns before estimating Sunday demand. Action: Look up Sweet Crumbs' foot traffic log for the past 8 weeks.
Observation: [traffic data returned — Saturdays average 240 customers, weekdays average 90–110 customers] Thought: I also need labor cost for a Sunday shift to compare against likely Sunday revenue. Action: Calculate the cost of one 8-hour Sunday shift with 2 staff at $18/hour.
Observation: [$288 total labor cost] Continue this reasoning-and-action loop, gathering any further information needed, until you can give a final, well-supported recommendation on whether Sweet Crumbs should open on Sundays.
2.16. Reflexion:
Reflexion gives a model the ability to improve its own output through self-critique, without retraining—a form of "verbal reinforcement learning" where feedback is expressed in language rather than gradient updates. The model produces an initial attempt, is prompted to honestly evaluate that attempt against the goal (What's missing? What's weak? What would a critic say?), and then produces a revised version informed by its own critique. This loop can repeat multiple times. It's particularly effective for tasks with a clear notion of quality that's hard to nail on the first try — writing, code, and strategic plans — because the revision step catches issues a single generation pass tends to miss, especially around completeness and internal consistency.
Prompt Example:
promptHere is a first draft of Sweet Crumbs' Q4 marketing plan: [insert full first-draft plan here]
Critique this draft honestly: identify anywhere the plan is vague, missing a budget breakdown, missing a way to measure success, or unrealistic given a $2,000 monthly budget. List every weakness you find, even minor ones. Then rewrite the plan into an improved version that fixes every weakness you identified — with concrete numbers, clear ownership of each task, and measurable success metrics for each initiative.
2.17. Multimodal CoT:
Multimodal CoT extends chain-of-thought reasoning beyond plain text, letting a model reason step-by-step across a mix of inputs — images, charts, diagrams, audio — alongside language.
Instead of reasoning only over what's described in words, the model must interpret visual or non-text evidence directly and fold that interpretation into its reasoning chain, the same way a person might glance at a chart before explaining a trend.
This is essential for any task where the answer genuinely depends on visual information that can't be fully captured in a text description — reading a sales chart, evaluating a product photo, or interpreting a floor-plan layout — and it typically produces more grounded, accurate conclusions than asking the model to reason about a chart's contents purely from a written summary of it.
Prompt Example:
prompt[Attached: a bar chart image showing Sweet Crumbs' weekly foot traffic over the last 8 weeks, with a visible dip in weeks 5–6]
Look at the attached foot-traffic chart. Step 1: Describe what the chart shows, including the specific weeks where traffic dropped. Step 2: Cross-reference that dip with the fact that a new competitor bakery opened at the start of week 5, three blocks away. Step 3: Reason about whether the timing supports competitor impact as the likely cause, or whether another explanation (seasonality, weather, a menu change) fits the pattern better. Step 4: Recommend one action to test your conclusion over the next two weeks.
2.18. Graph Prompting:
Graph prompting structures a model's reasoning around explicit graph relationships — nodes representing entities (people, products, events) and edges representing how they connect (causes, depends-on, purchased-with) — rather than leaving those relationships implicit in a paragraph of text.
This is powerful for problems where the connections between things matter as much as the things themselves: supply chains, customer relationship networks, dependency chains, or root-cause analysis.
By giving the model a graph-shaped representation of the data, you help it trace multi-hop relationships (A affects B, which affects C) far more reliably than if it had to infer that same chain from unstructured prose, where indirect connections are easy to miss.
Prompt Example:
promptHere is a relationship graph for Sweet Crumbs' supply chain:
Flour Supplier -> Sourdough Production -> Sourdough Loaf (product); Butter Supplier -> Croissant Production -> Almond Croissant (product) Sourdough Loaf -> 35% of weekly revenue Almond Croissant -> 20% of weekly revenue Flour Supplier -> recent delivery delays (2 late shipments this month) Using this graph, trace the chain of impact from the flour supplier's delivery delays through to Sweet Crumbs' overall weekly revenue. Identify which product line is most exposed to this risk, and recommend one mitigation step (e.g., backup supplier, buffer stock) based on the dependency chain shown in the graph.
Final Thoughts:
Prompt engineering isn't about memorizing clever tricks — it's about understanding how a model reasons, and choosing the technique that matches the shape of your problem. Simple factual tasks rarely need more than zero-shot or few-shot prompting. Anything involving multi-step logic benefits from Chain-of-Thought or Self-Consistency. Tasks that need current information or must stay grounded in fact call for RAG. And once you're building autonomous agents rather than single-turn chatbots, patterns like ReAct, Reflexion, and Prompt Chaining become essential — because agents don't just answer, they plan, act, and adapt.
The techniques in this guide aren't mutually exclusive. Real-world systems often combine several — a RAG pipeline feeding a ReAct loop, or a Tree of Thoughts search wrapped in Self-Consistency for validation. The best way to build intuition is to treat every prompt like an experiment: start simple, observe where the model falls short, and layer in the technique that solves that specific gap. That iterative mindset — not any single technique — is what actually makes someone effective at prompt engineering.




