Parts of a Good Prompt

The Five Components

Every strong prompt can be broken down into five parts. Not every prompt needs all five — simple tasks can work with just a task instruction — but missing any relevant component forces the model to guess, and its guess often does not match what you needed.

01

Task — the core instruction; what action the model should take

02

Context — background the model needs to produce a relevant response

03

Format — how the output should be structured

04

Constraints — limits on length, tone, audience, and scope

05

Examples — demonstrations of what good output looks like

Task

The task is the core instruction. It tells the model what action to take. A strong task includes an action verb, the subject, and any necessary qualification.

Weak task

"Write about AI."

No action specificity. No format. No scope. The model defaults to a generic overview of unknown length and depth.

Strong task

"Write a 3-sentence explanation of what AI is for a high school student."

Action verb (write), subject (AI), format (3 sentences), audience (high school student). Every element is specified.

Common Task Verbs

Write — generate text from scratch.
Summarize — condense existing content.
Classify — assign a category or label.
Extract — pull specific information from text.
Translate — convert between languages.
Explain — make a concept understandable.
Fix / Debug — correct errors in code or text.

Context

Context is the background the model needs to produce a relevant, calibrated response. The model only knows what is in the prompt — it cannot infer your situation, your audience, or your purpose.

Examples of Useful Context
  • "I am preparing a presentation for non-technical executives." — calibrates vocabulary and depth
  • "The user is a 10-year-old learning to code for the first time." — calibrates reading level and analogies
  • "This is customer feedback from a B2B SaaS product." — calibrates domain assumptions
  • "The code is written in Python 3.11 and uses the FastAPI framework." — calibrates technical specifics

Without context, the model produces a response calibrated to the average case. With context, it produces a response calibrated to your case.

Format

Format tells the model how to structure its output. Without a format instruction, the model defaults to prose paragraphs of variable length. With a format instruction, you get exactly the structure your use case requires.

01

Structured data — "Return a JSON object with keys: name, description, score" — essential for any programmatic pipeline

02

Lists — "Use a numbered list" or "Return bullet points" — useful for scannable, actionable output

03

Tables — "Write in a markdown table with columns: Feature, Pros, Cons" — useful for comparisons

04

Code only — "Return only the corrected code, no explanation" — strips prose when you need raw output

Constraints

Constraints narrow the output space by setting limits the model must respect. Without them, the model defaults to a verbose, neutral register that may not fit your use case.

Type of constraint

Length: "In under 100 words." / "In exactly three sentences."

Tone: "Use a professional, formal tone." / "Keep it conversational."

Audience: "Assume the reader has no prior knowledge of statistics."

Scope: "Focus only on Python 3. Do not mention Python 2."

Why constraints help

Without length constraints, models tend to over-explain. Without tone constraints, they default to a generic professional voice.

Without audience constraints, they pitch at an assumed middle level that may not match your reader.

Without scope constraints, they cover adjacent topics you didn't ask for.

Examples

Examples are the most powerful component. Showing the model what you want — before asking for it — is more reliable than describing it in words. This technique is called few-shot prompting.

Why Examples Beat Descriptions

A prompt that says "classify this review as positive or negative" may produce varying output formats: sometimes "Positive", sometimes "The sentiment is positive", sometimes a full explanation. A prompt that shows three labeled examples first will produce the exact label format almost every time. Demonstration is clearer than description.

Putting It Together

A Complete Prompt Example

Task: Classify the following customer review as Positive, Neutral, or Negative.
Context: These are reviews from a mobile app. Users are often brief.
Format: Return only the label — one word.
Constraint: Do not explain your reasoning.
Examples:
Review: "Love it! Works great." → Positive
Review: "App crashes every morning." → Negative
Review: "Does what it says, nothing more." → Neutral
Now classify: "Not bad, updated version fixed most issues."

This prompt has all five components. Each one eliminates a class of ambiguity that would otherwise lead to inconsistent output.

Summary

Key Takeaways
  • Task is the core action — include an action verb, subject, and qualification
  • Context gives the model the background it cannot infer from the task alone
  • Format specifies the output structure — critical for programmatic use cases
  • Constraints set limits on length, tone, audience, and scope
  • Examples are the most reliable way to control output format and style
  • Not every prompt needs all five, but missing relevant components forces the model to guess

Need Help?

Ask the AI if you need help understanding the five components of a good prompt, how to write strong task instructions, why context matters, how to specify output format, or when to use examples in a prompt.