RACE Framework for Prompt Engineering: 10 Examples That Get Results
Master the RACE framework for prompt engineering with 10 real-world examples. Learn Role, Action, Context, Expectations to write better AI prompts.

RACE Framework for Prompt Engineering: The Complete Guide
RACE is the framework I use for roughly 80% of my prompts. If you have ever pasted a prompt into ChatGPT or Claude and gotten a response that felt generic, unfocused, or just off, the problem probably was not the AI. It was the prompt. RACE framework prompt engineering gives you a repeatable four-part structure (Role, Action, Context, Expectations) that eliminates guesswork and produces consistently useful outputs.
I have tested RACE across hundreds of real projects: marketing copy, code reviews, data analysis, hiring workflows, and more. This guide walks through exactly how each component works, shows you 10 full prompts you can copy and adapt, and compares RACE to other popular frameworks so you can pick the right tool for the job.
For a quick-reference version of the framework itself, see the RACE framework page. This tutorial goes deeper, focusing on practical examples, common mistakes, and when RACE outperforms alternatives.
What Is the RACE Framework?
RACE stands for Role, Action, Context, Expectations. Each letter represents one part of a well-structured prompt:
- Role: Who should the AI become? A senior data analyst, a pediatric nurse, a tax attorney? The more specific the role, the more specialized the output.
- Action: What exactly do you want done? Analyze, write, compare, debug, summarize? Use precise verbs.
- Context: What background information does the AI need? Audience, constraints, data, industry, prior decisions.
- Expectations: What should the output look like? Format, length, tone, quality criteria, structure.
Why Four Components Instead of One Long Instruction?
Writing a single paragraph prompt works for simple questions. But for anything that matters (a deliverable for a client, a technical analysis, a content draft), ambiguity kills quality. RACE eliminates the three most common failure modes:
- Vague identity: Without a Role, the AI defaults to a generic assistant voice. Giving it a specific professional identity activates domain-appropriate vocabulary, reasoning patterns, and standards.
- Unclear task: Without a clear Action, the AI guesses what you want. "Help me with marketing" could mean a hundred things. "Write three subject lines for a cart-abandonment email sequence" is one thing.
- Missing guardrails: Without Expectations, you get whatever format and length the AI decides. You end up re-prompting three times to get the structure you needed from the start.
How to Write Each RACE Component
Role: Be Specific About Expertise
Bad: "You are a marketing expert."
Better: "You are a senior growth marketer with 8 years of experience in B2B SaaS, specializing in product-led growth and free-to-paid conversion funnels."
The more specific the role, the better. Include years of experience, industry focus, methodology preferences, or certifications when relevant. This is not role-playing for fun; it is a mechanism that activates the right knowledge domain in the model.
Action: Use Precise Verbs
Avoid vague verbs like "help," "assist," or "do something about." Instead, use verbs that specify exactly what output you expect:
- Analyze: Break down data, identify patterns, draw conclusions
- Compare: Evaluate two or more options against specific criteria
- Draft: Write a first version of a specific document
- Audit: Review against a standard and flag issues
- Prioritize: Rank items using stated criteria
Context: Give Only What Matters
Context is not "tell the AI everything." It is telling the AI the specific facts that change the answer. If you are asking for a marketing plan, the AI needs to know your budget, audience, and timeline, but it does not need your company's founding story.
Ask yourself: "If I gave this task to a human expert, what background would they need to do it well?" That is your Context.
Expectations: Define the Finish Line
This is where most people stop too early. Expectations should cover:
- Format: Bullet points, numbered list, table, prose, code block
- Length: Word count, number of items, level of detail
- Tone: Technical, conversational, formal, persuasive
- Quality criteria: What makes the output good vs. mediocre
- Constraints: What to avoid, what to prioritize
10 Real-World RACE Examples
Here are 10 complete RACE prompts across different use cases. Each one is tested and ready to customize. For more prompt templates, check out our collections of best ChatGPT prompts and best Claude prompts.
Example 1: SaaS Landing Page Copy
Role: You are a senior conversion copywriter who specializes in B2B SaaS landing pages with a track record of improving signup rates by 20-40%.
Action: Write the hero section copy (headline, subheadline, and CTA button text) for a project management tool landing page.
Context: The product is called "FlowBoard." It targets engineering teams of 10-50 people who currently use Jira but find it too complex. The key differentiator is AI-powered sprint planning that reduces planning meetings by 60%. Free trial available, no credit card required.
Expectations: Provide 3 headline variations (under 10 words each), a subheadline for each (under 25 words), and CTA text. Use a clear, confident tone: no hype words like "revolutionary" or "game-changing." Focus on the pain point of wasted time in planning meetings.Example 2: Technical Code Review
Role: You are a principal software engineer with 15 years of experience in Python backend development, specializing in API design and performance optimization.
Action: Review the following Python function and identify bugs, performance issues, and violations of clean code principles.
Context: This function is part of a high-traffic REST API (10K requests/minute) that processes user payment transactions. It runs on Python 3.12 with FastAPI and SQLAlchemy. The team follows PEP 8 and uses type hints throughout the codebase.
def process_payment(user_id, amount, currency="USD"):
user = db.query(User).filter(User.id == user_id).first()
if user.balance >= amount:
user.balance = user.balance - amount
transaction = Transaction(user_id=user_id, amount=amount, currency=currency, status="completed")
db.add(transaction)
db.commit()
return {"status": "success", "new_balance": user.balance}
return {"status": "failed", "reason": "insufficient funds"}
Expectations: List each issue with severity (Critical/High/Medium/Low), explain why it matters in a production context, and provide the corrected code. Address concurrency, error handling, and type safety at minimum.Example 3: Market Research Analysis
Role: You are a senior market research analyst at a top-tier consulting firm with deep expertise in the consumer health technology sector.
Action: Analyze the competitive landscape for a new AI-powered sleep tracking app and identify the top 5 market opportunities.
Context: The app uses phone microphone data (no wearable required) to analyze sleep patterns and provide personalized improvement recommendations. Target market is health-conscious adults 25-45 in the US. Main competitors include Sleep Cycle, Oura Ring, and Whoop. Budget for launch marketing is $50K. Planned price point is $4.99/month or $39.99/year.
Expectations: Structure your analysis as: (1) Competitor comparison table with features, pricing, and user ratings, (2) Five specific market opportunities ranked by potential impact, (3) For each opportunity, include estimated market size, competitive intensity score (1-5), and a recommended go-to-market tactic. Keep the total analysis under 1000 words.Example 4: Email Sequence for Onboarding
Role: You are a customer success strategist who specializes in SaaS user onboarding with expertise in behavioral email design and activation metrics.
Action: Write a 5-email onboarding sequence for new users who signed up but have not completed their first project.
Context: The product is a design collaboration tool for remote teams. Average time from signup to first project is 3 days for activated users. The main activation barrier is that users do not invite teammates: 73% of churned users never added a second team member. The brand voice is friendly, direct, and slightly playful (similar to Slack's tone).
Expectations: For each email provide: subject line (under 50 chars), preview text (under 90 chars), body copy (under 150 words), single CTA, and suggested send timing (hours after signup). Each email should address one specific behavioral trigger. Include A/B test suggestions for subject lines.Example 5: Data Analysis Report
Role: You are a senior data analyst with expertise in e-commerce analytics, specializing in customer retention and cohort analysis.
Action: Create a quarterly business review summary from the following metrics and identify the three most actionable insights.
Context: Q4 2025 metrics for an online pet supply store: Revenue $2.3M (up 12% QoQ), AOV $67 (down 5%), Customer acquisition cost $34 (up 18%), Repeat purchase rate 41% (down from 47%), Email open rate 22% (steady), Cart abandonment 71% (up from 65%), Top category growth: premium dog food +28%, Top category decline: pet accessories -15%, NPS score 52 (down from 58).
Expectations: Structure as an executive summary (3 sentences), then three insight sections. Each insight should include: the data point, why it matters, what is causing it (hypothesis), and one specific recommended action with expected impact. Use clear business language, not technical jargon. Include a simple markdown table summarizing KPIs with QoQ change and a red/yellow/green health indicator.Example 6: Job Interview Questions
Role: You are a senior engineering manager at a Series B startup who has conducted 200+ technical interviews and built engineering teams from 5 to 40 people.
Action: Design a structured interview question set for a mid-level frontend developer position focused on React and TypeScript.
Context: The role requires someone who can work independently on complex UI features, mentor junior developers, and contribute to architectural decisions. The team uses React 19, TypeScript, Tailwind CSS, and Next.js. Past hiring mistakes have included candidates who could solve algorithm puzzles but struggled with real-world component design and state management.
Expectations: Provide 8 questions organized into three categories: (1) Technical depth: React and TypeScript, (2) System design: component architecture, (3) Collaboration and mentoring. For each question include: the question text, what good/great/red-flag answers look like, and a follow-up probe. Avoid textbook algorithm questions. Focus on practical scenarios.Example 7: Content Strategy Brief
Role: You are a content strategy director with 10 years of experience in organic growth for technology brands, specializing in SEO-driven content that converts.
Action: Create a 90-day content plan for a developer tools company that wants to increase organic traffic by 40%.
Context: The company sells an API testing platform. Current organic traffic is 25K monthly visits, primarily from bottom-funnel product comparison pages. They have zero top-of-funnel educational content. The engineering team can contribute technical blog posts but needs detailed outlines. Main competitors (Postman, Insomnia) dominate "API testing" keywords. Domain authority is 35.
Expectations: Deliver the plan as a table with columns: week number, content title, target keyword, estimated search volume, content type (tutorial/guide/comparison/case study), funnel stage, and assigned writer (marketer vs. engineer). Include 12 pieces of content total. Prioritize keywords where the company can realistically rank within 90 days given the DA of 35. Add a brief rationale section explaining the keyword strategy.Example 8: Bug Report Triage
Role: You are a QA engineering lead with expertise in web application testing, specializing in systematic bug triage and root cause analysis for production issues.
Action: Triage the following list of user-reported bugs and create a prioritized fix schedule for the next two-week sprint.
Context: The application is a React-based project management tool with 5,000 daily active users. The team has 3 frontend and 2 backend developers available. Current sprint capacity is roughly 40 story points. Recent deployment was a migration from REST to GraphQL for the task endpoints.
Bug reports:
1. Tasks disappear when dragging between columns on Kanban board (15 reports)
2. Profile photo upload fails silently for files over 2MB (3 reports)
3. Due date picker shows wrong month after timezone change (7 reports)
4. Notification bell count does not reset after viewing (22 reports)
5. Export to CSV includes deleted tasks (4 reports)
6. Search returns results from archived projects (8 reports)
Expectations: For each bug provide: severity (P0-P3), estimated story points, likely root cause based on the recent GraphQL migration context, and recommended assignee (frontend or backend). Then provide a sprint plan that fits within the 40-point capacity, with justification for what gets deferred. Use a markdown table for the triage summary.Example 9: Financial Model Assumptions
Role: You are a startup CFO with experience building financial models for Series A through Series C fundraising rounds in the SaaS industry.
Action: Review and stress-test the following revenue projection assumptions for a pitch deck financial model.
Context: The company is a B2B SaaS platform for restaurant inventory management. Current ARR is $600K with 120 customers. Average contract value is $5K/year. Monthly churn is 3.5%. The founder projects growing to $3M ARR in 18 months by hiring 4 additional sales reps (currently 2) and launching a self-serve plan at $99/month. CAC payback is currently 14 months. The company has $1.2M in runway remaining.
Expectations: Identify the three most questionable assumptions with specific reasoning. For each, provide: why it is risky, what a more conservative estimate would be, and how it changes the 18-month ARR projection. Then provide a simple scenario table showing optimistic, base, and conservative cases for ARR at months 6, 12, and 18. Flag any assumption that would concern a Series A investor.Example 10: Technical Documentation
Role: You are a senior technical writer with expertise in API documentation, specializing in developer experience and documentation-driven adoption for developer tools.
Action: Write the getting-started guide for a new webhook management API that developers will integrate into their existing applications.
Context: The API allows developers to register webhook endpoints, manage retry logic, and monitor delivery status through a dashboard. It supports REST and has SDKs for Node.js, Python, and Go. Authentication uses API keys. The typical integration takes under 30 minutes. Target audience is mid-level backend developers who understand HTTP but may not have worked with webhooks before.
Expectations: Structure as: (1) Overview paragraph (what the API does and why), (2) Prerequisites checklist, (3) Step-by-step integration with code examples in Node.js, (4) Testing your first webhook section, (5) Common troubleshooting issues. Keep it under 800 words. Use a friendly but professional tone. Include curl commands alongside SDK examples. Every code block should be copy-paste ready with placeholder values clearly marked.5 Common RACE Mistakes (and How to Fix Them)
After coaching dozens of people on structured prompting, I see the same mistakes repeatedly. Here is how to avoid them. For more on avoiding common pitfalls, see our guide on advanced prompt engineering techniques.
Mistake 1: Roles That Are Too Broad
"You are a marketing expert" tells the AI almost nothing. Marketing covers brand strategy, performance ads, email, SEO, social, content, PR, and a dozen other specialties. A "growth marketer specializing in PLG free-to-paid conversion" activates a much more specific knowledge set.
Fix: Add specialty, years of experience, and industry focus to every Role.
Mistake 2: Actions Without Measurable Output
"Help me improve my resume" is not an action; it is a wish. What does "improve" mean? Rewrite bullet points? Add metrics? Reformat for ATS scanning? Tailor for a specific role?
Fix: Use verbs that produce a specific deliverable: rewrite, audit, compare, draft, prioritize, calculate.
Mistake 3: Context Overload
Pasting your entire company wiki into the Context defeats the purpose. More context is not always better. Irrelevant context actually degrades output quality because the model has to decide what matters.
Fix: Include only the facts that would change the answer if they were different. Budget, audience, constraints, timeline, prior decisions: that is usually enough.
Mistake 4: Missing Expectations Entirely
This is the most common mistake by far. People craft a great Role, Action, and Context, then leave Expectations blank. The AI picks a random format and length. You spend another three prompts trying to reshape the output.
Fix: At minimum, specify format (bullets, table, prose), length (word count or number of items), and tone. Add quality criteria when the task is important.
Mistake 5: Treating RACE as a Rigid Template
Some people type "Role:" and "Action:" as literal labels in every prompt. You do not have to do that. RACE is a mental checklist, not a fill-in-the-blank form. A natural paragraph that covers all four elements works just as well as labeled sections.
Fix: Use labels when the prompt is complex (500+ words). For shorter prompts, weave the four elements into natural language.
RACE vs Other Prompt Frameworks
RACE is not the only structured prompting framework worth knowing. Here is how it compares to three popular alternatives. For a broader comparison, check out our guide on the best AI prompt frameworks in 2026.
RACE vs TAG
The TAG framework uses three components: Task, Action, Goal. TAG is simpler: it skips the explicit Role and folds context into the Task definition.
| Aspect | RACE | TAG |
|---|---|---|
| Components | 4 (Role, Action, Context, Expectations) | 3 (Task, Action, Goal) |
| Best for | Complex, multi-step tasks | Quick, straightforward tasks |
| Role assignment | Explicit | Implicit |
| Output control | Detailed (format, length, criteria) | Basic (goal-oriented) |
| Learning curve | Moderate | Low |
When to use TAG instead: When your prompt is simple enough that a role is unnecessary and you just need to specify what and why. TAG is great for one-shot tasks like "Summarize this article in 3 bullet points for a non-technical audience."
When RACE wins: Anything where domain expertise matters: technical writing, financial analysis, code review, medical information, legal drafts. The explicit Role component consistently improves output quality for specialized tasks.
RACE vs ROSES
The ROSES framework stands for Role, Objective, Scenario, Expected Solution, Steps. It adds a Scenario component and breaks the output into Expected Solution and Steps, which makes it more prescriptive about the solution path.
| Aspect | RACE | ROSES |
|---|---|---|
| Components | 4 | 5 |
| Best for | Flexible, high-quality outputs | Step-by-step procedural tasks |
| Flexibility | High: the AI decides the approach | Lower: you guide the approach |
| Prompt length | Moderate | Longer |
| Output structure | You define in Expectations | Built into the framework |
When to use ROSES instead: When you already know the general approach and want the AI to execute a specific workflow with defined steps. ROSES works well for standard operating procedures and process documentation.
When RACE wins: When you want the AI to bring its own expertise to the problem. RACE gives more room for creative or analytical solutions because the Expectations component defines what good output looks like without dictating how to get there.
RACE vs COSTAR
The COSTAR framework uses six components: Context, Objective, Style, Tone, Audience, Response. COSTAR is the most granular of the common frameworks, splitting what RACE handles in Expectations into Style, Tone, Audience, and Response as separate fields.
| Aspect | RACE | COSTAR |
|---|---|---|
| Components | 4 | 6 |
| Best for | Balanced structure and flexibility | Content creation and writing tasks |
| Role handling | Explicit first component | Implicit via Style and Tone |
| Audience awareness | Part of Context | Dedicated component |
| Prompt length | Moderate | Longer |
When to use COSTAR instead: Content-heavy tasks where tone, style, and audience are critical dimensions: blog posts, marketing copy, social media content. The separate Audience component forces you to think carefully about who will read the output.
When RACE wins: Technical and analytical tasks where the professional Role matters more than writing style. If you are asking for a code review, a financial analysis, or a legal opinion, the Role component in RACE gives you more leverage than COSTAR's style-focused breakdown.
Quick Decision Guide
- Simple, one-shot tasks: Use TAG
- Technical or analytical work: Use RACE
- Writing and content creation: Use COSTAR
- Process and procedure documentation: Use ROSES
Tips for Getting More From RACE
Stack RACE With Follow-Up Prompts
RACE works best as the opening prompt in a conversation. Once you have established the Role, the AI maintains that persona for subsequent messages. Your follow-up prompts can be shorter; just add new Actions and Context as needed.
Adjust Detail Level by Task Importance
Not every prompt needs a 200-word RACE structure. For low-stakes tasks, a single sentence covering all four elements works fine:
As a senior editor (Role), proofread this email (Action) that I'm sending to our enterprise client about a delayed feature launch (Context) and flag any tone issues, keeping it under the same word count (Expectations).For high-stakes deliverables, expand each component into its own paragraph with specific details.
Use RACE Across Different AI Models
RACE works with every major language model: GPT-4, Claude, Gemini, Llama, and others. The structure is model-agnostic because it addresses a fundamental problem (prompt ambiguity) rather than exploiting model-specific features. That said, Claude responds particularly well to the explicit Role component, and GPT-4 tends to follow detailed Expectations more precisely.
Start Using RACE Today
The fastest way to improve your AI outputs is to stop typing the first thing that comes to mind and start using a structure. RACE is simple enough to memorize (four letters, four components) but powerful enough to handle complex professional tasks.
Here is how to begin:
- Pick one task you regularly use AI for: an email draft, a code review, a research summary.
- Write a RACE prompt for that task using the examples above as a template.
- Compare the output to what you normally get with unstructured prompts.
- Save your best RACE prompts as templates for reuse.

Keyur Patel is the founder of AiPromptsX and an AI engineer with extensive experience in prompt engineering, large language models, and AI application development. After years of working with AI systems like ChatGPT, Claude, and Gemini, he created AiPromptsX to share effective prompt patterns and frameworks with the broader community. His mission is to democratize AI prompt engineering and help developers, content creators, and business professionals harness the full potential of AI tools.
Related Articles
Explore Related Frameworks
A.P.E Framework: A Simple Yet Powerful Approach to Effective Prompting
Action, Purpose, Expectation - A powerful methodology for designing effective prompts that maximize AI responses
COAST Framework: Context-Optimized Audience-Specific Tailoring
A comprehensive framework for creating highly contextualized, audience-focused prompts that deliver precisely tailored AI outputs
RACE Framework: Role-Aligned Contextual Expertise
A structured approach to AI prompting that leverages specific roles, actions, context, and expectations to produce highly targeted outputs
Try These Related Prompts
Unlock Hidden Prompts
Discover advanced prompt engineering techniques and generate 15 powerful prompt templates that most people overlook when using ChatGPT for maximum results.
Absolute Mode
A system instruction that enforces direct, unembellished communication focused on cognitive rebuilding and independent thinking, eliminating filler behaviors.
Security Code Auditor
Adversarial-first security code review prompt for Claude Opus 4.7. 5-phase audit with OWASP Top 10, CWE Top 25, and CVSS 3.1 output. Paste code, get patch-ready findings with exploit scenarios and test cases.

