ASAmol Shukla
Projects
Courses
Prompts
Skills
Contact
Resume
Course Outline
Syllabus Overview

AI Tools: LLM & Prompt Engineering Mastery

Courses/AI Tools: LLM & Prompt Engineering Mastery/Lesson 16: The Anatomy of an Effective Prompt
45 mins lesson duration•9 mins read

Lesson 16: The Anatomy of an Effective Prompt

Role, context, task, format, constraints — the five building blocks that turn vague requests into precise instructions.

Why Prompts Are the UI of AI

An LLM is a brilliant, literal assistant: it does exactly what you say, not what you mean. Prompt engineering is translating your intention into instructions the model cannot misunderstand.

The Five Building Blocks

Block Purpose Example
Role Who should the model be? "You are a senior tax consultant…"
Context What does the model need to know? "I run a freelance design business in India…"
Task What exactly should it do? "Draft a client follow-up email…"
Format How should the output look? "A table with columns: Task, Deadline, Status"
Constraints What must it avoid/respect? "Under 150 words, no jargon, no promises you can't keep"

Not every prompt needs all five — but the more complex the task, the more you need them.

Bad vs. Good Prompt

Bad: "Write about marketing."

Good:

You are a marketing strategist for small B2B SaaS companies.

I sell project-management software to agencies with 10-50 staff.
Our differentiator is AI-powered time tracking.

Write a 300-word LinkedIn post announcing our new AI time-tracking
feature. Target: agency owners who hate manual timesheets.

Format: hook line, 3 short paragraphs, call to action.
Tone: confident but not salesy. No emojis. No hashtags.

System vs. User Messages

  • System prompt: persistent instructions for the whole conversation ("You are a helpful code reviewer…"). Set it once; it steers everything.
  • User message: the current request, with task-specific details.

This separation is how chat apps keep behavior consistent across many turns.

Common Prompting Mistakes

Mistake Fix
Too vague ("make it better") Say exactly what "better" means
No output format State table / JSON / bullets / length
Burying the ask Put the task early and repeat it at the end
Assuming knowledge Give the model the facts it needs
One-shot and giving up Iterate — prompting is a loop

The Iteration Loop

  1. Write the prompt → 2. Run it → 3. Notice what's wrong → 4. Fix the prompt → 5. Repeat. Keep a prompt library: save the versions that work, with notes on why.

Key Takeaways

  • Five blocks: Role, Context, Task, Format, Constraints.
  • System prompt = persistent rules; user prompt = the specific ask.
  • Be concrete, state the format, and iterate instead of giving up.
  • Save working prompts — you'll reuse them constantly.

Next up: Zero-shot, few-shot, and chain-of-thought — the core techniques.

Interactive Lesson Code Snippet
# Build a prompt from reusable parts (the "anatomy" of a prompt)
role = "You are a senior data analyst specializing in business metrics."
context = "Our SaaS startup tracks monthly active users (MAU) and churn."
task = "Analyze the churn trend and suggest one action to reduce churn."
format_rule = "Respond with: (1) Trend, (2) Likely cause, (3) One action."
constraints = "Keep it under 120 words. No jargon."

prompt = f"""{role}

CONTEXT: {context}

TASK: {task}

FORMAT: {format_rule}

CONSTRAINTS: {constraints}"""

print(prompt)
Language: python

Lesson Code (Python)

# Build a prompt from reusable parts (the "anatomy" of a prompt)
role = "You are a senior data analyst specializing in business metrics."
context = "Our SaaS startup tracks monthly active users (MAU) and churn."
task = "Analyze the churn trend and suggest one action to reduce churn."
format_rule = "Respond with: (1) Trend, (2) Likely cause, (3) One action."
constraints = "Keep it under 120 words. No jargon."

prompt = f"""{role}

CONTEXT: {context}

TASK: {task}

FORMAT: {format_rule}

CONSTRAINTS: {constraints}"""

print(prompt)

Console Output

You are a senior data analyst specializing in business metrics.

CONTEXT: Our SaaS startup tracks monthly active users (MAU) and churn.

TASK: Analyze the churn trend and suggest one action to reduce churn.

FORMAT: Respond with: (1) Trend, (2) Likely cause, (3) One action.

CONSTRAINTS: Keep it under 120 words. No jargon.

Code Visualization Tips

  • 🧠Draw the prompt as a labeled diagram: 5 color-coded blocks (role, context, task, format, constraints).
  • 🧠Put bad vs. good prompts side by side and annotate what each block adds.
  • 🧠Sketch the system/user split as two layers over one conversation.

Professional Tips & Tricks

  • ⚡Start prompts with the ROLE line — it measurably changes output quality.
  • ⚡Put the most important instruction last: models weight the end of the prompt heavily.
  • ⚡Version your prompts like code (v1, v2) and note what changed and why.

Python Code Judge & Practice Arena

LeetCode Style

Run real Python 3.12 WebAssembly code directly in your browser against automated test suites.

Solved:0 / 1
0 / 10 XP
Challenges:
Problem 1 of 1

Rewrite a Vague Prompt

Easy+10 XP
Rewrite 'Tell me about SEO' using all five building blocks: role, context, task, format, constraints.
main.pyPython 3.12 (WASM)
1
2
3
4
5
6
7
8
9
10
11
12
Press Run Code to test or Submit to verify test cases

Test Your Knowledge

Instant feedback

Quick Check: Anatomy of an Effective Prompt

1 / 3
Which five blocks make up an effective prompt?

Up next · Continue learning

Zero-Shot, Few-Shot & Chain-of-Thought

The three core techniques every prompt engineer reaches for — and when to use each one.

10 mins read50 mins
Start next lesson
Previous: Evaluating LLM SystemsNext: Zero-Shot, Few-Shot & Chain-of-Thought
Made withbyAmol Shukla·amolshukla.online
ASAmol Shukla

AI Developer, Trainer & Agentic AI Expert building practical learning systems and real-world AI applications.

Explore

  • Projects
  • Courses
  • Prompts
  • Skills
  • Contact
  • Experience
  • Blogs

Connect

  • Resume
  • Contact
© 2026 Amol Shukla·Created withbyamolshukla.online
Back to top