Start with the real problem
A good prompt is like a complete recipe: it says what to make, which ingredients to use, which rules to follow, and what the finished result should look like.
A prompt can fail even when every sentence sounds clear, because one necessary ingredient—task, context, input, constraint, example, or output shape—was never supplied.
task + context + input + constraints + examples + output → complete request
What you will learn
- Identify the functional parts of a prompt.
- Separate instructions from the data being processed.
- Add only the context that changes the answer.
- Build a complete prompt from a short requirement.
How this connects to current AI systems
Modern GPT, Gemini, and Claude prompts commonly organize these ingredients with short headings or tags. Their APIs can also enforce output whose exact shape is safe for software to read.
1. Why This Module Exists
In Module 1, you saw that “better” prompts tend to answer three things: what exactly you want, who it’s for, and how it should look. This module breaks that down into clear, reusable building blocks — so instead of just having a feeling for “a good prompt,” you have an actual checklist you can use every time.
2. The Building Blocks, in Plain Language
Think of a prompt like a recipe card you hand to a helpful friend who’s going to cook for you. You wouldn’t just say “make dinner” — you’d naturally include a few things:
| Building block | In a recipe card… | In a prompt… |
|---|---|---|
| The task | “Make chicken stir-fry” | What you want the AI to do |
| Background info | “I’m allergic to peanuts” | Anything the AI needs to know to do it well |
| The ingredients | The actual chicken, rice, veggies | The actual content you want it to work with |
| An example | “Like the one we had at Mom’s” | Showing what “good” looks like |
| Rules | “Keep it under 30 minutes” | Limits it has to follow |
| How to serve it | “On a plate, not in a bowl” | What format you want the answer in |
None of these need fancy names to understand. Here’s the same idea, one more time, in the words this course will use going forward:
Task → What do you want done?
Background → What does the AI need to know?
Content → What is it actually working on?
Example → What should "good" look like?
Rules → What limits should it follow?
Format → How should the answer be delivered?
You don’t need all six every time — a quick, simple prompt might only need the task. But when a prompt isn’t working the way you want, it’s almost always because one of these six is missing.
[Trails] Analogy: The Contractor’s Work Order Form Think of structured prompt building like filling out a work order form for a home renovation project:
- Task (The Core Request): Paint the living room walls. (If you don’t say this, they won’t pick up a brush).
- Background (The Context): The room gets tons of direct natural sunlight. (Helps them choose heat-resistant or low-glare paints).
- Content (The Material): The walls are currently drywall plaster with an old cream coat. (They know if primer is needed).
- Example (The Standard): Here is a photo of the adjacent hallway color we like. (Gives them a precise color target).
- Rules (The Boundaries): Do not paint the baseboards, fireplace, or ceiling. (Avoids accidental damage).
- Format (The Delivery): Apply two coats of semi-gloss eggshell finish. (Gives the final appearance instructions).
📊 Visual Chart: The Six Blocks of Prompt Anatomy
Here is how the six building blocks fit together to shape a complete prompt:
graph TD
classDef main fill:#3498db,stroke:#333,stroke-width:1px,color:#fff;
Task["1. Task (Action requirement)"]:::main
Background["2. Background (Context details)"]:::main
Content["3. Content (Input material to work on)"]:::main
Example["4. Example (Ideal target demonstration)"]:::main
Rules["5. Rules (Constraints and boundaries)"]:::main
Format["6. Format (Expected output layout)"]:::main
Task --> PromptAssembly["Assembled Final Prompt Structure"]
Background --> PromptAssembly
Content --> PromptAssembly
Example --> PromptAssembly
Rules --> PromptAssembly
Format --> PromptAssembly
3. Before vs. After — Planning a Party
Weak Prompt
"Help me plan a party."
This only has one building block: the task. Everything else is left blank, so the AI has to guess: What kind of party? For how many people? What’s the budget? Indoor or outdoor?
Better Prompt
"I'm planning a 30th birthday party for my best friend. It'll be
outdoors in our backyard, for about 15 people, with a budget of $200.
She loves plants and cozy string lights. Give me:
1. A simple theme idea
2. A short shopping list
3. 3 easy snack ideas that don't need cooking"
Let’s spot each building block:
"I'm planning a 30th birthday party for my best friend."
→ TASK: what you want (party planning help)
"It'll be outdoors in our backyard, for about 15 people, with a
budget of $200. She loves plants and cozy string lights."
→ BACKGROUND: everything the AI needs to actually give useful,
specific advice instead of generic party tips
"Give me: 1. A simple theme idea 2. A short shopping list
3. 3 easy snack ideas that don't need cooking"
→ RULES + FORMAT: exactly what to include, and how many of each,
laid out as a numbered list so it's easy to read
Why does the second version work so much better? Not just because it’s “longer” — it’s better because every added sentence answers a question the AI would otherwise have to guess at: how big is the party, what’s the budget, what does she like, and exactly what should the answer include. Fill in those blanks yourself, and there’s much less room for the AI to guess wrong.
4. Each Building Block, One at a Time
Task
This is simply the action you want: write, explain, plan, fix, summarize, translate. Every prompt needs at least this much. “Help me with this” is not a task — “write a thank-you note” is.
Background
This is any information the AI needs to give you a useful, specific answer instead of a generic one. “For a 30th birthday party” and “she loves plants” are both background — they don’t change what you’re asking for (party ideas), but they change what kind of ideas make sense.
Content
This is the actual material you’re handing over — the essay you want proofread, the email you want rewritten, the résumé you want improved. If you’re not giving the AI anything to work on (just asking it to generate something from scratch), you may not need this block at all.
Example
Sometimes the easiest way to explain what you want is to show it instead of describe it. “Write a caption like this one: ‘Sunset chasing with my favorite people 🌅’” tells the AI the tone and style far more precisely than trying to describe “casual and warm” in words. Module 4 covers this idea — called few-shot prompting — in much more depth.
Rules
These are any limits the answer has to respect: “under 100 words,” “no swearing,” “must include a call to action,” “keep it under $50.” Rules tell the AI what to leave out, just as much as what to include.
Format
This is how you want the answer delivered: a numbered list, a short paragraph, a table, bullet points, a single sentence. Without this, the AI picks whatever seems reasonable — which might not match what you actually wanted.
5. More Quick Before-and-After Examples
Asking for a workout
Before: "Give me a workout."
After: "Give me a 20-minute home workout for a beginner with no
equipment. Focus on legs and core. List it as a simple
step-by-step routine with rest times."
Writing a complaint email
Before: "Write a complaint email."
After: "Write a firm but polite email to an airline about a delayed
flight that made me miss a connecting flight. I want a refund.
Keep it under 150 words."
Getting book recommendations
Before: "Recommend some books."
After: "Recommend 4 mystery novels similar to Agatha Christie, for
someone who enjoys slow-burn plots more than fast action.
Include a one-sentence reason for each pick."
A real example from a developer’s perspective
Say you’re building a feature that turns a customer’s product review into a short internal summary for the sales team. Watch the same six building blocks appear:
Before (missing several blocks):
"Summarize this review: [review text]"
After (all relevant blocks present):
"Task: Summarize the customer review below for the sales
team.
Background: The sales team only cares about product complaints
and feature requests, not general compliments.
Content: [review text]
Rules: Keep it to 1-2 sentences. Skip the summary entirely
and return 'No actionable feedback' if there's
nothing relevant to sales.
Format: Plain text, no greeting or sign-off."
Labeling each block explicitly like this (Task:, Background:, etc.)
is a real, common pattern in production prompts — it makes the prompt
easy to read, easy to update later, and easy for a teammate to
understand at a glance. Module 28 covers reusable prompt templates like
this one in depth.
A simple agentic AI example
The same six blocks show up in agent instructions too — just applied to behavior instead of a single piece of writing:
Task: You are a scheduling agent that books meeting rooms.
Background: Rooms can only be booked during business hours
(9am-6pm) and cannot be double-booked.
Content: The user's meeting request (time, duration, attendees).
Example: If asked "book a room for 3pm tomorrow, 30 minutes,"
check availability first, then confirm the booking
back to the user in one sentence.
Rules: Never book a room without checking availability first.
If no room is free, suggest the next available time
instead of failing silently.
Format: Always end with a one-line confirmation or a clear
explanation of why the request couldn't be completed.
Notice: this is the exact same six-block structure from Section 2 — task, background, content, example, rules, format — just now shaping an agent’s ongoing behavior rather than one single response. Module 19 covers this in much more depth.
6. How Is This Used in AI?
🤖 How Is This Used in AI?
Nearly every real, production-grade prompt — the kind running inside an app, a chatbot, or an agent — is structurally an assembly of these exact six blocks, often with some parts fixed by the developer (task, rules, format) and others filled in automatically per request (content, sometimes background). The party-planning and review- summarizing examples in this module use the identical structure — only the stakes and the audience change.
7. When Do You Actually Need All Six Blocks?
You almost never need all six for a quick, everyday request. Use this simple guide:
| If your request is… | You probably need… |
|---|---|
| Quick and common (“translate this sentence”) | Just the task |
| Personal or specific (“help me plan my trip”) | Task + background |
| About something you’re handing over (“fix this email”) | Task + content |
| Hard to describe in words (“write in this exact tone”) | Task + example |
| Something with real limits (a word count, a budget) | Task + rules |
| Going into an app, form, or document | Task + format |
8. Common Mistakes
Incorrect idea
Forgetting background info the AI has no way of knowing.
Why it is incorrect
If you ask “what should I wear to the party” without saying what kind of party, the weather, or the dress code, you’re leaving the exact same blanks the “weak prompt” above did.
Incorrect idea
Adding rules or details that don’t actually matter.
Why it is incorrect
Not every prompt needs a budget, a word count, and a tone specified — for a quick, casual request, that’s extra typing for no real benefit.
Incorrect idea
Mixing your instructions and your content together with no separation
Why it is incorrect
, especially for longer content like an essay or email you’re pasting in. It becomes hard for the AI (and for you!) to tell where the instructions end and the actual content begins. Module 7 covers a simple fix for this.
9. Limitations
Knowing the six building blocks helps you write more complete prompts, but it’s not a magic formula:
- Including all six blocks doesn’t guarantee a perfect result — the AI can still misunderstand, especially for really complex or unusual requests
- More blocks isn’t automatically better — as Section 7 notes, padding a simple request with unnecessary rules or background can waste effort without improving the result
- This module tells you what to include — it doesn’t yet tell you how to check whether your prompt is actually reliable across many different situations, not just the one you tried (that’s Module 20, Prompt Evaluation)
10. Quick Reference — The Whole Idea in One Diagram
Task -> What do you want done?
Background -> What does the AI need to know?
Content -> What is it actually working on?
Example -> What should "good" look like?
Rules -> What limits should it follow?
Format -> How should the answer be delivered?
Missing block -> a specific kind of ambiguity left unresolved
11. Prompts in Code — Calling an LLM
Here’s how the six building blocks from this module actually show up when calling an LLM through code — not just in a chat window.
Example 1 — Simple
A single, unstructured prompt string with just the task. No separation between components — everything is one blob of text.
import anthropic
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=300,
messages=[
{"role": "user", "content": "Summarize this document."}
]
)
print(response.content[0].text)
This works, but as Module 2 covered, it leaves every other building block (background, rules, format) up to guesswork.
Example 2 — Intermediate
The building blocks are now separated explicitly inside the prompt string, and the actual document is inserted as a variable — a first step toward a reusable prompt.
import anthropic
client = anthropic.Anthropic()
document_text = "..." # the actual document content
prompt = f"""Task: Summarize the document below for a software engineer.
Background: The reader wants to understand architecture, key
decisions, and risks — not a general overview.
Rules: Keep the summary under 150 words.
Format: Return 3 short bullet points.
Document:
{document_text}"""
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=300,
messages=[{"role": "user", "content": prompt}]
)
print(response.content[0].text)
Example 3 — Production Grade
The prompt is now a reusable template function — each building block is a separate parameter, so the same function can generate prompts for many different documents and audiences without rewriting the prompt each time. This is exactly the pattern real applications use (Module 28 covers prompt templates in full).
import anthropic
client = anthropic.Anthropic()
def build_summary_prompt(task, background, content, rules, output_format):
return f"""Task: {task}
Background: {background}
Rules: {rules}
Format: {output_format}
Content:
{content}"""
def summarize_document(document_text, audience="a general reader"):
prompt = build_summary_prompt(
task=f"Summarize the document below for {audience}.",
background="Focus on the most decision-relevant information.",
content=document_text,
rules="Keep the summary under 150 words.",
output_format="Return 3 short bullet points, no preamble.",
)
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=300,
messages=[{"role": "user", "content": prompt}],
)
return response.content[0].text
summary = summarize_document(document_text="...", audience="a software engineer")
print(summary)
Notice the progression: Example 1 has no structure at all, Example 2 makes the building blocks visible but hardcoded, and Example 3 turns them into reusable, swappable parameters — the same building blocks from Module 2, now doing real work inside an actual application.
When to use it—and when not to
Use it when:
- complex requests with several requirements.
- reusable application prompts.
Do not rely on it when:
- a one-line request already produces reliable results.
- extra sections add noise without changing behavior.
12. Interview Questions
Q: What are the core components of a well-structured prompt?
Ans: A prompt can be broken into up to six building blocks: the task (what you want done), background (context the AI needs to do it well), content (the material it’s acting on), examples (demonstrations of the desired output), rules (limits the output must respect), and format (how the response should be structured). Not every prompt needs all six — but each one that’s missing leaves a specific kind of ambiguity unresolved.
Q: How would you decide which components a given prompt actually needs?
Ans: I’d ask, for each component in turn, whether leaving it out creates real ambiguity for this specific request. A quick, common request (“translate this sentence”) may only need the task. A personal or open-ended request typically needs background. Anything with a real length, budget, or content limit needs rules. Anything feeding into an application, form, or document needs an explicit format. The goal isn’t to maximize components — it’s to resolve whatever ambiguity actually exists for that particular request.
Q: Why might adding more detail to a prompt sometimes make results worse, not better?
Ans: Extra detail that isn’t actually relevant to the task can dilute or even contradict the parts that matter, and simply adds more for the model to parse and weigh. If a request is really simple and unambiguous, padding it with unnecessary background, rules, or examples adds cost and complexity without resolving any real ambiguity — and can occasionally introduce new, unintended constraints the requester didn’t mean to impose.
13. What You Should Remember
- A prompt is made of a few simple building blocks: task, background, content, example, rules, format — not every prompt needs all six.
- Each block fills in a specific blank the AI would otherwise have to guess.
- When a prompt isn’t giving you what you want, ask yourself: which of these six blocks did I forget to include?
14. Quick Practice
Take this weak prompt: “Help me write a LinkedIn post.”
Try rewriting it using as many building blocks as make sense — what’s the post about, who’s your audience, how long should it be, what tone?
15. Next Step
Next: Module 3 — Zero-Shot Prompting — what happens when you give the AI just the task, with nothing else — when that’s totally fine, and when it starts to fall apart.
- Author
- TechByteByByte Editorial Team
- Reviewed by
- TechByteByByte Admin
- Published
- Last reviewed