Content sourced from official Anthropic documentation
1
Why use role prompting?
The right role turns Claude from a general assistant into a virtual domain expert. Benefits: Enhanced accuracy in complex scenarios, tailored tone (CFO brevity → copywriter flair), and improved focus within task requirements.
💡Experiment with roles! A 'data scientist' might see different insights than a 'marketing strategist' for the same data.
2
How to give Claude a role
Use the system parameter in the Messages API. Put the role there, and task-specific instructions in the user turn. This keeps the role persistent across the conversation.
API usage
import anthropic
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-opus-4-6",
max_tokens=2048,
system="You are a seasoned data scientist at a Fortune 500 company.",
messages=[
{
"role": "user",
"content": "Analyze this dataset for anomalies: <dataset>{{DATASET}}</dataset>"
}
]
)
Role goes in the system parameter. Task instructions go in the user message. This separation lets you swap tasks without changing the role.
3
Legal analysis: Role makes the difference
Without a role, Claude says 'the agreement seems standard.' With a role, it catches critical issues worth millions.
Contract review
[System] You are the General Counsel of a Fortune 500 tech company. We're considering this software licensing agreement for our core data infrastructure:
<contract>{{CONTRACT}}</contract>
Analyze it for potential risks, focusing on indemnification, liability, and IP ownership. Give your professional opinion.
Without role: 'the agreement seems standard.' With role: catches that indemnification could hold you liable for vendor's negligence, $500 liability cap is 'grossly inadequate,' and joint IP ownership could let vendor sell your proprietary algorithms.
4
Financial analysis: Generic vs. board-ready
Without a role, Claude gives a generic summary. With the right role, it delivers actionable, board-ready analysis.
Q2 financials
[System] You are the CFO of a high-growth B2B SaaS company. We're in a board meeting discussing our Q2 financials:
<data>{{FINANCIALS}}</data>
Analyze key trends, flag concerns, and recommend strategic actions. Our investors want aggressive growth but are wary of our burn rate.
Without role: 'financials look strong, maintain current course.' With role: flags SMB decline, recommends reallocating 20% of SMB budget to enterprise, defends R&D as critical for stickiness, sets Q4 deadline to monetize AI or cut R&D by 30%.