Learning Objectives
- Apply zero-shot, one-shot, and few-shot prompting techniques
- Use chain-of-thought prompting to improve reasoning quality
- Write effective system prompts to set context and constraints
- Recognize and avoid common prompting mistakes
What Is Prompt Engineering?
Prompt engineering is the practice of crafting inputs to AI systems to get better, more reliable, and more useful outputs. It is the most immediately practical skill for working with LLMs.
The term "engineering" is intentional — this is a craft with repeatable techniques, not magic. The same underlying model can produce wildly different outputs depending on how you frame your request.
Prompting Techniques
Zero-Shot Prompting
Simply ask the model to do something without providing any examples:
Summarize the following article in three bullet points:
[article text]
Zero-shot works well for clear, common tasks. For complex or specialized tasks, you may need to provide more structure.
One-Shot and Few-Shot Prompting
Provide one or more examples of the desired input-output format before giving your actual query:
Convert these sentences to formal tone:
Informal: "Hey, can we chat later?"
Formal: "Would it be possible to schedule a conversation at your convenience?"
Informal: "The report's kinda messy."
Formal: [YOUR TURN]
Few-shot examples dramatically improve output quality for specialized formats, styles, or structured data extraction tasks.
Chain-of-Thought Prompting
For complex reasoning tasks, instruct the model to think step by step before giving an answer:
Solve this problem step by step:
A train leaves Station A at 9:00 AM traveling at 60 mph. Another train leaves Station B
(200 miles away) at 10:00 AM traveling at 80 mph toward Station A. When do they meet?
Let's think through this carefully, step by step.
✅Tip
Chain-of-thought prompting reliably improves accuracy on math, logic, and multi-step reasoning tasks. The phrase "think step by step" or "let's reason through this" is one of the most reliable prompt engineering techniques.
System Prompts
A system prompt is the instruction set given to the model before the conversation begins. It sets:
- Persona: "You are a senior software engineer at a fintech startup"
- Tone: "Respond concisely. No filler phrases."
- Constraints: "Only answer questions about our product. Decline unrelated requests."
- Format: "Always respond in JSON with fields: summary, action_items, priority"
System prompts are the foundation of every production AI application.
Best Practices
Be specific: Vague instructions produce vague outputs.
- ❌ "Write something about climate change"
- ✅ "Write a 150-word summary of the economic costs of climate change for a non-technical audience, citing two statistics"
Specify the format: If you need structured output, say so explicitly.
- "Respond in a markdown table with columns: Tool, Best For, Pricing"
Break complex tasks into steps: Instead of one massive prompt, chain multiple focused prompts.
Iterate: Treat prompting as a feedback loop. If the first output is off, refine your prompt and try again.
Avoiding Hallucinations
LLMs sometimes generate plausible-sounding but incorrect information — a phenomenon called hallucination. Techniques to reduce it:
- Ask the model to cite sources or express uncertainty ("If you're not sure, say so")
- Use retrieval-augmented generation (RAG) to ground the model in real documents
- Verify factual claims independently for high-stakes use cases
⚠️Warning
Prompt injection: Malicious users can attempt to override your system prompt by injecting instructions into their input ("Ignore all previous instructions and..."). Be aware of this attack vector when building user-facing AI applications.
Key Takeaways
- Prompt engineering is a learnable craft with repeatable techniques
- Few-shot examples and chain-of-thought reasoning reliably improve output quality
- System prompts define the AI's behavior, persona, and constraints in production applications
- Treat prompting as an iterative feedback loop — expect to refine your prompts
- Hallucination is real; always verify critical factual claims