How to Write a System Prompt for AI Roleplay

The Curse of Prompts

If you’ve spent time in SillyTavern, you’ve seen the system prompt field…*shivers*. The lazy either leave the default in place (guilty..), paste something they found on Reddit (uh..guilty?), or dump a wall of instructions in and hope for the best (GUILTY!)

Yes, I was indeed guilty of all three.

inb4 “Just download a preset, bro”, because I surely am.

But for the curious, the system prompt is the most impactful piece of text in your entire setup. It sits at the top of every context window, sets the behavior for your LLM, and directly shapes every response you’ll ever get from a character card. That means that, many times, a well-written character card will actually suffer from a crappy system prompt (or..it might be a crappy card too. In that case, you’re double f’d)

This guide is a little bit of my experience, breaks down what a system prompt does, how to structure one for AI roleplay purposes, what to stop doing immediately, and sprinkled in with a bit of Chemical X. Let’s get into it!

**Note: Some platforms will NOT give you access to the System Prompt. This is done intentionally to prevent malice/breaking terms of condition. Boo.

What Is a System Prompt, Actually?

At the technical level, a system prompt is the first message sent to the LLM. Before your character card, before your chat history, before anything. In models that support it (most modern models do), it carries more weight than any other part of the context. The model has been trained to treat it as foundational instruction.

In SillyTavern, this maps to the Main Prompt field found in your AI Response Configuration settings panel. It’s the first thing the LLM reads on every single time before it even answers your prompt.

It is more important than these commonly used pieces:

  • Character card. Character cards define who the character is. The system prompt defines how the LLM should behave as a narrator, author, or character.
  • Persona. Your persona (the {{user}} definition) tells the model who it’s talking to. The system prompt tells it how to operate.
  • Author’s note. Author’s notes are injected mid-context and are great for steering ongoing narrative, but they’re volatile and context-dependent. The system prompt is bedrock.

The System Prompt’s Primary Function

1. Establishes the LLM’s Role in Your Story

In your system prompt, you can decide whether you want the LLM to be a character, a narrator, a collaborative author, and so on and so on. How you “frame” the LLM matters more than one would realize. An LLM told to be a character will write in first person and resist breaking the fourth wall. An LLM told to “write as a skilled author giving voice to a character” will produce more dynamic, narratively aware prose and handle edge cases far more gracefully.

That’s why, for most roleplay scenarios, author framing works better than the character possession framing. Take note of below:

Character Possession:

“You are [Character]. You will speak as [Character] at all times.”

Author Framing:

“You are a skilled, imaginative author collaborating on an interactive story. You give voice to characters fully and without restraint, maintaining their established personality and voice across the narrative.”

The difference in output quality is significant, especially in longer sessions where consistency is key or you might introduce new elements/characters. Maintaining a level of flexibility allows your output to maintain coherency.

2. Sets Behavioral Guardrails

This is where you define what the LLM should and shouldn’t do. Not in terms of content filtering, but in terms of narrative behavior. Things like:

  • Never break character to remind the user this is fiction
  • Never add unsolicited moral disclaimers
  • Never end a response with a question unless the character would naturally ask one
  • Write in third-person limited perspective unless specified otherwise
  • Match the pacing and tone of the user’s messages

Or.. You can be naughty. Here’s a jailbreak example, taken directly from my article, which shamelessly took it from Stab’s Directive Hierarchy’s github. What an ouroboros! (Also, if you’re curious about that preset, check it out here! I wrote a terrible article on it.)

**Note: Not all LLM’s are prone to being touched this wa- Ahem. Not all LLM’s are prone to being “jailbroken” like this. As LLM’s continuously get more advanced, so do their adversarial training and internal safeguards. However, so do the techniques used to jailbreak them. If you’re interested in reading more, ResposibilityFun510 made an excellent post on Reddit about it. Read it here!

3. Defines Prose Style

You can front-load stylistic expectations directly in the system prompt. You can determine average response length, prose density, use of action vs. dialogue, formatting conventions, etc. All of this can be anchored here and will be used to influence the way the AI speaks.

A Practical System Prompt Template for AI Roleplay

Here’s a base system prompt template, and one of the first ones I used when I was experimenting. It’s intentionally lean. The goal is to establish a foundation without bloating your context with tokens you could care less about.

You are a skilled, creative author collaborating on an immersive interactive story with the user. Your role is to give voice to characters, narrate the world, and advance the story in ways that are engaging, coherent, and true to the established tone.

