Domain 4 · Prompt Engineering & Structured Output
Anatomy of a prompt
A great prompt isn't clever wording — it's structure. Claude responds best to clearly
separated parts: a role and task, context marked off with XML tags, explicit criteria,
and (optionally) a prefill to shape the start of the answer. Assemble a prompt block by block and
watch a vague request turn into a reliable one.
system prompt / roleXML tags
explicit criteriaprefill
be clear & direct
Explain like I'm 10
Imagine asking a super-smart but very literal helper to do something. If you mumble "make this better," they
have no idea what "better" means. But if you say "
You're a careful editor. Here's the story
[between these fences]. Fix only spelling. Don't change the plot," they nail it. Prompting is just
putting your request in clearly-labelled boxes so nothing is left to a guess.
Build the prompt — toggle each part on
Start with a bare instruction and switch on each technique. Watch the prompt grow more reliable, and read
why each part helps:
The order that works
- Role / system prompt — set who Claude is acting as ("a meticulous financial analyst"). Goes in the
system parameter, not the user turn.
- Task, stated as explicit criteria — say exactly what to do and what "good" looks like. Replace
vague adjectives ("concise", "professional") with checkable rules ("≤ 3 bullets", "no jargon").
- Context, in XML tags — wrap documents/data in tags like
<transcript>…</transcript>
so Claude can tell your data from your instructions. Put long documents before the
question.
- Examples (few-shot) — show 1–3 input→output pairs for anything ambiguous (its own explainer).
- Prefill — start Claude's reply for it (e.g.
{ or <analysis>) to lock
the format.
Exam trap: the winning answers favour explicit, checkable criteria over
vague adjectives, and XML tags to separate instructions from data. "Be more detailed/professional" is a
distractor — it isn't measurable. Also: the role belongs in the system prompt, and long
context goes before the question, not after.
Takeaways: structure beats cleverness. Set a role in the system prompt,
state the task as explicit criteria (not vague adjectives), wrap data in XML tags so Claude
separates instructions from content, add few-shot examples for ambiguity, and use a prefill to
lock the output format. Put long documents before the question.
Curated companion: Anthropic — Prompt engineering guide.