Course එකට ආපසු

Role Playing

20 මිනිත්තු📖Lecture

🎯 Lesson Objectives

By the end of this lesson, you will:

  • Understand why assigning roles dramatically improves AI output
  • Know the four categories of roles and when to use each
  • Master role stacking for complex tasks
  • Have ready-to-use role templates for common scenarios

📖 The Power of Roles

Here's something fascinating: the same question asked with different roles produces completely different answers.

Why Roles Work

When you assign a role, AI:

  • Adjusts vocabulary — Uses appropriate terminology
  • Changes depth — More or less technical as needed
  • Shifts perspective — Teacher explains, expert delivers
  • Matches expectations — Professional output for professional roles

🔬 Same Question, Different Roles

Question: "How do I center a div in CSS?"

No Role
With Specific Roles
Generic response: 'There are several ways including margin: auto, flexbox, grid...'
Patient Teacher: 'Great question! Imagine your div is a picture you want to hang in the exact center of a wall. Here's the simplest way...'
Lists all options without guidance
Senior Developer: 'For modern browsers, use flexbox: display: flex; justify-content: center; align-items: center; on the parent.'
May overwhelm beginners
Code Reviewer: 'Your current approach works but has browser compatibility issues. Here's a more robust solution...'

The role completely changes the response style and usefulness!


📚 The Four Role Categories

1. 🎓 Expertise Roles

Purpose: Get professional-quality output with best practices

RoleBest For
"Senior frontend developer"Web development tasks
"Python expert"Python-specific coding
"Database architect"Database design questions
"Security specialist"Security-related code
"DevOps engineer"Deployment, infrastructure

Example:

You are a senior React developer with 10 years of experience. Create a reusable button component with TypeScript.

2. 👨‍🏫 Teaching Roles

Purpose: Get clear explanations and learning-focused responses

RoleBest For
"Patient coding teacher"Learning new concepts
"Tutor explaining to a 10-year-old"Very simple explanations
"Bootcamp instructor"Practical, hands-on guidance
"College professor"Thorough, academic explanations

Example:

You are a patient coding teacher who uses simple analogies. Explain what an API is to someone who has never programmed.

3. 🔍 Quality Roles

Purpose: Improve code quality and catch issues

RoleBest For
"Code reviewer"Finding bugs, improving code
"UX designer who codes"User-friendly interfaces
"Performance expert"Making code faster
"Clean code advocate"Readable, maintainable code

Example:

You are a code reviewer focused on best practices. Review this code and suggest improvements: [code]

4. 🎨 Style Roles

Purpose: Get specific tone, approach, or aesthetic

RoleBest For
"Minimalist developer"Simple, no-frills code
"Creative web designer"Visually interesting designs
"Practical engineer"No-nonsense, working solutions
"Encouraging mentor"Motivation and confidence

Example:

You are a minimalist developer who values simplicity. Create the simplest possible navigation bar using only HTML and CSS.

🎭 Role Decision Guide

Use this table to choose the right role:

If You Need...Use This Role
Code that works"Senior [language] developer"
Understanding a concept"Patient teacher"
Better code"Code reviewer"
Nice-looking design"UX designer who codes"
Simple solution"Minimalist developer"
Fast code"Performance expert"
Secure code"Security specialist"
Learning explanation"Tutor for beginners"

🔗 Advanced: Role Stacking

For complex tasks, combine multiple roles:

Role Stacking

Formula: "You are a [role 1] AND [role 2]"

This gets you the benefits of both perspectives!

Role Stacking Examples:

Builder + Explainer:

You are an expert React developer AND a patient teacher. First, create a toggle switch component. Then, explain each line like I'm a beginner.

Creator + Critic:

You are a web developer AND a code reviewer. First, create a login form. Then, review your own code and suggest improvements.

Designer + Developer:

You are a UX designer AND a frontend developer. Create a pricing table that is both visually appealing and well-coded.

📝 Activity: Role Comparison

Try this experiment to see roles in action:

Compare Role Responses

0/4

📋 Role Prompt Templates

Copy and use these templates:

For Building Features:

Building Template
You are a senior [technology] developer building a professional [project type]. Create [specific feature] that [does what].
ChatGPTClaude

For Learning:

Learning Template
You are a patient coding teacher who uses simple analogies. Explain [concept] to someone who has never programmed before. Include a real-world example.
ChatGPTClaude

For Code Review:

Code Review Template
You are a senior developer doing a code review. Review this code for: - Bugs or potential errors - Performance issues - Readability improvements - Best practice violations [paste code here]
ChatGPTClaude

For Design + Code:

Design + Code Template
You are a UX designer who also writes clean code. Create [UI element] that is both visually appealing and well-implemented. Use [technologies].
ChatGPTClaude

⚠️ Common Role Mistakes

❌ Mistake
✅ Fix
Role doesn't match task: 'Python expert' for CSS question
Use 'CSS expert' when asking about CSS
Role too vague: 'You are smart'
Be specific: 'Senior developer with performance expertise'
Conflicting roles: 'Minimalist who writes extensive docs'
Choose one focus per task
Forgetting role in follow-ups
Remind AI of role if responses drift

✅ Lesson Summary

Key Takeaways

  1. Roles dramatically change AI responses — Same question, different answers
  2. Four categories: Expertise, Teaching, Quality, Style
  3. Match role to task — Use the decision guide
  4. Role stacking combines benefits for complex tasks
  5. Be specific — "Senior React developer" not just "developer"

📝 Mini Quiz

📝 Check Your Understanding

1/3

Which role is best for learning a new concept?