Lesson 11.3 · 3 of 7 · 4 min read · Reviewed 24 Nov 2026
Roles and audience
By the end, you can
- Use roles to set expertise and tone.
- Write for a named audience.
Roles
Putting a role in the system promptSystem prompt: Instructions passed in the top-level system field that set the model’s role, rules and context for the whole conversation., such as “You are a senior data engineer reviewing pipeline designs”, shifts what Claude notices and how it explains. It’s most useful when the task needs a particular lens: a security reviewer spots different things from a performance reviewer.
Audience
Saying who will read the output often matters more than the role:
- “for a new hire on their first day”: define terms, short steps.
- “for the on-call engineer at 3 a.m.”: the fix first, the cause later.
- “for the CFO”: cost and risk, no code.
Combine them
A role plus an audience plus explicit criteriaExplicit criteria: Concrete, checkable rules in a prompt that define what a good answer is, instead of vague words like "good" or "concise". is a strong start:
You are a security reviewer. The readers are backend developers.
Report only exploitable issues, each with the line and a fix.
A role alone, such as “You are an expert”, adds little. Expert at what, for whom?
Key points
- A role in the system prompt sets the perspective and expertise Claude writes from.
- Naming the audience shapes vocabulary, depth and length more than almost any other line.
- Roles work best combined with explicit criteria, not instead of them.
Write one answer for three audiences
Build three system prompts that share a role and facts but name different audiences with checkable limits.
You will have: Three system prompts, each passing a check for an audience line and a length limit, and a simulated reply for each.
Steps
- Read the shared role, question and facts.
- Add the on-call engineer and CFO audience lines, each with who reads it, what comes first and a limit.
- Run it: each prompt is checked for a reader line and an "At most" limit.
- Compare the three prompts side by side and note which words changed.
- Write down how you would grade each reply against its own audience line.
Done when
- The script prints 3 prompts built.
- Each audience prints with its prompt length.
- No prompt fails the reader and limit check.
Open in the Playground No API key needed.
Starter code (Python)
import anthropic
client = anthropic.Anthropic() # simulated
ROLE = "You are a data engineer explaining an incident."
QUESTION = "Why did last night's sales data load fail?"
FACTS = "Facts: the upstream export timed out, so sales_0412.csv never arrived; the nightly load stopped; no data was lost; a re-run is queued."
AUDIENCES = {
"new hire": "Readers are new hires on their first day. Define any term you use. At most 4 short sentences.",
# TODO: add "on-call engineer": who reads it, what comes first, and a length limit.
# TODO: add "CFO": who reads it, what to cover and leave out, and a length limit.
}
def system_prompt(audience_line):
return f"{ROLE}\n{audience_line}\nOnly use these facts. {FACTS}"
prompts = {name: system_prompt(line) for name, line in AUDIENCES.items()}
print(f"{len(prompts)} prompts built")
for name, prompt in prompts.items():
assert "Reader" in prompt and "At most" in prompt, name
reply = client.messages.create(model="claude-sonnet-5-5", max_tokens=200, system=prompt,
messages=[{"role": "user", "content": QUESTION}])
text = "".join(b.text for b in reply.content if b.type == "text")
print(f"audience: {name} | prompt {len(prompt)} chars | reply starts: {text[:70]!r}")
Show a solution
import anthropic
client = anthropic.Anthropic() # simulated
ROLE = "You are a data engineer explaining an incident."
QUESTION = "Why did last night's sales data load fail?"
FACTS = "Facts: the upstream export timed out, so sales_0412.csv never arrived; the nightly load stopped; no data was lost; a re-run is queued."
AUDIENCES = {
"new hire": "Readers are new hires on their first day. Define any term you use. At most 4 short sentences.",
"on-call engineer": "Reader is the on-call engineer at 3 a.m. Give the fix first, then the cause. At most 3 lines.",
"CFO": "Reader is the CFO. Cover business impact and risk only, no code or file names. At most 3 sentences.",
}
def system_prompt(audience_line):
return f"{ROLE}\n{audience_line}\nOnly use these facts. {FACTS}"
prompts = {name: system_prompt(line) for name, line in AUDIENCES.items()}
print(f"{len(prompts)} prompts built")
for name, prompt in prompts.items():
assert "Reader" in prompt and "At most" in prompt, name
reply = client.messages.create(model="claude-sonnet-5-5", max_tokens=200, system=prompt,
messages=[{"role": "user", "content": QUESTION}])
text = "".join(b.text for b in reply.content if b.type == "text")
print(f"audience: {name} | prompt {len(prompt)} chars | reply starts: {text[:70]!r}")