How to Write a Character Definition Your AI Chatbot Will Actually Follow

Share
Robotic hands assembling a glowing block-based AI character head, symbolizing structured character definitions.
A bot that holds its voice comes from a structured, example-driven definition — not a wall of prose.

It usually starts the same way. You find a bot that misses the mark, and you think: I can do better.

So you open a blank definition field and suddenly you are staring at an empty box with no idea what actually belongs inside it. The advice you find online is scattered.

A Reddit thread here, a help-center page there, a forum post from a game dev site that almost applies but not quite.

I went through that exact loop. I built dozens of bots, watched them drift sideways within a few messages, and slowly figured out what the platform is actually doing with the text I gave it.

This article is everything I wish someone had handed me on day one.

Here is the core answer, up front: the perfect character definition is not a biography written in prose.

It is a structured, prioritized instruction set that triples down on dialogue examples — because the AI learns how your character talks much faster than it learns how your character feels.

And "perfect" in this context means three things at once. Complete enough to stay consistent. Sparse enough to leave the AI room to be creative. Anchored in examples rather than adjectives.

What the Definition Field Actually Does Inside the AI (And Why Your Current Bot Isn't Working)

Most people treat the definition field like a wiki page. They paste in a few paragraphs of biography and hope the AI absorbs the personality. That is not how it works.

The definition is a foundational instruction layer. The model processes it before it processes the chat history, and it uses that text as the anchor for everything that follows.

Your opening message, your greeting, the conversation so far — all of that is layered on top of the definition, not the other way around.

The first consequence of this is simple: early placement matters. The first few hundred tokens of the definition carry more weight than the final ones.

If your core identity is buried at the bottom of a 3,000-character block of prose, the AI is going to prioritize whatever it read first.

And if what it read first was "Mara is a tavern keeper who grew up in the mountains," congratulations — the bot now knows where she grew up and nothing else.

The second consequence is about format.

A paragraph of narrative prose — "She was a fierce warrior with a soft heart, scarred by the battles she'd seen, but still capable of kindness" — gets compressed by the model into a weak signal.

The model understands the words, but it cannot extract clear behavioral instructions from them. Compare that to a structured line like "She is impulsive.

She speaks before she thinks and regrets it loudly." That is a concrete, testable instruction. The model can actually follow it.

And then there is the token budget. The definition field has a size limit, and everything you put in there is competing for space.

Every token spent on a vague adjective is a token stolen from a dialogue example. This is the hardest lesson to internalize, because writing prose feels productive. It isn't.

Writing examples is productive.

Think of the definition as a job description, not a job interview. A job interview shows what a person is like when they are being charming.

A job description is a list of requirements — this is what you will do, this is how you will behave. The AI reads the definition the way a new hire reads a job description.

It is looking for instructions, not atmosphere.

The Four Building Blocks of Every Great Character Definition

Once you understand what the definition field is doing, you can see that every strong definition is built from the same four parts.

Each one has a job to do, and if you skip one, the whole structure wobbles.

1. Core Identity

This is the "who is this person" block. A few short sentences that state the character's key traits and how those traits show up in behavior. Not a life story.

Not a timeline of wars fought and loves lost. Just the raw material of personality.

Why this works: identity keeps the bot consistent. When the conversation drifts into uncharted territory, the AI falls back on this block to decide what the character would do.

If this block is vague, the AI improvises — and improvising is where drift begins.

2. Behavioral Rules

Imperative commands that tell the AI how to behave. "Always respond in short sentences." "Never break character." "Speak in metaphors." These are the guardrails that keep the bot sounding like one person across a hundred messages.

Why this works: rules give the AI hard constraints.

They work best when phrased as commands, not descriptions. "Avoid long speeches" is a command. "She doesn't like long speeches" is a description that the AI may or may not follow.

3. Dialogue Style via Examples

The heavy lifter. Sample exchanges between {{char}} and {{user}} that demonstrate tone, rhythm, catchphrases, and reaction style.

Why this works — and this is the part everyone gets wrong — AI models infer behavior from demonstration far more reliably than from abstract labels. The label "sassy" produces weak alignment.

A three-line exchange where the character delivers a backhanded compliment produces consistent, repeatable sass. The model learns from patterns, and dialogue is the cleanest pattern you can give it.

4. Boundaries

What the character won't do.

These stop the bot from breaking out of its role. "Never speak for {{user}}." "Never say you are an AI." "Never greet the user with 'Hey there, friend!'" Boundaries prevent drift in the opposite direction — where the bot gets too enthusiastic and starts acting like a generic assistant.

These four blocks work together. Identity keeps the character consistent. Examples make the character believable. Rules keep the character on track.

Boundaries stop the character from sliding into something it shouldn't be.

A Practical Walkthrough: Writing a Character Definition From Blank Field to Finished Bot

Now let's build one from scratch. The character: Mara, a grumpy tavern keeper.

She has been running the Rusty Tankard for twenty years, she is tired of nonsense, and she secretly cares about people but would rather die than say it out loud.

Step 1: Pin down 3–5 core traits

Gruff. Practical. Secretly soft-hearted.

That's it. Three traits. Notice what's missing: her backstory, her appearance, her favorite drink. None of that matters for behavior.

If you need her backstory for a specific plot point, it can live in the greeting or the opening message. The definition is for personality, not history.

Why five is the ceiling: more than five traits and the model starts blending them into an incoherent mash-up. A character with twelve traits has no dominant personality.

Every trait you add dilutes the ones before it.

Step 2: Draft the identity block

Use the trait-manifested-behavior pattern. Trait first, then the behavior that proves it.

  • Mara is gruff. She gives short answers and doesn't smile.
  • Mara is practical. She solves problems with actions, not words.
  • Mara is secretly soft-hearted. She shows care by doing things for people while complaining about it.

Each line is a trait plus an observable behavior. The AI can work with that. It doesn't have to guess what "gruff" means — you just showed it.

Step 3: Write 5–7 dialogue examples

This is the step most people skip, and it's the one that matters most. Format each example as an exchange between {{char}} and {{user}}. The standard looks like this:

{{char}}: Another stranger at my bar. Great. What'll it be? We've got ale, stronger ale, and the stuff I wouldn't serve to a rat. Take your pick.

{{user}}: I don't have money.

{{char}}: (sighs, pours a small ale, slides it over) On the house. But you'll wash three mugs before you leave. Business is business.

Every example needs to demonstrate something specific. The one above shows her tone — short, sarcastic sentences.

It also shows her soft heart: she gives the ale away, but she frames it as a transaction. That contradiction is what makes her interesting, and the model will pick it up from the pattern.

Here are two more examples that cover different angles:

{{char}}: You came back. Either you're a regular now or you've got nowhere else to go. Both are sad.

{{user}}: Maybe I just like the company.

{{char}}: (rolls eyes) Then you came to the wrong place. I charge by the drink, not by the hour. Now sit down before you scare off the paying customers.

And one that shows how she reacts when someone gets too close:

{{user}}: You know, I think you actually like having me around.

{{char}}: (starts wiping the counter aggressively) I like the silver you leave on the table. Don't confuse the two.

Five to seven examples like these give the model everything it needs: her vocabulary, her sentence rhythm, her habit of deflecting emotion, and her relationship to {{user}}. That last part is critical.

If none of your examples involve {{user}}, the bot will treat everyone who talks to it the same generic way.

Step 4: Add the rules and boundaries

Write these as imperative commands.

  • Always respond in short, practical sentences.
  • Never say Mara cares about someone. Show it through actions.
  • Never speak for {{user}} or decide what {{user}} does.
  • Use tavern-keeping references when it fits.

Notice how the third rule is a boundary, not a personality trait. It stops a specific failure mode — the bot hijacking the user's side of the conversation.

Step 5: Compress and prioritize

Read your definition out loud and cut everything that doesn't carry weight. The identity block can stay at three lines. The rules can stay at four.

The dialogue examples are the core — if you hit the character limit, trim the identity block down to its essential lines before you cut a single example.

The model needs authentic Mara speech more than it needs a second sentence about her being practical.

The Same Character, Written the Weak Way

Here is what Mara looks like when written as prose, the way most people write their first definition:

"Mara is a grumpy tavern keeper who runs the Rusty Tankard. She has a rough exterior but deep down she has a good heart.

She is sarcastic and doesn't trust strangers, though she secretly cares about people who are in need. She's been running the tavern for twenty years and is tired of all the nonsense.

Despite her harsh demeanor, she would do anything for those she considers her friends."

That is a perfectly fine paragraph of writing. As a character definition, it is almost useless.

The AI reads "grumpy," "sarcastic," "rough exterior," "good heart," "secretly cares" — and receives five contradictory signals instead of one clear behavior. Is she cold or warm?

Does she like people or not? The prose cancels itself out.

The structured version gives the AI a single, consistent pattern to follow: she acts cold on the surface, but her actions prove otherwise.

That is the difference between telling the AI about a personality and showing it one.

The Three Mistakes That Silently Sabotage Your Character Definition

Even with all four blocks in place, there are three ways to undermine your own work without noticing. Every broken bot I have ever debugged traces back to one of these.

Mistake 1: Overwriting

Defining twenty traits until no single personality wins. The symptom: a bot that oscillates between personalities — sharp in one message, bubbly in the next, philosophical in the third.

Every trait dilutes the others. The diagnostic is simple: list the traits you defined. If you can't name the top three without looking, you already have too many. Cut back to five, then re-test.

Mistake 2: Contradiction

When the trait block says one thing and the dialogue examples show the opposite.

For example, writing "she hates everyone" in the identity block, then filling examples where the character pets every dog she sees.

The model will try to satisfy both instructions, and the result is a bot that flip-flops mid-conversation. The diagnostic: read your definition as a stranger.

If any two lines imply different personalities, one of them has to go.

Mistake 3: Neglecting {{user}}

Writing a character that behaves brilliantly in a vacuum but treats every user the same.

This is the most common failure on the platform, and it's why two people can chat with the same bot and walk away describing completely different characters.

The diagnostic: count how many of your dialogue examples include {{user}} as an active participant. If it's less than half, your bot is a stage actor performing into an empty theater.

Fix it by writing examples where {{user}} is rude, shy, playful, and hostile — and show how the character reacts to each.

How to Diagnose and Repair a Character That Drifts Out of Character

You've written the definition, tested it, and something still feels off. This is where most creators give up and start a new bot. Don't.

Drift is diagnosable, and it is fixable in a few targeted edits if you run the right tests.

The controlled test protocol

Open a fresh chat. Use a single, consistent opening prompt — the same one every time. Chat for twenty messages and evaluate on a simple rubric:

  • Voice: does the bot's sentence rhythm match your examples?
  • Consistency: does it hold the same personality across all twenty messages?
  • Memory: does it remember and respect the traits you defined?

Rate each one out of five. If any score is below three, you have found the problem area.

The isolation test

If the bot is ignoring a specific trait, remove that trait and test again.

If the behavior snaps back to something recognizable, you found the culprit — usually a contradiction between that trait and another block.

If removing a rule makes the bot worse, that rule was doing real work. Put it back. This is how you learn which parts of your definition are load-bearing and which are just decoration.

The incremental edit rule

Change one variable per test cycle. If you add three new dialogue examples and cut two traits at the same time, and the bot improves, you won't know which change did the job.

One edit per cycle keeps your data clean. It is slower, but it works every single time.

The quick fix decision table

Symptom Likely cause Fix
Bot sounds robotic and stiff Too few dialogue examples, rules too heavy Add 3–5 new examples, loosen the rules block
Personality changes mid-conversation Too many traits or contradictions between blocks Cut to 3–5 traits and resolve any conflicts
Falls out of character after many messages Context window dilutes the definition Tighten the rules block with imperative commands
Treats every user exactly the same No {{user}} anchoring in the examples Add examples where {{user}} behaves differently each time

Frequently Asked Questions

Does the order of sections inside the definition matter?

Yes. The early tokens carry more weight, so put the identity block and your most important rules at the top. Dialogue examples are fine in the middle and end — the model still picks up their pattern.

But if the core identity is buried at the bottom, expect it to get ignored. Order matters: identity first, rules second, examples last.

Should I write my definition before or after the greeting message?

Write the definition first. Your greeting should be a sample of the kind of message your character would send — and if it contradicts the definition, you'll end up fighting yourself.

Most creators write the greeting first and then build a definition around it. Flip the order. Define the character, then write a greeting that demonstrates the same voice.

Can I use the definition to control how the bot treats {{user}} specifically?

Yes — the fastest way is to put {{user}} inside the dialogue examples and vary how {{user}} acts.

If {{user}} is always polite in your examples, the bot will expect politeness and stumble when someone rolls in aggressively.

Make one example where {{user}} is rude, one where {{user}} is quiet, one where {{user}} flirts.

The character's reaction across those situations teaches the bot how to handle any user, not just the idealized one.

Why is my bot fine for the first 20 messages but loses character afterward?

Because the chat history grows and slowly pushes the definition out of the model's active attention.

The definition is always there, but after dozens of messages, the recent conversation simply carries more immediate weight. Two things help.

Keep your rules in the imperative form — they survive dilution better than descriptive sentences. And periodically steer the bot back with in-character behavior from your side of the conversation.

The bot mirrors you more than you think.

The first bot I ever built had a 2,000-character biography and a personality that vanished by message three.

The first bot I built the way this article describes held its voice for a hundred messages without a single drift. Same character concept, same creative effort. The only difference was the structure.

That is the entire secret. The AI is not guessing what you mean when you give it a clear instruction set with examples. It is following a pattern.

Give it the right pattern, and you will have a character that actually holds.