Menu

Role Prompting: Personas and "Act As" Prompts

Role prompting gives the model a part to play, such as a tutor, a code reviewer or an interviewer. A role changes who the answer is written for and what standard it meets; it does not add knowledge the model lacks.

Every prompt below is editable: change it, then open it in ChatGPT, Claude or another AI app.

Role prompting means telling the model who to be before you tell it what to do: "You are a patient math tutor", "Act as a hiring manager for a junior developer job". The role changes who the answer is written for, which words it uses, how deep it goes and what it pays attention to. It does not give the model knowledge it does not already have: a role is a way to steer an answer, not a way to add facts.

What a role changes

A role is a compact way to set several things at once:

  • The audience and vocabulary. A tutor for beginners defines terms and uses analogies; a senior engineer writing for peers skips both.
  • The standard. A strict editor flags a sentence a friendly reader would let pass. The role decides what counts as a problem.
  • The focus. A security reviewer and a performance reviewer read the same function and notice different things.
  • The behavior. An interviewer asks questions and waits; a tutor can be told to give hints instead of answers.

Switch between the three tabs below. The task is identical in each; only the role changes.

Parts
Explain what an API is in under 80 words.
Try it
Example replyReplies vary between models and runs.

An API (Application Programming Interface) is a set of rules that lets one piece of software talk to another. It defines what requests you can make, how to make them and what you get back. For example, a weather app uses a weather service's API to fetch the forecast. APIs let developers use features and data from other systems without knowing how those systems work inside.

"You are an expert" barely moved the answer: it kept the same generic shape and added jargon, because "expert" says nothing about who is reading. The specific role changed the vocabulary, the example and the reference point, because it named an audience and something that audience already knows.

What a role does not change

A role cannot add knowledge. "You are a world-class tax lawyer" does not give the model this year's tax rules if it never learned them, and a confident persona can make a wrong answer sound more authoritative, not less. Do not count on an expert label to improve accuracy. If correctness matters, give the model the facts or documents it needs and ask it to say when it is unsure; AI hallucination covers prompts that help.

The same goes for real people. "Answer as a famous programmer would" gets you an imitation of that person's public style. The model does not know their private opinions, so anything it says in their voice about a new question is invented.

Write specific roles

A useful role usually names four things: the job, the audience, the goal and the standard. Compare:

  • "You are a writer" becomes "You are an editor at a technical blog who cuts any sentence that does not help a beginner follow the steps."
  • "You are a programmer" becomes "You are a senior Python developer reviewing a junior colleague's pull request. Point out bugs first, then readability, and explain each point so they can learn from it." See prompts for code review for full review prompts.
  • "Act as a teacher" becomes "Act as a chemistry teacher preparing a 15 year old for an exam. Ask me questions instead of giving answers, and give a hint when I get one wrong."

A role is one part of a prompt, not the whole prompt. It works together with a clear task, the context the model cannot guess and the shape of the answer you want; the guide to writing prompts covers the other parts. If the role and the task pull in different directions, such as "a strict reviewer" asked to "reassure the author", the reply tries to do both and often does neither well.

"Act as" prompts for practice

The "act as" form became popular through shared prompt collections, where the model plays a job interviewer, a language partner or even a Linux terminal. Role-play is useful for anything you want to rehearse: interviews, a hard conversation, a presentation, a new language.

The difference between a role-play that works and one that falls apart is the rules. Tell the role what to do on each turn, when to wait for you, and when to stop. Without them, the model may run the whole session in one reply: five questions at once, or a question followed by a sample answer.

Mock job interview
Fill in
Act as an interviewer hiring a junior frontend developer. Ask me one question at a time about JavaScript and CSS and wait for my answer. After each answer, give two sentences of feedback, then ask the next question. Start easy and get harder. After five questions, stop and give me an overall assessment with the one thing I should practice most.
Try it
Example replyReplies vary between models and runs.

Great, let's begin. I'll start with a fundamentals question.

Question 1: In JavaScript, what is the difference between let, const and var?

Take your time and answer as you would in a real interview.

Change the job and the topic to rehearse your own interview. The line "wait for my answer" is what keeps the model to one question per turn, and "after five questions, stop" gives the session an end and a summary.

Where the role goes

A role you want in every reply belongs in the system prompt: the system field in the API, or custom instructions and project instructions in the chat apps. There, it applies to the whole conversation without being repeated. For a one-off request, put the role in the first sentence of your message, before the task.

import anthropic

client = anthropic.Anthropic()
MODEL = "your-model-id"  # e.g. from your provider's model list

message = client.messages.create(
    model=MODEL,
    max_tokens=500,
    system="You are a patient programming tutor for adults in their first month of coding. Give hints before full solutions.",
    messages=[{"role": "user", "content": "Why does my loop print the last item twice?"}],
)
print(message.content[0].text)

Roles also work mid-conversation. After the model drafts something, asking it to "now act as a skeptical reviewer of the draft above and list its three weakest points" often surfaces problems the first pass glossed over, because the new role changes what the model is looking for.

Frequently Asked Questions

What is role prompting?

Role prompting is telling the model who to be before telling it what to do, for example "You are a patient math tutor for 12 year olds" or "Act as an interviewer for a junior developer job." The role shapes the reply's audience, vocabulary, depth and focus, and in a conversation it can change how the model behaves, such as asking questions instead of answering them.

Does telling the AI it is an expert make it more accurate?

Do not count on it. A label like "You are a world-class expert" does not give the model knowledge it lacks, and it can make a wrong answer sound more confident. To improve accuracy, give the model the facts or sources it needs, ask it to say when it is unsure, and check the result.

Where should I put the role?

For a role that should last the whole conversation, put it in the system prompt: the system field in the API, or custom instructions and project instructions in the chat apps. For a one-off request, put it in the first sentence of your message, before the task.

What are "act as" prompts?

They are prompts that start with "Act as" and give the model a part to play: an interviewer, a language partner, a Linux terminal, a travel guide. Shared prompt collections made the pattern popular. They work best when they also say what the role should do on each turn and when to stop.

What makes a good role prompt?

Specificity. Name the job, the audience, the goal and the standard: "a senior Python developer reviewing a junior colleague's pull request, bugs first, then readability" gives the model far more to work with than "an expert." Then write the rest of the prompt as usual: the task, the context and the format.

Coddy programming languages illustration

Learn to code with Coddy

GET STARTED