02. Prompt Anatomy

Chapter 2 of 25 · 15 min

A complete prompt has five components: instructions, context, input data, output format specification, and constraints. Most prompts fail because they omit one or more of these.

Instructions tell the model what to do. They should be imperative sentences: "Extract," "Classify," "Rewrite." Avoid vague verbs like "handle" or "deal with."

Context provides background information the model needs. This includes domain knowledge, user history, or situational details. Without context, models assume generic scenarios.

Input data is the content to process. Always clearly delimit this from instructions. Models can mix your instructions with their interpretation of the data if boundaries are unclear.

Output format specification describes how you want the response structured. This is separate from instructions because format and task are distinct concerns.

Constraints limit acceptable outputs. These include "do not include," "limit to," or "exclude."

INSTRUCTIONS: Classify the sentiment of each review as POSITIVE, NEGATIVE, or NEUTRAL.

CONTEXT: You are analyzing customer feedback for a coffee subscription service. Reviews mention product quality, delivery speed, and customer service.

INPUT DATA:
1. "Arrived on time, beans are fresh" - Rating: 5 stars
2. "Package was damaged but company sent replacement quickly" - Rating: 4 stars
3. "Tastes like burnt cardboard" - Rating: 1 star

OUTPUT FORMAT: Return a JSON array where each item has "review", "sentiment", and "confidence" fields. Confidence is a decimal between 0 and 1.

CONSTRAINTS: Only use the three sentiment labels. Do not infer sentiment from the star rating—use the text content only.

This prompt is verbose but produces consistent results. The verbosity is a feature: it reduces ambiguity.

A common failure is burying constraints in the instructions. "Classify sentiment (do not use the rating)" mixes the task with a constraint. Separating them prevents the model from treating constraints as secondary.

EXERCISE

Take a prompt from your current work and identify which of the five components are present and which are missing. Rewrite it to include all five.