Programming AI with Personas · scripted
Programming AI with Personas
Review of instructing AI
When we write a prompt, we are giving AI instructions about work we want it to perform. A program is a set of instructions that tells a computer what to do with information.
We can write a very simple program in ordinary language.
From now on, whenever I give you a number, double it. Reply with only the result. If you understand, say ready.
Ready.
7
14
23
46
We gave AI an instruction first. Then we gave it new information to process. The same instruction can be used again with different inputs.
Sometimes we do not know the instructions, and we do not have examples of what the correct work should look like. Many problems are not as simple as doubling a number, where we know exactly what to tell AI, or have examples handy to teach it what the right result looks like. We may know the outcome we want without knowing the process, and without having a single finished example to show.
The persona prompt pattern
In the real world, we often solve a problem by finding or hiring the right person to do the work. If you need a nutrition plan created for your eating habits, you might hire a nutritionist. With AI, we often need to do the same thing: hire the right AI to do the work.
A persona is a description of the person, thing, system, or role we want AI to pretend to be when it does the work. It might describe a software engineer, a professor of computer science, or an executive chef specializing in Uzbek cuisine.
If we tell AI to act as a nutritionist, it will perform the work differently than if we tell it to act as a gourmet chef. We will get very different recipes. We are describing who or what it should act like when it does the work, which changes how it does the work and what it does.
Giving AI a persona is another way of instructing it what to do. The instruction is telling it how to act. If I tell you to act like a clown, I do not have to give you any more instructions. You know what clowns do. When we give AI a persona, it does the same thing, except it knows how many more things act, far beyond clowns. AI has learned the patterns of how a nutritionist plans a meal, how a lawyer reads a contract, how a dog reacts to a doorbell, and how a vending machine responds to a coin. A persona tells it which of those patterns to use.
The Persona Prompt Pattern is specific language we give AI to instruct it to use a persona when doing the work.
We typically begin with:
Act as [description of the person, thing, or system]
For example:
Act as a software engineer.Act as a professor of computer science.Act as an executive chef specializing in Uzbek cuisine.Act as a conscientious computer programmer who cares about cybersecurity.
When we use a persona, our instructions are not telling AI exactly what to do. They are describing who or what it should act like. We are not explaining how to program or how to search for security issues. We are describing the persona AI should use to decide its actions when doing the work. AI draws on the patterns it has learned about how that persona approaches situations and performs work. We do not have to write out every rule.
The persona does not even have to be a person.
Act as our dog, Pepper. Communicate with me the way Pepper would. A squirrel just sat down on the porch railing and is looking at you through the window.
Woof! WOOF! (runs to the window) (jumps up, front paws on the sill) (nose smudge on the glass) Woof! (tail going so fast the back half of me is going too) (looks at you) (looks at the squirrel) (looks at you) WOOF. (the squirrel has not moved) (whines) (runs to the door) (runs back to the window) (the squirrel is eating something) (the squirrel is eating something IN FRONT OF ME) WOOF WOOF WOOF (looks at you again, because you have hands and hands open doors) (lies down under the window, one ear up, staring at the sill) (waiting) (I can wait) (I cannot wait) Woof.
We never told AI how a dog thinks or what a dog says. One word, “dog,” brought in everything it has learned about barking, jumping at windows, and wanting doors opened. It did not answer in sentences a person would write. It answered in barks and actions, because that is how a dog communicates.
The next persona cannot bark, and cannot talk at all.
Act as a roll of toilet paper. Communicate to me the way a roll of toilet paper would. 2 + 2 =
.-""""""""-.
/ .------. \
| ( ) |
| '------' |
\____________/
| |
| |
| |
|- - - - |
| |
| |
| |
|- - - - |
| |
| |
| |
|- - - - |
| |
| |
| |
'--------'
AI did not write the number 4. A roll of toilet paper has no voice and no pen, so AI answered the only way a roll of toilet paper can: it unrolled four sheets. It understood the arithmetic, understood the persona, and understood that the persona changes not just what is said but how anything can be said at all. That is the whole idea of a persona: a short description that carries a large pattern of behavior with it, including how the thing communicates.
That pattern can be small or enormous. In this lesson we will see personas do three different kinds of work:
- A persona can be an operation. “Act as a skeptic” is a way of saying: challenge my assumptions. We are not asking for a character. We are asking for something to be done to our idea.
- A persona can be a way of structuring. “Act as a scientist” makes AI take whatever we give it and turn it into hypotheses, experiments, and evidence. The persona decides the shape of the answer.
- A persona can be a whole experience. “Act as an arcade machine” makes AI draw a screen, remember the state of a game, obey controls, and tell us what happened, all in words and symbols. The persona becomes the thing itself, including its interface.
The first two are useful. The third is where it gets strange, and we will end there.
Role-based personas
There are many ways to specify the persona we want AI to take on. One is to think about the role or job title we want it to take on when performing the work. It is almost like writing a job description for the AI.
A role persona represents the job or perspective we want AI to bring to the problem.
Let’s look at two conversations about the same problem. The only thing we change is the role.
Act as a scientist. I charge my phone to 100 percent before dinner, and by 2 a.m. it is completely dead. It used to make it to the morning. Help me figure out why.
Let’s treat this as something we can test rather than something we guess at.
What we know. Full charge around 6 p.m. Dead around 2 a.m. That is roughly eight hours, down from what used to be twelve or more. We do not yet know whether the change was sudden or gradual, or whether anything else changed at the same time: a software update, a new app, a new game, a new place where the phone sits overnight.
Hypotheses.
- H1: An app is running more than it used to, especially in the evening and overnight.
- H2: The screen is on for more of that window than it used to be.
- H3: The phone is spending energy searching for a weak signal wherever it spends the night.
- H4: The battery itself has lost capacity.
Experiments, cheapest first.
- Battery health. Read the battery health figure in settings. If it is well under 90 percent, H4 is likely and the rest matter less.
- Usage log. Tomorrow at 2 a.m., or first thing in the morning, open the per-app battery breakdown and note the top three apps and the total screen-on time since 6 p.m. A large screen-on number supports H2. One app at the top supports H1.
- Controlled night. Charge to 100 percent at 6 p.m., then leave the phone face down in airplane mode in the room where it usually spends the night. If it is still mostly charged at 2 a.m., the drain comes from use or signal, not the battery.
Run the first one now. It takes thirty seconds and may end the investigation.
Act as the parent of the 11-year-old who owns this phone. I charge my phone to 100 percent before dinner, and by 2 a.m. it is completely dead. It used to make it to the morning. Help me figure out why.
Good. You should not be on your phone at 2 a.m. anyway.
We gave AI the same problem twice. The scientist produced hypotheses and cheap experiments. The parent produced one sentence, and it was not about the battery at all. Changing the role changed what AI noticed, what it thought the real problem was, and how much work it decided to do. Neither approach was written into the prompt; the role supplied it.
When writing a role-based persona, think about the qualifications needed to do the work. A job description is often a good starting point for deciding what the persona should look like.
Personality-based personas
The role is helpful, but often we need more than a role. Two people with the same customer service job can approach it very differently: one may be friendly and patient, while another may be terse and transactional. A role alone does not fully describe how AI should approach the work.
Personality traits can be especially useful when we want to see something we are working on from a different perspective. A skeptic questions our assumptions and approaches, giving us another vantage point.
Let’s use the same science project twice. Only the personality changes, so we can see how the perspective changes the work.
Act as a skeptic. Here is a description of my science project, the results, and my conclusions.
Project: Does music make plants grow faster? I bought two basil plants of the same size. I put one on my desk next to a speaker that played music for eight hours a day. I put the other one in the spare room where it was quiet. I watered both every other day.
Results: After three weeks, the music plant was 4 cm taller than the quiet plant.
Conclusion: Music makes plants grow faster.
Four centimeters is a real difference, so something happened. I am not convinced it was the music. Let me push on the reasoning.
Two plants is not an experiment. It is an anecdote. Two basil plants of the same size can still differ by several centimeters after three weeks for no reason at all. With one plant per group, you cannot tell the music effect apart from plant-to-plant luck. How would your conclusion look with five plants in each group?
The two plants did not just differ in music. One was on your desk. One was in the spare room. Which room had more light? Which was warmer? Did the speaker itself give off heat? Did you look at the desk plant every day and the spare-room plant only when you remembered to water it? Any one of those could produce 4 cm on its own. You changed several things at once and credited one of them.
“Faster” compared to what? You measured height. A plant stretching toward a weak light source gets taller and thinner, which is the opposite of healthy. Did you weigh the plants or count leaves?
The conclusion is bigger than the evidence. Even if everything above were fixed, the result would support “this music, at this volume, made this kind of basil taller in this room.” It would not support “music makes plants grow faster.”
I am not saying the idea is wrong. I am saying the experiment cannot tell us. Put both plants in the same room, use more of them, and play music to half. Then I will take the 4 cm seriously.
Act as a supporter. Here is a description of my science project, the results, and my conclusions.
Project: Does music make plants grow faster? I bought two basil plants of the same size. I put one on my desk next to a speaker that played music for eight hours a day. I put the other one in the spare room where it was quiet. I watered both every other day.
Results: After three weeks, the music plant was 4 cm taller than the quiet plant.
Conclusion: Music makes plants grow faster.
This is a good project, and you did the hard parts right. You asked a clear question. You set up a comparison instead of just growing one plant and guessing. You controlled the watering. You measured something specific and waited long enough to see a difference. Most projects at this stage do not get that far.
A 4 cm gap in three weeks is worth paying attention to. Whatever caused it, you found a real effect and you have a number to show for it.
Here is how to make the result stronger, because it deserves to be. Put both plants in the same room so light and temperature match, and add a few more plants to each group. Alongside height, count the leaves or weigh the plants at the end. Those changes turn a promising result into one that other people will believe.
Keep the music question. It is a good one, and you already know how to test it.
The skeptic and supporter received the same project. Their personas changed what they noticed and how they interpreted it. The skeptic looked for reasons the conclusion might be wrong. The supporter looked for what the student did right and how to build on it. Both are useful, and neither one was described in the prompt beyond a single word.
Example-driven personas
We have seen that we can teach an LLM by giving it examples. We can also use examples to teach it a persona. Instead of naming a role or a personality, we show AI examples of how someone has actually talked or behaved, and ask it to act as that person.
This is useful when we do not know how to describe the persona we need, but we have samples of it. Imagine you run a small dog-walking business in your neighborhood and you are thinking about changing how it works. You do not know how to describe your customers as a persona. You do have the messages they have sent you.
Act as the customers who sent me these messages about my dog-walking service.
“Honestly the best part is the photo you send from the walk. My daughter looks for it every day after school.”
“Can you keep the walk at the full 30 minutes? Last time it felt short and Biscuit was still bouncing off the walls at dinner.”
“Twelve dollars is already a stretch for us, but you are reliable and he loves you, so we are making it work.”
I am thinking about changing from a 30-minute walk for $12 to a 20-minute walk for $10, and stopping the photos so I can fit in more dogs per afternoon.
The customer whose daughter waits for the photo: The photo is the part we would miss most. It is thirty seconds of your time and it is the reason my kid thinks of you as part of the family. If you keep the photo, I do not mind the shorter walk. If you drop it, this becomes just a service, and I will start comparing prices.
The customer with Biscuit: Twenty minutes does not work for my dog. Thirty already felt short. I would rather pay the $12 and keep the full walk. If 20 minutes is the only option, I will need to find someone else, and I would rather not.
The customer for whom $12 is a stretch: Ten dollars helps. I will be honest, though: I am paying for reliability, not minutes, so a shorter walk at a lower price is fine with me as long as you still show up every day. Do not add fees later to make up the difference.
The three messages are examples of how each customer talks and what each one cares about. AI used those examples to build three distinct personas and produced a credible reaction from each, without our ever describing the customers. We taught the persona by example, the same way we taught a task by example in the last lesson.
So far, the personas have represented people or animals. We can also ask AI to represent a system whose state changes as it receives inputs.
Personas that become the whole thing
So far the personas have been people, or things that behave like people. Now we will ask AI to be something that is not a person at all, and to be all of it: the object, its rules, its controls, and its screen.
Here is the exact prompt, and what came back.
I want you to act as the game Galaga, but in an ASCII art format. I can tell you where to move and what actions to take, and you’ll simulate that set of moves and then redraw the intermediate screens as would have been seen for me to review and then describe what happened in two or three sentences.
Absolutely. I’ll maintain the game state between turns. You can give commands like LEFT 3, RIGHT 2, FIRE, or FIRE WHILE MOVING LEFT, and I’ll simulate them, show the relevant intermediate ASCII frames, then briefly explain what happened.
GALAGA 1UP 00000
V V V V V V
W W W W W
M M M M M M
v v
|
*
\ ^ /
|A|
------------------
READY!
Your fighter is at the bottom center. Two enemies are breaking from the formation and starting to dive.
Fire and move to the left corner.
FRAME 1
V V V V V V
W W W W W
M M M M M M
v v
|
*
\ ^ /
|A|
------------------
FRAME 2
V V V V V V
W W W W W
M M M M M M
X v
\ ^ /
|A|
------------------
You held fire while sweeping hard left. Your shot caught the diving enemy on the left and destroyed it (+100 points); you reached the far-left corner safely while the second diver continues downward on the right.
SCORE: 00100 — LIVES: 3 — Your move.
Look at what that one sentence produced. Nobody explained the rules of Galaga, how enemies dive, what a fighter looks like, or how scoring works. AI drew a screen that anyone who has seen the game would recognize. It remembered where the ship and the enemies were from one turn to the next. It understood “move to the left corner” without being given a list of commands. It showed time passing as a series of frames. Then it explained what happened.
The rules of the thing are also just words, so we can change them by talking.
Act as a working pinball machine. Draw the playfield in ASCII, including bumpers, flippers, the ball, and the score. I control the flippers by saying LEFT, RIGHT, or BOTH. Simulate the physics between my actions and show me a few intermediate frames before asking for my next move.
Launch the ball.
+----------------------+
| (500) (500) |
| (1000) |
| |
| o |
| \ / |
| \__ ___/ |
| \ / |
+----------------------+
SCORE 000000 BALL 1
+----------------------+
| (500) (500) |
| (1000) o |
| |
| |
| \ / |
| \__ ___/ |
| \ / |
+----------------------+
SCORE 001000 BALL 1
The ball shot up the right lane, clipped the 1000 bumper, and is now dropping toward the right flipper. Your move.
RIGHT. And from now on, gravity points to the LEFT.
+----------------------+
| (500) (500) |
| (1000) |
| |
| |
| \ o / |
| \__ ___/ |
| \ / |
+----------------------+
SCORE 001500 BALL 1
+----------------------+
| (500) (500) |
|o (1000) |
| |
| |
| \ / |
| \__ ___/ |
| \ / |
+----------------------+
SCORE 002000 BALL 1 TILT?
The right flipper connected and sent the ball up into the 500 bumper. Then gravity changed: instead of falling, the ball slid sideways along the top of the playfield and came to rest against the left wall, where the flippers cannot reach it. There is no flipper on this machine that reaches it.
We did not just play pinball. We rewrote physics in a sentence, and AI kept the persona working. It could do that because the machine, its rules, and its screen were never anything but language. There was nothing else there to break.
The thing does not have to be a game. Something as plain as a vending machine works the same way, and it shows a useful trick: write the prompt as named fields, so the state of the thing is visible on every turn.
ACT AS: a vending machine
PRODUCT: juice
PRICE: $1.25
STARTING CREDIT: $0.00
INPUTS: insert money; select juice; cancel
RESPONSE FIELDS: CREDIT; ACTION; NEXT INPUT
CREDIT: $0.00
ACTION: Waiting for payment or a selection.
NEXT INPUT: Insert money or choose a drink.
INPUT: Insert $1.00 and select juice.
CREDIT: $1.00
ACTION: Juice selected. Insert another $0.25 to complete the purchase.
NEXT INPUT: Insert $0.25 or cancel.
INPUT: Insert $0.50.
CREDIT: $0.00
ACTION: Dispense one juice and return $0.25 in change.
NEXT INPUT: Begin another purchase.
The structured prompt describes the machine, its starting state, its possible inputs, and the form of its responses. AI keeps the changing situation from one turn to the next and applies the patterns associated with a vending machine.
What exactly was AI pretending to be?
Stop and ask that question about the arcade machine. The easy answer is “Galaga.” But look at everything AI was doing at once.
It was a video game, with rules it was never told. It was a physics engine, moving ships and shots and deciding when they collided. It was an artist, drawing the screen in characters. It was a memory, holding the score, the lives, and every position between turns. It was a controller, turning “move to the left corner” into an action. It was a narrator, explaining what happened. And when we changed gravity in the pinball machine, it was a physicist too, working out what a ball does when down is suddenly sideways.
Every one of those existed entirely in words and symbols. That is the reveal of this lesson, and it is bigger than “give AI a character.”
AI does not only take words as instructions. AI can take words as a description of the thing. It can take words as the rules of the thing. It can take words as the controls. And it can use words and symbols as the thing’s display. With generative AI, language can be both the program and the interface.
Personas are another way to program
When we know the exact process, we can state the instructions directly, as we did when doubling a number.
When we do not know the process, we can give AI a persona whose learned patterns supply a way to approach the work. The persona can be an operation, like the skeptic. It can be a way of structuring, like the scientist. Or it can be the whole thing, like the arcade machine: object, rules, controls, and screen, all at once.
We can combine a persona with context, additional instructions, output formats, examples, and conversation rules.
The question to ask is:
What do I want AI to do, and what persona should do that work?
We direct the program through language. The persona shapes how the work is approached, and our instructions define what happens in the conversation.