PROMPT ENGINEERING
The Complete Learning Guide
Master the art of communicating with AI
Techniques • Best Practices • Templates • Exercises
1. WHAT IS PROMPT ENGINEERING?
Prompt Engineering is the practice of designing and optimizing text inputs — called "prompts" — to get the
best possible outputs from AI language models such as ChatGPT, Claude, or Gemini. It is part science, part
art.
Why It Matters
• Better accuracy and relevance from AI responses
• Saves time — fewer retries and corrections needed
• Unlocks advanced AI capabilities others miss
• Essential skill for developers, writers, analysts, and PMs
• Can be the difference between an AI product succeeding or failing
2. KEY VOCABULARY
Term Definition
Prompt The text input you send to an AI model (question, instruction, or command)
Token Small text units (~4 characters each) that the AI reads and processes
Context Window The total amount of text the AI can "remember" in one session
System Prompt Background instructions that shape the AI's behavior and persona
Temperature Setting (0–1) that controls creativity: low=precise, high=creative
Hallucination When AI generates false or made-up information with false confidence
LLM Large Language Model — the AI brain behind chatbots (GPT-4, Claude,
Gemini)
Zero-Shot Asking the AI with no examples — just a direct instruction
Few-Shot Providing 2–3 examples before your real question to guide the AI
Chain-of-Thought Asking AI to reason step by step to improve accuracy on hard problems
Inference The process of the AI generating a response from your prompt
Fine-tuning Training a model further on specific data to specialize its behavior
3. PROMPTING TECHNIQUES
① Zero-Shot Prompting
Directly ask the AI without providing any examples. Works well for simple, well-defined tasks.
Example:
"Translate this sentence to French: I love coding."
② Few-Shot Prompting
Provide 2–3 examples before your real question to teach the AI your desired format or style.
Example:
"Positive: I love this! → Happy Negative: This is awful → Sad Neutral:
It's okay → ?"
③ Chain-of-Thought (CoT)
Ask the AI to "think step by step." Dramatically improves accuracy for math, logic, and
multi-step problems.
Example:
"A store sells 3 apples for $2. I buy 9. How much do I pay? Think step by
step."
④ Role / Persona Prompting
Assign the AI a specific expert role. It will respond with that expert's knowledge and tone.
Example:
"Act as a senior cybersecurity expert. Explain SQL injection to a
beginner."
⑤ Prompt Chaining
Break a complex task into smaller steps. Feed each output as the input to the next prompt.
Example:
Step 1: "Summarize this article." → Step 2: "Rate its completeness 1–10."
→ Step 3: "Improve it."
⑥ Meta-Prompting
Use AI to write or improve your own prompts. Describe what you want and let AI craft the best
prompt.
Example:
"Write me an optimized prompt to ask you to generate Python code with full
error handling."
⑦ Output Scaffolding
Give the AI the beginning of the desired output format to lock in structure.
Example:
"List 5 AI tools. Use ONLY this format: 1. [Name] | [Category] | [Best use
case]"
⑧ Retrieval-Augmented (RAG)
Combine a prompt with retrieved documents or data to ground AI answers in real, specific
information.
Example:
"Given this support doc: [paste doc]... Answer: Why is my payment
failing?"
4. BEST PRACTICES
01. Be Specific & Clear
Vague prompts produce vague results. Always define the task, target audience, tone, and
expected output.
Tip: Bad: "Write about AI" → Good: "Write a 200-word intro to AI for high
school students."
02. Use Positive Instructions
Tell the AI what TO DO rather than what NOT to do. Positive instructions are processed more
reliably.
Tip: Bad: "Don't be too long" → Good: "Keep your response under 100
words."
03. Specify Output Format
Always state the exact format needed: bullet points, JSON, table, numbered list, paragraphs,
etc.
Tip: Good: "Compare Python vs JavaScript in a 3-column table: Feature |
Python | JavaScript"
04. Provide Context
Background information dramatically improves relevance. Tell the AI who you are and why
you need this.
Tip: Good: "I am a 10th-grade teacher. Create a fun quiz about
photosynthesis for 15-year-olds."
05. Use Delimiters
Separate instructions from content using """, ###, or XML-style to prevent confusion.
Tip: Good: "Summarize the text below. """ [paste your text here] """"
06. Prevent Hallucinations
Add a clause to allow AI to admit uncertainty rather than fabricate an answer.
Tip: Add: "If you don't know the answer, say 'I don't know' rather than
guessing."
07. Iterate & Refine
Treat prompts like code — test, measure, and improve them. Small wording changes can
have huge effects.
Tip: Tip: Keep a personal "prompt library" noting what works best for each
task type.
08. Control Temperature
Match the temperature to your task. Facts and code need precision; creative tasks need
variety.
Tip: Low (0.0–0.3): code, facts, summaries | High (0.7–1.0): stories,
brainstorms, poetry
5. THE PERFECT PROMPT STRUCTURE
A well-crafted prompt can have up to 5 components. Not every prompt needs all 5 — use what the task
requires.
Part Purpose Example
ROLE Who should the AI be? You are an expert Python tutor with 10 years of
teaching experience.
CONTEXT What is the situation? I am a complete beginner who has never coded
before.
TASK What should the AI do? Explain what a Python function is and how to write
one.
FORMAT How should output look? Use: 1) Simple definition 2) Code example 3) When to
use it.
CONSTRAINTS What are the limits/rules? Keep under 150 words. Avoid technical jargon.
Full Example Prompt:
You are an expert Python tutor with 10 years of teaching experience. [ROLE] I am a
complete beginner who has never coded before. [CONTEXT] Explain what a Python function
is and how to write one. [TASK] Structure your answer as: 1) Simple definition 2) A
code example 3) When to use it. [FORMAT] Keep it under 150 words. Avoid technical
jargon. [CONSTRAINTS]
6. COMMON MISTAKES TO AVOID
Mistake: Too Vague
Bad prompt: "Write about the economy."
Better prompt: "Summarize the top 3 causes of the 2008 financial crisis in bullet points for a
college student."
Mistake: No Context
Bad prompt: "Write an email."
Better prompt: "Write a polite follow-up email to a client who missed our Tuesday Zoom
meeting."
Mistake: Negative Instructions
Bad prompt: "Don't make it complicated."
Better prompt: "Explain this in simple language suitable for a 12-year-old."
Mistake: No Format Given
Bad prompt: "Compare React and Vue."
Better prompt: "Compare React and Vue in a table with columns: Feature | React | Vue."
Mistake: Asking Too Much at Once
Bad prompt: One prompt: "Research, write, format, and publish a blog post."
Better prompt: Split into steps: Research → Outline → Draft → Edit → Format
7. QUICK REFERENCE CHEAT SHEET
Goal Best Technique Key Phrase to Use Temperature
Simple one-off task Zero-Shot "Explain / Write / List..." 0.3–0.5
Consistent format output Few-Shot "Here are examples: ..." 0.2–0.4
Math / logic / reasoning Chain-of-Thought "Think step by step." 0.0–0.2
Expert-level answer Role Prompting "Act as a [role]..." 0.4–0.6
Complex multi-step task Prompt Chaining Break into separate prompts varies
"Respond ONLY in this format:
Predictable structure Scaffolding 0.1–0.3
..."
Better prompts Meta-Prompting "Write me a prompt to ask you..." 0.5–0.7
Creative content High Temperature Increase temp to 0.8–1.0 0.8–1.0
Facts / summaries / code Low Temperature Keep temp at 0.0–0.3 0.0–0.3
Grounded in real data RAG "Given this document: [paste]..." 0.2–0.4
8. PRACTICE EXERCISES
Exercise: BEGINNER
Rewrite this weak prompt to make it specific, formatted, and contextual:
Original: "Tell me about machine learning."
Hint: Add a role, specify your audience, define the format, and limit the length.
Exercise: INTERMEDIATE
Build a Few-Shot prompt to classify customer support tickets as: Bug / Feature Request /
Billing / Other.
You must provide at least 3 examples before the real ticket.
Hint: Format each example as: Ticket: "..." → Category: [label]
Exercise: ADVANCED
Design a 3-step Prompt Chain to process a research paper:
Step 1: Summarize the paper in 5 bullet points. Step 2: Identify 3
potential weaknesses. Step 3: Suggest 2 follow-up research questions.
Hint: Each step should explicitly reference or paste the output of the previous step.
Exercise: CHALLENGE
Use Meta-Prompting: Ask Claude/ChatGPT to generate the best possible prompt for this task:
"I need to generate weekly status report emails from raw bullet-point
notes."
Hint: Ask the AI: "What is the optimal prompt I should use to ask you to [task]?"
Happy Learning! — Prompt Engineering Guide
Practice daily • Iterate • Build your prompt library