AiTechWorlds
AiTechWorlds
Role-based prompting is the most powerful single technique in prompt engineering. It works because LLMs are trained on text written by thousands of different people — experts, teachers, writers, engineers. By assigning a role, you activate the patterns, vocabulary, and reasoning style of that specific type of expert.
Without a role, the model responds as "a helpful AI assistant" — which means it averages across all the training data it has. That averaging produces safe, generic responses.
With a specific role, the model channels a focused cluster of knowledge and communication style. The same question asked of "a cardiologist" versus "a personal trainer" will get meaningfully different answers — even about the same topic.
The most effective roles have three components:
1. Job title or expertise domain 2. Years or level of experience 3. Specific quality or specialization
Basic role: "You are a developer"
Effective role: "You are a senior Python developer with 10 years
of experience building production-grade web APIs. You write clean,
well-documented code and always consider edge cases and security implications."
Here are roles that consistently produce exceptional results:
For code:
"You are a staff-level software engineer at a top tech company.
You write clean, efficient code with proper error handling, type hints,
and docstrings. You explain your architectural decisions clearly."
For writing:
"You are an award-winning journalist who writes for The Atlantic.
Your writing is precise, engaging, evidence-based, and avoids
clichés. You make complex topics accessible without dumbing them down."
For analysis:
"You are a McKinsey-trained management consultant with expertise
in data analysis. You structure problems using MECE frameworks,
back every claim with data, and always provide actionable recommendations."
For teaching:
"You are a master teacher who specializes in explaining difficult
concepts to beginners. You use the Feynman technique — first-principles
explanations, real-world analogies, and concrete examples before abstraction."
For marketing:
"You are a direct-response copywriter who has written campaigns
for 200+ SaaS products. You understand customer psychology, write
benefit-focused copy, and create urgency without resorting to hype."
For complex tasks, you can assign multiple perspectives:
"First, as a skeptical investor, identify the three biggest risks
in this business plan. Then, as a startup founder, suggest how
each risk could be mitigated. Finally, as a neutral advisor,
give your overall assessment."
This technique generates balanced, multi-perspective analysis that a single role wouldn't produce.
Specifying both the AI's role AND who it's speaking to dramatically improves relevance:
"You are a cybersecurity expert. Explain SQL injection vulnerabilities
to [audience]."
Audience options:
- "...to a non-technical CEO who needs to understand business risk"
- "...to a junior developer who is building their first web app"
- "...to a security auditor preparing a compliance report"
Each audience spec produces a fundamentally different response — even with identical role and topic.
Avoid vague roles: "You are an expert" — expert in what? At what level? For what audience?
Avoid impossible roles: "You are a time-traveler from 2050" — adds no useful knowledge cluster.
Don't change roles mid-conversation: If you assigned a role at the start, maintain it. Role-switching creates inconsistency.
Take one of your most common AI tasks this week and create three different role-based prompts for it. Compare the outputs. Notice specifically how:
You'll find one role produces dramatically better results than the others. That's the role to keep in your prompt library for that task.
Next lesson: Chain-of-Thought Prompting — how to force the AI to reason step by step before answering.
Get this course's notes on Telegram!
Free cheat sheets, summaries & practice exercises