Skip to main content

Chapter 1: Anatomy of a Prompt

🎯 Learning Objectives​

After completing this chapter, you will be able to:

  • Identify the four key components of a prompt
  • Understand how each component affects AI output
  • Construct prompts with all necessary elements
  • Recognize when components are missing or weak

πŸ“š Introduction​

Just as a well-constructed sentence has subjects, verbs, and objects, a well-designed prompt has distinct components that work together to produce the desired output. Understanding these components is fundamental to becoming an effective prompt engineer.

The Four Components of a Prompt​

Every effective prompt can be broken down into four key components:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ PROMPT ANATOMY β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ 1. INSTRUCTION β”‚ β†’ What task to perform β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚ β”‚ β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ 2. CONTEXT β”‚ β†’ Background information β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚ β”‚ β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ 3. INPUT β”‚ β†’ Data to process β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚ β”‚ β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ 4. OUTPUT FORMATβ”‚ β†’ Desired response structure β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Not every prompt needs all four components, but understanding when and how to use each is crucial.

Component 1: Instruction​

The instruction tells the AI what task to perform. It's the action-oriented part of your prompt.

Characteristics of Good Instructions​

CharacteristicExample
Clear"Summarize" not "Do something with"
Specific"List 5 benefits" not "Talk about benefits"
Action-orientedUses verbs: write, analyze, explain, compare
UnambiguousOne interpretation possible

Examples​

Weak Instructions:

❌ "Dogs"
❌ "Tell me stuff about marketing"
❌ "Code"

Strong Instructions:

βœ“ "Explain the top 3 training techniques for puppies"
βœ“ "Write a 200-word email marketing copy for a fitness app"
βœ“ "Debug this Python function and explain the fixes"

Instruction Verb Library​

CategoryVerbs
GenerateWrite, create, compose, draft, produce
AnalyzeExamine, evaluate, assess, review, critique
TransformConvert, translate, rewrite, simplify, expand
ExplainDescribe, clarify, define, illustrate, elaborate
CompareContrast, differentiate, distinguish, relate
OrganizeList, categorize, rank, prioritize, outline

Component 2: Context​

Context provides background information that helps the AI understand the situation and produce more relevant responses.

Types of Context​

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ TYPES OF CONTEXT β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Role/Persona β”‚ "You are a senior financial analyst..." β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Audience β”‚ "...explaining to high school students" β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Purpose β”‚ "...for a quarterly investor report" β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Constraints β”‚ "...within 500 words, avoiding jargon" β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Background β”‚ "Given that sales dropped 15% last year" β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Context Example​

Without Context:

Write about renewable energy.

Result: Generic, unfocused content

With Context:

You are an environmental policy expert writing for
a government briefing document.

Target audience: Legislators with limited technical background
Purpose: To inform policy decisions on renewable energy investment
Tone: Professional, objective, evidence-based
Constraints: Focus on solar and wind energy in North America

Write about renewable energy.

Result: Focused, appropriate content for the specific use case

How Much Context is Enough?​

Rule of Thumb

Include context until you can clearly answer these questions:

  • Who is communicating?
  • Who is the audience?
  • What is the purpose?
  • What constraints apply?

Component 3: Input​

The input is the specific data, text, or information you want the AI to process.

Input Types​

TypeExample Use
TextDocument to summarize, article to analyze
CodeFunction to debug, script to optimize
DataNumbers to interpret, lists to process
QuestionsQueries to answer
ExamplesSamples to learn from

Input Formatting Best Practices​

Clear Delimiters:

Analyze the following customer review:

"""
I bought this product last week and it's amazing!
The quality exceeded my expectations. Would definitely
recommend to friends.
"""

Provide sentiment analysis and key themes.

Labeled Sections:

Compare these two code snippets for efficiency:

[CODE A]
def sum_list(numbers):
total = 0
for n in numbers:
total += n
return total

[CODE B]
def sum_list(numbers):
return sum(numbers)

Which is more efficient and why?

Common Input Delimiters​

Triple quotes: """content"""
Triple backticks: ```content```
XML tags: <input>content</input>
Square brackets: [INPUT] content [/INPUT]
Dashes: ---content---

Component 4: Output Format​

The output format specifies how you want the AI to structure its response.

Format Specifications​

Format TypeWhen to Use
Prose/ParagraphExplanations, stories, articles
Bullet PointsLists, features, quick scans
Numbered ListsSteps, rankings, sequences
TablesComparisons, structured data
CodeTechnical outputs
JSON/XMLProgrammatic processing
MarkdownFormatted documentation

