Skip to content
AgenticAIWiki
  1. Learn
  2. Part 2
  3. 11. Explicit criteria, roles and XML tags
  4. 11.3

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.
Hands-on labRuns in the Playground

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

  1. Read the shared role, question and facts.
  2. Add the on-call engineer and CFO audience lines, each with who reads it, what comes first and a limit.
  3. Run it: each prompt is checked for a reader line and an "At most" limit.
  4. Compare the three prompts side by side and note which words changed.
  5. 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}")
Quick checkThe same answer must suit a hospital's legal team. Which line helps most?
How sure are you?
Pick an answer and how sure you are