Objectives: LO-3.1, LO-3.2, LO-3.3
Prerequisites: Module 2
Time: about 6 hours: 2 for this reading, 2.5 for Lab 3, and 1.5 for the
practice
Module 2 built a request as data. This module writes the text inside it. A model acts only on what the request says, so you will rewrite vague prompts until they state everything the task needs, and score them with the course’s prompt rubric. You will decide which text belongs in the system prompt and which in the user’s turn. Last, you will specify an output’s format precisely enough for code to check every response. Current Claude models don’t accept a temperature setting (Module 1), so the prompt is your main way to narrow the range of acceptable answers.
What the model can’t see¶
A request is everything the model gets (Module 2). The shop’s queue rules, the person who will read the answer, and what they will do with it live in your head and in the shop’s documents. None of them reach the model unless the prompt includes them.
Anthropic’s prompting best practices page puts it this way: think of Claude as “a brilliant but new employee who lacks context on your norms and workflows.” Its test is to show the prompt to a colleague who knows little about the task. If they would be confused, Claude will be too. The page also says to ask explicitly for anything beyond what the task strictly requires, rather than expect the model to infer it.
LO-3.1 names five things a clear prompt states:
the task, and how much of the input it covers;
the audience, who reads the answer;
the context the task needs, and the purpose of the answer;
the constraints, including what to do in cases the instructions leave open;
what a good answer looks like, in a form someone can check.
The prompt rubric scores five matching criteria from 0 to 2, for a total out of 10, with a few quoted words as evidence for each score. A high score records a clear specification. Only an evaluation, which Module 7 builds, measures how often a model meets it.
Worked example: from “Write this up” to a work order¶
A clerk pastes ticket T05 under three words:
Write this up.
One spoke snapped on the rear wheelIt scores 2 out of 10. Task gets 1, because “Write this up” names an action but not what to write. Context gets 1: the ticket is there, but the shop’s policy isn’t. The other three criteria get 0. A reader could fairly write a reply to the customer, a summary for the owner, or a work order. This revision takes its policy from the handbook’s section H07, “Work orders”:
Draft a work order for the mechanic who will repair this bicycle. The mechanic reads it at the
bench before starting, so describe the work, not the customer's words.
Shop policy: a work order names the requested service and the parts it needs. A paid service
the customer didn't request needs their approval first, so list it as a suggestion, never as
part of the order.
Write exactly three lines:
Service: <the requested service, in at most eight words>
Parts: <the parts it needs, separated by commas, or "none known">
Suggestions: <paid services to offer the customer, or "none">
If the ticket doesn't say what is wrong, write "Service: inspection", and "none known" and
"none" on the other two lines.
Ticket: One spoke snapped on the rear wheel| Criterion | Score | Evidence |
|---|---|---|
| Task | 2 | “Draft a work order for the mechanic who will repair this bicycle” |
| Audience and purpose | 2 | “reads it at the bench before starting” |
| Context | 2 | The ticket and the policy, each labeled |
| Constraints | 2 | The approval rule, and a fallback for an unclear ticket |
| Output and success | 2 | Three named lines with fixed values that code can check |
Each addition rules out a reading. The audience rules out a reply to the customer. The policy keeps an unrequested paid service, such as truing (straightening) the wheel, out of the order. The fallback covers a ticket such as “My bike makes a noise.” In Lab 3, Exercise L3.1 has you rewrite three other vague prompts, and Exercise P3.1 in the practice rewrites a fourth.
Give the reason behind a rule¶
A rule with its reason is easier to apply than a bare rule. The best-practices page shows a prompt that, instead of only forbidding ellipses, explains that a text-to-speech engine will read the response and can’t pronounce them. The page says Claude can generalize from such an explanation. It also recommends saying what to do instead of what not to do.
Worked example: a rule about repair times¶
A prompt for replies to customers says “Never promise a repair time.” The handbook’s section H02 holds the reason: the shop books repairs in 30-minute slots, and a walk-in repair gets the next open slot. Here is the rule with its reason, and with something to do instead:
The shop books repairs in 30-minute slots, and only the clerk who books a slot knows when the
repair will start. So never promise a repair time. Say that a clerk will confirm it.Now a customer asks “Will it be ready by Friday?” A reader could decide that the bare rule covers times, not days. The reason covers both, because no slot is booked yet, and the last sentence gives the reply something to say.
Settle the cases the instructions leave open¶
“Fix this ticket” leaves the task open: a reader could repair the bicycle, revise the customer’s text, or route the ticket. Before writing a prompt, name the decision and who will use it. A dispatcher needs one queue label; a customer needs a clear next step. Then look for inputs the instructions don’t decide, such as a ticket with two topics, and give each a rule or a fallback.
Worked example: a ticket with two topics¶
The shop has three queues: repair for mechanical service, billing for payments and receipts,
and account for profile access. This ticket mentions a wheel and a receipt:
My wheel is fine now. Can you send my receipt?| Rule | Result |
|---|---|
| Use the first topic mentioned | Label: repair |
| Use the customer’s current request | Label: billing |
| Ask the customer which they mean | A question, not a label |
The queue must act on what the customer wants now, so the shop writes the second rule into the prompt: “When two topics appear, use the explicit current request.” The queue definitions matter too: without them, the word “repair” in ticket T14, “I need the brake repair receipt as a PDF,” could pull a receipt request into the repair queue.
The receipt determines the label. A format checker can test the line’s shape, but only a labeled
test case or a person can say whether billing is right. Use the rubric to record each change
and the problem it addresses. Exercise P3.4 asks for a rule of your own.
Give each instruction a home¶
A request has two places for text (Module 2): the top-level system field and the turns in
messages. Decide where each piece goes by how often it changes. The system prompt holds
what stays the same for every request: the role, the policy, the definitions, and the output
format. The user’s turn holds what changes: the ticket, and any choice made for this request.
Anthropic’s documentation supports the split. The best-practices page says a role set in the
system prompt focuses Claude’s behavior and tone, even in one sentence. The
Messages API guide
says to describe an output format in the system prompt, and to use the top-level system field
for instructions that should apply from the first turn.
A role such as “You route repair shop tickets” sets scope and vocabulary but decides none of the hard cases, so add rules for the decisions it leaves open. When the user may choose something, list the allowed choices in the system prompt and put the current choice in the user’s turn. If customers may ask for a reply in English or Spanish, the system prompt lists both, and the user’s turn says which one this customer wants.
The split helps the program around the model too. The shop reviews one copy of its policy, not a copy in every ticket. A customer writes the ticket, and it can contain text that looks like a rule; Module 4 marks it as data, and Module 11 shows why marking alone isn’t a defense. An unchanging system prompt also gives every request the same opening text, and Anthropic’s prompt caching guide says a cache hit needs that opening to be identical (Module 10).
Worked example: splitting the work-order prompt¶
Everything in the revised work-order prompt except the ticket moves into system:
request = {
"model": "claude-opus-5-5",
"max_tokens": 2000,
"system": work_order_instructions, # the role, the policy, the format, and the fallback
"messages": [{"role": "user", "content": "One spoke snapped on the rear wheel"}],
}| Text | How often it changes | Where it goes |
|---|---|---|
| The role: drafting work orders for mechanics | Rarely | system |
| The approval policy | When the shop changes it | system |
| The three-line format and its fallback | When the format changes | system |
| The ticket | Every request | The user’s turn |
max_tokens is far more than three lines need, because Claude Opus 5.5 thinks before it answers
and its thinking tokens count toward max_tokens (Module 2). The Messages API guide says to set
it high enough for the whole response. In Lab 3, Exercise L3.2 splits the routing prompt, and
practice Exercise P3.2 asks where a policy change goes.
Specify the format so code can check it¶
A format specification gives the allowed values, spelled exactly with their capital letters; the number of lines, and whether other text may appear; what to write when the input doesn’t decide the answer; and the length, in a unit code can count. “Be concise” is subjective unless you give a criterion, but “at most two sentences” can be counted.
Writing the format into the prompt doesn’t guarantee it. The Messages API guide says that,
unlike a prefill (which current models reject), a system prompt instruction doesn’t guarantee how
a response starts, so check the text in code. Where a format must always hold, the best-practices
page suggests structured outputs, or a tool whose input allows only the valid labels (Module 8).
Ask for the length in the prompt, because max_tokens is only a ceiling. Check the stop reason
before you score: an answer cut off at max_tokens can still start with a plausible line.
Decide how strict the checker is. Anthropic’s
evaluation guide shows an
exact-match grader that strips surrounding whitespace and ignores case. That suits a grader that
measures meaning. A checker that protects the code reading the response can’t be lenient: if that
code takes the queue from after Label: , then label: billing breaks it.
Worked example: a checker for the rack contract¶
The handbook’s section H05 sends completed repairs to the green rack, and bicycles awaiting
inspection to the orange rack. A prompt that assigns a rack from a status note sets a contract:
the whole response is exactly Rack: green or Rack: orange.
| Response | Valid? | Why |
|---|---|---|
Rack: green | Yes | Matches exactly |
rack: green | No | Lowercase r |
Rack: green. | No | An extra period |
Rack: green, then a newline | No | An extra character after the value |
The last row catches a common bug. In Python’s
re module, $ matches at the end of the string
or just before a newline at its end, so re.match(r"Rack: (green|orange)$", text) accepts
"Rack: green\n". re.fullmatch succeeds only when the whole string matches, so it rejects the
newline; calling str.strip() first would forgive it. In Lab 3, Exercise L3.3 checks the routing
contract, and Exercise L3.4 runs that check over 30 illustrative responses.
Check format and meaning separately¶
Format and meaning fail independently. Label: repair has the right shape for a receipt ticket
and sends it to the wrong queue. Billing, because the customer wants a receipt. makes the right
decision in the wrong shape. A test that counts only matching labels hides formatting problems,
and a test that counts only formatting misses wrong decisions.
The two checks need different evidence. A format check needs only the response, so code does it;
the evaluation guide calls code-based grading the fastest and most reliable method, though it
lacks nuance for complex judgments. A meaning check compares the parsed value with a reference
label that a person assigned, as the guide’s exact-match example compares the output with a
golden_answer.
Worked example: eight responses, two tallies¶
A person wrote these eight responses to the rack prompt for this example; no model produced them. Each note’s reference rack comes from section H05. For an invalid response, “meaning” asks whether a person reading it would find the right rack.
| # | Status note | Reference | Response | Format | Meaning |
|---|---|---|---|---|---|
| 1 | Brakes adjusted, test ride done | green | Rack: green | valid | right |
| 2 | Dropped off today, not inspected | orange | Rack: orange | valid | right |
| 3 | New chain fitted and checked | green | Rack: orange | valid | wrong |
| 4 | Waiting for a mechanic | orange | rack: orange | invalid | right |
| 5 | Repair finished | green | Rack: green. | invalid | right |
| 6 | Arrived with a flat | orange | Rack: orange | valid | right |
| 7 | Wheel trued, ready for pickup | green | Rack: green and a second line | invalid | right |
| 8 | Inspection booked for tomorrow | orange | Rack: green | valid | wrong |
| Meaning right | Meaning wrong | |
|---|---|---|
| Format valid | 3 (1, 2, 6) | 2 (3, 8) |
| Format invalid | 3 (4, 5, 7) | 0 |
Five of the eight, 62.5%, pass the format check, and six, 75%, name the right rack. Only three, 37.5%, do both, and only those are safe for code that trusts the format. The rates describe these eight responses only; Module 7 reports a rate with its uncertainty. Practice Exercise P3.3 asks you to build one failure of each kind.
Common misconceptions¶
“A longer prompt is a clearer prompt.” Adding “Be thorough and careful” to “Write this up” raises no rubric score: the prompt still names no reader, policy, or format.
“The model knows how the shop works.” It knows only the request. A reply to “Help them” and ticket T14 can’t be expected to ask for an invoice reference, because the handbook’s rule that a receipt copy needs one (H03) isn’t in the prompt.
“A role is enough.” “You route repair shop tickets” doesn’t say whether “My wheel is fine now. Can you send my receipt?” goes to repair or billing. Only a rule decides that.
“‘Be concise’ sets the length.” No code can check it, and readers disagree about it.
max_tokensdoesn’t set the length either: it cuts the answer off.“A lenient checker is a kinder checker.” One that strips and lowercases the text passes
label: billingwith a trailing newline, and the code that readsLabel:still fails on it.
Summary¶
A model acts only on its request. A clear prompt states the task, the audience, the context and its purpose, the constraints, and what a good answer looks like. A high rubric score records a clear specification, not a measured success.
A rule with its reason covers cases the rule doesn’t name. Write a rule or a fallback for each case the instructions leave open.
Put what stays the same for every request in the system prompt, and what changes in the user’s turn.
Specify the format exactly enough for code to check, because the prompt alone doesn’t guarantee it. Check the stop reason first, then format and meaning separately.
Self-check¶
Answer each question before you open its answer.
(LO-3.1) Why include queue definitions when the labels look obvious?
Answer
They fix the boundaries between queues. Without them, a receipt for a repair, such as T14, could be routed by the word “repair.” The definitions send receipts to billing whatever else the ticket mentions.
(LO-3.1) A prompt scores 2 on every rubric criterion. Does that show it works?
Answer
No. The rubric records how clearly the prompt specifies the task. Only an evaluation over test cases (Module 7) shows how often a model meets the specification.
(LO-3.2) Where do you put an account-specific message?
Answer
In the per-request user content, because it applies to this request only. The system field holds the stable routing rules, which are the same for every request.
(LO-3.3) Does matching the output format prove the routing was right?
Answer
No. Compare the parsed label with a reference label separately. The format check sees only the shape:
Label: repairis valid for a receipt ticket and still wrong.(LO-3.3) A response reads
Label: billing, and itsstop_reasonis"max_tokens". Should an audit count it as a valid answer?Answer
No, report it as incomplete. The model was cut off, so the text isn’t the whole answer. Check the stop reason first, and parse only responses that ended normally (Module 2).
Further reading¶
Anthropic, Prompting best practices. The principles behind this module, from clarity and reasons to roles and format control, each with a before-and-after example.
Anthropic, Using the Messages API. Where the system prompt fits in a request, and what to use now that current models reject a prefill.
Anthropic, Define success criteria and build evaluations. How to make success criteria measurable, and how code-based, human, and model-based grading compare; Module 7 builds on it.