Prompt Engineering Techniques: Zero-Shot to Chain-of-Thought (AIF-C01)
Prompt engineering is the practice of writing clear, well-structured instructions so a foundation model produces the output you want, and it is the cheapest way to shape a model's behavior because it needs no training. This lesson covers Task 3.2 of the AIF-C01 exam. You will learn the building blocks of a prompt, including context, instruction, and negative prompts, and the core techniques the exam names: zero-shot, single-shot, few-shot, and chain-of-thought prompting, plus reusable prompt templates. You will see a concrete before-and-after example of improving a weak prompt, review the benefits and best practices that raise response quality, and learn the security risks unique to prompting, such as prompt injection and jailbreaking. Finally, you will see how Amazon Bedrock Prompt Management helps you version and manage prompts. These are recognition-level skills: the exam rewards knowing which technique fits a task and what each risk means.
On this page7 sections
- What Prompt Engineering Is and Its Building Blocks
- Zero-Shot, Single-Shot, and Few-Shot Prompting
- Chain-of-Thought Prompting and Prompt Templates
- Techniques Compared and a Before-and-After Example
- Benefits and Best Practices
- Risks and Limitations of Prompting
- Prompt Versioning and Management with Amazon Bedrock Prompt Management
- Identify the core constructs of a prompt: context, instruction, negative prompts, and examples.
- Distinguish zero-shot, single-shot, and few-shot prompting by how many examples they provide.
- Explain chain-of-thought prompting and when reusable prompt templates help.
- Improve a weak prompt using specificity, clear instructions, and context.
- Describe the risks of prompting, including prompt injection, exposure, poisoning, hijacking, and jailbreaking.
- Describe prompt versioning and management with Amazon Bedrock Prompt Management.
What Prompt Engineering Is and Its Building Blocks
Prompt engineering is the practice of designing the input you give a foundation model so it returns accurate, relevant, useful output. Because you are only changing the prompt, not retraining the model, it is the fastest and cheapest way to improve results. A well-built prompt is usually made of a few recognizable constructs.
- Instruction — the task you want done, stated directly, such as "Summarize the review in two sentences." Clear instructions are the heart of a good prompt.
- Context — background information the model should use, such as the document to summarize, the audience, or the role the model should play. Context grounds the answer.
- Input data — the specific content the model acts on, for example the customer message or the text to translate.
- Examples — sample input-and-output pairs that show the model the format or style you expect. Examples power the few-shot techniques below.
- Negative prompts — instructions about what to avoid, such as "Do not include personal opinions" or "Do not mention competitors." Negative prompts steer the model away from unwanted content.
You rarely need all of these at once, but recognizing them helps you diagnose a weak prompt. If a model's answer is off-topic, the context may be missing; if the format is wrong, add an example; if it keeps including something unwanted, add a negative prompt. The exam expects you to match each construct to its role in shaping the response.
Zero-Shot, Single-Shot, and Few-Shot Prompting
The most commonly tested techniques differ by how many examples you include in the prompt. An example is a demonstration of the task, an input paired with the desired output, that shows the model what you want.
Zero-shot prompting gives the model an instruction with no examples and relies on its built-in knowledge. For instance: "Classify this review as positive or negative: The delivery was fast and the product works great." You provide only the task and the input. Zero-shot is quick and works well for straightforward tasks a capable model already understands.
Single-shot (also called one-shot) prompting gives one example before the real task, so the model can see the expected format. You might show one review already labeled "positive," then ask the model to label a new one the same way.
Few-shot prompting gives several examples, typically two to five, before the real task. Each example demonstrates an input and its correct output, so the model learns the pattern from the samples and applies it. Few-shot improves accuracy and consistency on tasks where the format or the desired judgment is not obvious from a plain instruction, such as applying a specific labeling scheme or a particular writing style. The trade-off is that more examples use more tokens. For the exam, anchor on the count: zero examples is zero-shot, one example is single-shot, and several examples is few-shot. When a scenario says "give the model a few examples in the prompt," the answer is few-shot prompting.
Chain-of-Thought Prompting and Prompt Templates
Chain-of-thought (CoT) prompting asks the model to show its reasoning step by step before giving a final answer, often by adding a phrase such as "Let's think step by step" or "Explain your reasoning, then answer." By working through intermediate steps, the model handles complex, multi-step problems, such as word problems, logic puzzles, or multi-part analysis, more reliably than when it jumps straight to an answer. The technique trades extra output tokens for better accuracy on hard tasks. When a question describes a complex reasoning problem and asks how to improve the model's accuracy, chain-of-thought is the technique being tested.
Prompt templates are reusable prompt structures with placeholders that you fill in for each request. Instead of rewriting a prompt every time, you create a template such as: "You are a support assistant. Using the following policy: {policy}, answer the customer question: {question}. Do not guess if the answer is not in the policy." The bracketed slots are filled with real values at run time. Templates make prompting consistent and repeatable across many requests, which matters when an application sends thousands of prompts. They also make prompts easier to test, share, and improve, because everyone uses the same proven structure. Templates often combine the constructs from the first section, a role, an instruction, context, and a negative prompt, into one dependable pattern that a whole team can reuse.
Techniques Compared and a Before-and-After Example
The table below summarizes the core techniques and when to reach for each.
| Technique | Examples in prompt | When to use |
|---|---|---|
| Zero-shot | None | Straightforward tasks a capable model already understands. |
| Single-shot (one-shot) | One | When one example is enough to show the expected format. |
| Few-shot | Several (2 to 5) | When the format or judgment needs a pattern the model can copy. |
| Chain-of-thought | None or a few | Complex, multi-step reasoning where step-by-step thinking improves accuracy. |
| Prompt template | Reusable structure | Repeated, consistent prompting across many requests. |
A concrete before-and-after shows why technique and construction matter. A weak prompt is: "Write about our product." It is vague, has no context, no audience, and no format, so the model guesses and the output is generic.
An improved prompt applies clear instruction, context, specificity, and a negative prompt: "You are a marketing writer. Write a 50-word product description for the SoloBrew coffee maker, a compact single-cup brewer aimed at people in small apartments. Highlight its small size and one-touch operation. Use a friendly, concise tone. Do not invent technical specifications." The improved version tells the model who to be, exactly what to produce, for whom, what to emphasize, the length and tone, and what to avoid. This is prompt engineering in action: same model, far better result, achieved only by rewriting the prompt.
Benefits and Best Practices
Prompt engineering delivers real value with no training cost, which is why the exam frames it as the first tool to reach for. The main benefits and best practices are worth knowing as a group.
Benefits. Good prompts improve response quality, producing more accurate and relevant answers. Prompting supports fast experimentation, since you can test many variations quickly and cheaply. It aids discovery, helping you learn what a model can do for your use case. And prompts can enforce lightweight guardrails at the instruction level, for example telling the model to refuse off-topic requests or to stay within a defined scope.
Best practices. Follow a few habits to get consistent results:
- Be specific. State exactly what you want, including format, length, tone, and audience. Vague prompts produce vague answers.
- Give clear instructions. Put the task up front and phrase it plainly, avoiding ambiguity.
- Be concise. Include what the model needs and cut noise; unnecessary text wastes tokens and can distract the model.
- Provide context and examples. Ground the model with relevant background, and show examples when the format or judgment is not obvious.
- Experiment and iterate. Try variations, compare results, and refine, since small wording changes can noticeably change output.
Taken together, specificity, clarity, and concision are the habits that most improve results, and the exam rewards recognizing them as best practices.
Risks and Limitations of Prompting
Prompting introduces security risks the exam expects you to recognize, because a model follows instructions in its input and an attacker may try to control that input. Learn each term by what it does.
- Prompt injection — an attacker hides malicious instructions inside the input, such as a document or user message, to trick the model into ignoring its original instructions and doing something else. This is the headline risk when untrusted text reaches a model.
- Jailbreaking — crafting input designed to bypass the model's safety rules and make it produce restricted or harmful content it would normally refuse.
- Prompt hijacking — taking over the model's behavior by overriding the intended instructions, redirecting it to serve the attacker's goal instead of the application's.
- Prompt (or prompt-data) poisoning — corrupting the examples, context, or data a model relies on so its behavior is skewed or its outputs become untrustworthy.
- Exposure — sensitive information leaking, for example a system prompt, private data, or confidential context being revealed in the model's output.
The limitation behind all of these is that a foundation model does not truly separate trusted instructions from untrusted input; it treats the whole prompt as text to act on. That is why untrusted content, such as a user message or a fetched web page, must be handled carefully. For the exam, connect "trick the model into ignoring its instructions" to prompt injection, and "bypass the model's safety rules" to jailbreaking. Deeper guardrail and responsible-AI controls belong to another domain; here you only mention prompt-level defenses.
Prompt Versioning and Management with Amazon Bedrock Prompt Management
Once prompts become part of a real application, they need to be managed like any other important asset. A prompt that works today may be edited, and a change can quietly make outputs worse, so teams need a way to save, compare, and roll back prompt versions. This is prompt versioning and management: keeping track of prompt changes over time, storing known-good versions, and reusing tested prompts across an application.
On AWS, Amazon Bedrock Prompt Management is the service for this. It lets you create, store, and version prompts in one place, so you can build a prompt, save it as a version, test changes, and return to a previous version if an edit causes problems. Because prompts are stored centrally, teams can reuse the same approved prompts instead of copying slightly different versions into different parts of the code, which reduces inconsistency and mistakes.
The exam-level point is simple: when a scenario describes the need to organize, version, reuse, or roll back prompts in a controlled way, Amazon Bedrock Prompt Management is the AWS answer. It brings the same discipline to prompts, saving versions, comparing them, and reusing tested ones, that developers already apply to source code, which matters as an application grows and many prompts must stay consistent and reliable over time.
Tip. Expect questions that name a technique from its description. "Give the model a few examples in the prompt" is few-shot prompting, one example is single-shot, and no examples is zero-shot; "ask the model to reason step by step to improve accuracy on hard problems" is chain-of-thought. Security items describe an attack and want the term: "trick the model into ignoring its instructions" is prompt injection, and "bypass the model's safety rules" is jailbreaking. When a scenario needs prompts versioned, reused, or rolled back, the answer is Amazon Bedrock Prompt Management.
- Prompt engineering shapes a model's output by improving the prompt, with no training, making it the cheapest way to change model behavior.
- The core prompt constructs are instruction (the task), context (background), input data, examples, and negative prompts (what to avoid).
- Techniques differ by example count: zero-shot uses no examples, single-shot uses one, and few-shot uses several to teach a pattern.
- Chain-of-thought prompting asks the model to reason step by step, improving accuracy on complex, multi-step problems.
- Prompt templates are reusable structures with placeholders that keep prompting consistent and repeatable across many requests.
- Best practices are specificity, clear instructions, concision, providing context and examples, and iterating; they most improve response quality.
- Prompting risks include prompt injection (hidden malicious instructions), jailbreaking (bypassing safety rules), hijacking, poisoning, and exposure of sensitive data.
- Amazon Bedrock Prompt Management stores, versions, and reuses prompts so teams can test changes and roll back to known-good versions.
Frequently asked questions
What is the difference between zero-shot and few-shot prompting?
The difference is how many examples the prompt includes. Zero-shot prompting gives the model only an instruction and the input, with no examples, and relies on the model's built-in knowledge; it works well for straightforward tasks. Few-shot prompting includes several examples, usually two to five, each showing an input paired with the desired output, so the model learns the pattern and applies it to the new input. Few-shot improves accuracy and consistency when the format or judgment is not obvious from a plain instruction, at the cost of using more tokens. Between the two sits single-shot, also called one-shot, which provides exactly one example. On the exam, match the number of examples to the name: zero is zero-shot, one is single-shot, several is few-shot.
What is chain-of-thought prompting?
Chain-of-thought prompting is a technique that asks the model to show its reasoning step by step before giving a final answer, often by adding a phrase such as "Let's think step by step." By working through intermediate steps rather than jumping straight to a conclusion, the model handles complex, multi-step problems, such as math word problems, logic tasks, or multi-part analysis, more reliably. The trade-off is that the model produces more output, using more tokens, but accuracy on difficult reasoning tasks improves. On the exam, when a scenario describes a complex problem and asks how to make the model's reasoning more accurate, chain-of-thought prompting is the technique being tested.
What is prompt injection?
Prompt injection is a security risk in which an attacker hides malicious instructions inside the input a model receives, such as a user message, an uploaded document, or a fetched web page, to trick the model into ignoring its original instructions and doing something else. It is the headline risk whenever untrusted text reaches a foundation model, because the model treats the whole prompt as text to act on and does not reliably separate trusted instructions from untrusted input. Related risks include jailbreaking, which crafts input to bypass the model's safety rules; hijacking, which overrides the intended instructions to redirect behavior; poisoning, which corrupts the data or examples the model relies on; and exposure, which leaks sensitive information such as a system prompt. On the exam, "trick the model into ignoring its instructions" points to prompt injection.
What is a prompt template?
A prompt template is a reusable prompt structure with placeholders that you fill in for each request, instead of writing a new prompt every time. For example, a template might read: "You are a support assistant. Using the following policy: {policy}, answer the customer question: {question}." The bracketed slots are replaced with real values at run time. Templates keep prompting consistent and repeatable across many requests, make prompts easier to test and share, and let a whole team reuse the same proven structure. They often combine several prompt constructs, such as a role, an instruction, context, and a negative prompt, into one dependable pattern. On AWS, Amazon Bedrock Prompt Management helps store and version such prompts.
What is Amazon Bedrock Prompt Management?
Amazon Bedrock Prompt Management is the AWS service for creating, storing, versioning, and reusing prompts in one place. As prompts become part of a real application, they need to be managed like any other important asset, because editing a prompt can quietly change outputs. Prompt Management lets you save a prompt as a version, test changes, compare versions, and roll back to a previous version if an edit causes problems. Storing prompts centrally also lets teams reuse the same approved prompts rather than copying slightly different versions across the code, which reduces inconsistency. On the exam, when a scenario describes organizing, versioning, or rolling back prompts in a controlled way, Amazon Bedrock Prompt Management is the answer.
Sign up free to mark lessons complete, bookmark topics and track your exam readiness.