Prompt Engineering
The same LLM can produce brilliant or useless output depending on how you ask. Prompt engineering is the highest-leverage skill in AI engineering — it controls behavior, format, tone, and accuracy without changing model weights.
Prompt engineering is like briefing a talented contractor — a vague brief ('fix the kitchen') gets mediocre results. A detailed brief ('replace countertops with quartz, keep existing cabinets, budget $5K') gets exactly what you need.
Visual Workflows
Start here — study each diagram, then use + / − to zoom if needed.
Scroll inside the frame · use + / − to zoom
Key Takeaways
- 1.Prompt engineering is the practice of crafting effective inputs to LLMs — using system prompts, few-shot examples, and structured instructions to get reliable, high-quality outputs.
- 2.Techniques: system prompts (set role and rules), few-shot examples (show input-output pairs), chain-of-thought (ask model to reason step by step), role prompting ('You are an expert...'), output formatting instructions ('Respond in JSON'), delimiters (separate sections with ###), and negative instructions ('Do not invent facts').
- 3.Key principles: be specific, provide context, define output format, include examples for complex tasks, and iterate based on evaluation results.
Real Example
Scenario
Instead of 'Summarize this', you write: 'Summarize the following article in 3 bullet points. Focus on actionable insights for product managers. Use plain language. Article: ...' — getting focused, useful output every time.
What you would do
In Generative AI Foundations, apply Prompt Engineering to this scenario: Instead of 'Summarize this', you write: 'Summarize the following article in 3 bullet points. Identify the inputs, run the technique, validate the output, and note one thing you would monitor in production.
Practice Task
Open the Code Walkthrough below and run it locally. Change one parameter related to Prompt Engineering (e.g. model, temperature, top_k, or tool name), observe the difference in output, and write 2–3 sentences explaining what changed.
Code Walkthrough
Highlighted lines show where Prompt Engineering happens in the code.
1SYSTEM_PROMPT = """You are a technical documentation writer.2Rules:3- Use clear, concise language4- Include code examples where relevant5- Structure with headers and bullet points6- If unsure, say "I don't have enough information"7"""8
9FEW_SHOT = [10 {"role": "user", "content": "Explain REST APIs"}, # key line for Prompt Engineering11 {"role": "assistant", "content": "## REST APIs\n\n- Resource-based URLs...\n\n```python\nresponse = httpx.get('/users')\n```"}, # key line for Prompt Engineering12]13
14messages = [15 {"role": "system", "content": SYSTEM_PROMPT}, # key line for Prompt Engineering16 *FEW_SHOT,17 {"role": "user", "content": "Explain WebSockets"}, # key line for Prompt Engineering18]Cheat Sheet
Quick recap
quick ref- •System prompt = role + rules
- •Few-shot = example pairs
- •CoT = 'think step by step'
- •Delimiters: ### or triple quotes
- •Version prompts in git
- •Be specific, not vague
Common Mistakes
- ✕Vague prompts producing inconsistent outputs
- ✕Hardcoding prompts in code instead of versioned files
- ✕Not testing prompts with edge cases
- ✕Overly long prompts wasting tokens without improving quality