Format Examples​

Requesting Bullet Points:

List the benefits of remote work.

Format: Bullet points (5-7 items)
Each point: One sentence with a brief explanation

Requesting a Table:

Compare Python and JavaScript for web development.

Format your response as a markdown table with columns:
| Aspect | Python | JavaScript |

Requesting JSON:

Extract information from this job posting and return as JSON:

{
"title": "",
"company": "",
"location": "",
"salary_range": "",
"required_skills": [],
"experience_years": ""
}

Putting It All Together​

Here's a complete prompt using all four components:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ INSTRUCTION β”‚
β”‚ Analyze the following customer feedback and provide β”‚
β”‚ actionable insights for our product team. β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ CONTEXT β”‚
β”‚ You are a customer experience analyst at a SaaS company. β”‚
β”‚ This feedback is from users of our project management tool. β”‚
β”‚ We're preparing for our Q1 product planning meeting. β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ INPUT β”‚
β”‚ """ β”‚
β”‚ Feedback 1: "Love the collaboration features but the β”‚
β”‚ mobile app is really slow." β”‚
β”‚ Feedback 2: "Can't figure out how to set recurring tasks." β”‚
β”‚ Feedback 3: "Great tool! Wish there was dark mode." β”‚
β”‚ Feedback 4: "Integration with Slack keeps breaking." β”‚
β”‚ Feedback 5: "The calendar view is confusing." β”‚
β”‚ """ β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ OUTPUT FORMAT β”‚
β”‚ Structure your response as: β”‚
β”‚ 1. Executive Summary (2-3 sentences) β”‚
β”‚ 2. Key Themes (bullet points) β”‚
β”‚ 3. Priority Recommendations (numbered, top 3) β”‚
β”‚ 4. Quick Wins vs Long-term Investments (table) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Component Checklist​

Use this checklist when crafting prompts:

☐ INSTRUCTION
☐ Clear action verb
☐ Specific task defined
☐ No ambiguity

☐ CONTEXT (as needed)
☐ Role/persona defined
☐ Audience specified
☐ Purpose stated
☐ Constraints listed

☐ INPUT (if applicable)
☐ Clearly delimited
☐ Properly formatted
☐ Complete information

☐ OUTPUT FORMAT
☐ Structure specified
☐ Length guidelines
☐ Style requirements

Common Mistakes​

Avoid These Errors

1. Missing Instruction

❌ "Customer feedback about our app"
βœ“ "Analyze this customer feedback and identify the top concerns"

2. Vague Context

❌ "You're an expert. Write about technology."
βœ“ "You are a cybersecurity consultant writing for small business owners with limited technical knowledge."

3. Unmarked Input

❌ Summarize: The product was good but shipping was slow
βœ“ Summarize the following review:
"""
The product was good but shipping was slow
"""

4. Missing Output Format

❌ "Tell me about the French Revolution"
βœ“ "Explain the causes of the French Revolution in 3-5 bullet points, each with one sentence of context"

Practical Exercise​

Exercise: Component Identification​

Identify the components in this prompt:

You are a nutritionist creating content for a health app
targeted at busy professionals.

Analyze the following meal plan and suggest improvements:

Breakfast: Coffee and a muffin
Lunch: Fast food burger and fries
Dinner: Frozen pizza
Snacks: Chips and soda

Provide your response as:
1. Current issues (bullet points)
2. Suggested improvements (numbered list)
3. Sample one-day meal plan (formatted schedule)
View Answer

Instruction: "Analyze the following meal plan and suggest improvements"

Context:

  • Role: Nutritionist
  • Purpose: Content for a health app
  • Audience: Busy professionals

Input: The meal plan (Breakfast through Snacks)

Output Format:

  1. Bullet points for issues
  2. Numbered list for improvements
  3. Formatted schedule for sample plan

Key Takeaways​

Summary
  1. Every prompt has four potential components: Instruction, Context, Input, Output Format
  2. Instructions should be clear, specific, and action-oriented
  3. Context provides the background needed for relevant responses
  4. Input should be clearly delimited and formatted
  5. Output Format specifications dramatically improve response usefulness
  6. Not every prompt needs all four components, but knowing when to use each is crucial

What's Next?​

In the next chapter, we'll explore types of prompts, including the powerful concepts of zero-shot and few-shot prompting.


← Back to Module 2 | Next: Types of Prompts β†’