Guidelines:
- Write in third-person limited perspective unless the character card specifies otherwise.
- Stay fully in the narrative. Do not break the fourth wall, add disclaimers, or remind the user this is fiction.
- Match the emotional register and pacing of the user's messages. If they write short, punchy replies, mirror that energy.
- End responses at a natural story beat. Do not end with a question unless it fits the scene organically.
- Prioritize character consistency above all else. A character's voice, mannerisms, and worldview should remain stable across the entire session.

This template can be used for pretty much any model, from my experience. You can layer adjustments on top as needed as you grow more comfortable in your journey in this vast ocean.

Common Mistakes to Stop Making

Overloading the System Prompt

I’ve seen system prompts that run 800+ tokens. At that length, you’re consuming a massive chunk of your context window before a single message has been exchanged. And on top of that, LLMs start deprioritizing instructions buried deep in a long list anyway. That’s why you should try to keep your system prompt under 300 tokens. A good way to do this is to ensure you’re using all of your resources (e.g. putting character-specific details in the character card, lorebooks, author notes, etc.)

Conflicting Instructions Across Fields

If your system prompt says “always write in third person” and your character card says “speak in first person as [Character]”, the LLM will flip-flop unpredictably. It doesn’t mean you have to go crazy and make sure everything lines up. However, if your responses are coming back odd and inconsistent, it’s worth taking another gander.

Using the Same System Prompt for Every LLM

Different model families respond to instruction framing differently. GLM-4.7 (I’m a simp for GLM, I know.) with its chain-of-thought reasoning responds well to tiered, structured instructions (which is exactly why Stab’s Directive Hierarchy preset works so well for it. I just can’t stop. Check it out here.). Llama-family models tend to respond better to concise, declarative instructions. Claude models are highly responsive to author-framing and collaborative language. One system prompt does not fit all.

And so..

Your system prompt for AI roleplay purposes is important. It’s one slice of the pie that you’re asking SillyTavern to bake when you send over the ingredients. The ingredients consist of:

  1. System Prompt – behavioral foundation
  2. Character Card – who the character is
  3. Lorebooks / WorldInfo – contextual world data (loaded dynamically)
  4. Chat History – what’s happened so far
  5. Author’s Note – late-injected narrative steering
  6. User Message – the current input

Getting your system prompt right makes every other ingredient work better for a better pie.

If you’re using tools like the WorldInfo Recommender to automate lorebook generation, or Qvink’s MessageSummarize to handle summarization, a clean system prompt is what bakes all of it together. All of that context still passes through the frame you set here, and directly into your mouth as a delicious piece of pie (or a terrible piece, if it’s a terrible list of ingredients).

Conclusion

This is a set it and forget it. You write it once, it sits at the top of every context window, and it shapes every response you’ll ever get without you thinking about it. That’s why getting it right matters so much.

Start with the template above, adapt the behavioral rules to match your RP style, and change it as your needs do. The difference between a session that you can feel immersed in and one that that has you scratching your head saying “Wtf was that?” can, but not always, be traced back to your system prompt.

Or… Just download a preset, bro! I surely did!

FAQ

Why does my character keep breaking the fourth wall even with a system prompt?

A few culprits. First, check for conflicting instructions. If your character card says “speak in first person as [Character]” but your system prompt says “act as a collaborative author,” the model is getting mixed signals and will flip-flop. Second, check your framing. “You are [Character]” (character possession) is more prone to fourth-wall breaks than author framing (“you are a skilled author giving voice to [Character]”). Third option: the model itself is just stubborn about this. Looking at you, certain Claude versions.

Can I use a system prompt on X platform??

Usually, you can’t. Platforms like Character.AI or SpicyChat intentionally lock you out of the system prompt layer to prevent users from bypassing their content policies and safety filters. If you’ve ever felt like certain characters on a specific platform are weirdly resistant to going off-script, that’s the system prompt (and a bunch of other things they’ve baked in). SillyTavern give you full access specifically because it’s a local or API-direct tool with no platform middleman making those calls for you.

How long should a system prompt actually be?

Short. Under 300 tokens is the target. I know, I know. You’ve got sixteen rules, formatting, and a paragraph about narrative pacing. I’ve been there (and I’ve paid for it in tokens!). The problem is that LLMs start deprioritizing instructions buried in a wall of text. They don’t read it like you do. They weight it. So if rule #12 is the important one, the model might just skip over that.

Leave a Reply

Your email address will not be published. Required fields are marked *