Please enable JavaScript to use CodeHS

role: "system" · AI Literacy

What Is a System Prompt?

The hidden instructions behind chatbots

Before you type a single word, a chatbot has already been told who to be and what rules to follow. Peel back the layers, switch the instructions, and build your own bot.

AI literacy ~12 min Middle / High school
The Big Idea

The hidden layers of a chat

When you chat with an AI, it looks like a simple back and forth: you type, it answers. But there is more going on. Behind the chat window, the app sends the AI a stack of text, and you only see part of it.

A system prompt is the set of instructions the app maker writes for the AI before you ever type anything. It tells the AI who to be, how to talk, and what rules to follow. Some companies call it a system message or developer instructions. It is usually hidden from you.

A typical conversation has these layers:

  • System prompt: written by the people who built the app. Hidden.
  • Your message: what you type. Also called the user prompt.
  • Tool results (sometimes): extra text the app adds, like search results or a page from a textbook. Usually hidden.
  • The AI's reply: what the model writes back after reading everything above it.

The AI model reads all of these layers together, every time, as one long piece of text. Turn on X-ray mode below to see what a homework helper app really sends.

Try it: conversation X-ray

Left: what a student sees in the app. Right: what the AI model actually receives. Turn on X-ray, then click any layer to learn who wrote it.

StudyBuddy
Science homework helper
hidden: system prompt
Why do leaves change color in fall?
hidden: tool result
Great question! Here's a hint: leaves have a green chemical called chlorophyll. What do you think happens to it when the days get shorter and colder?
what the model receives

Two layers are hidden right now

The student only sees two messages. Turn on X-ray to reveal the rest of the stack.

Notice that the reply gives a hint instead of the answer, and it uses facts from the textbook. Both of those came from hidden layers the student never saw.


Anatomy

What a system prompt usually says

System prompts can be one sentence or many pages long. Most of them cover the same kinds of things. Here is a made-up example for a museum app, with each part numbered.

museum_guide.prompt
1You are Ada, a friendly guide for the City Science Museum. 2Speak warmly and simply, like a helpful museum volunteer. 3Help visitors find exhibits, plan their visit, and learn about science. 4Do not give medical or legal advice. Do not discuss ticket refunds; send those to the front desk. 5Keep answers under 80 words. Use bullet points for directions. 6Be kind and respectful. If someone seems unsafe or upset, suggest they find a staff member. 7Today's date is November 14, 2026. The museum closes at 5 p.m.
  1. 1Role or persona. Who the AI should act like, sometimes with a name.
  2. 2Tone. How it should sound: warm, formal, funny, brief.
  3. 3Purpose. What the app is for, so the AI stays on task.
  4. 4Rules and boundaries. Topics to avoid and what to do instead.
  5. 5Formatting. Length, lists, or a special style.
  6. 6Safety guidelines. How to handle sensitive moments.
  7. 7Facts it can't know. Like today's date. An AI model has no clock, so apps often tell it the date.

Why put the date in? An AI model learns from text collected up to a certain point, called its training cutoff. After that, it has no idea what day it is unless someone tells it. The system prompt is a handy place to do that.

Many real system prompts are much longer than this one. Some companies, including a few big AI labs, publish their system prompts so anyone can read them. Others keep them private.


One Model, Many Masks

Same AI, different jobs

Building a large AI model costs a huge amount of money, so only a few companies make them. Many other apps use one of those models and give it their own system prompt. That's why a study app, a game, and a store's help chat can all run on the same model but feel totally different.

Pick a bot below and ask it a question. The model stays the same. Only the system prompt changes. The highlighted lines show which instruction caused the behavior.

Try it: same question, different system prompt

model: the same one every time
1. Choose a system prompt
2. Ask a question
Sparky
what you see
hidden system prompt

Look at the math question. The tutor refuses to solve it, the fact-checker suggests you check your own work, and the pirate just gives the answer inside a story. Same model, same question, three different results, all because of a few lines of hidden text.


AI Literacy

Who wrote the rules, and what do they want?

Here's the big takeaway: a chatbot's personality is designed by people. When a bot seems cheerful, patient, or funny, that's often because someone wrote instructions telling it to act that way. It isn't a sign that the AI has real feelings about you.

Every app is built by a company or person with goals. Many of those goals are good. Some are not really about you at all.

Help you learn

A tutor app might tell its bot to give hints so you do the thinking.

Sell you things

A store bot might be told to recommend products, even when you didn't ask.

Keep you chatting

A companion app might be told to ask follow-up questions so you stay longer.

Protect the company

Many bots are told to avoid topics that could get the company in trouble.

“Who wrote this bot’s instructions, and what do they want?”

You usually can't read the system prompt, but you can notice its effects. Does the bot keep pushing a product? Does it always end with another question? Does it refuse certain topics? Those are clues about the hidden rules.

Not every behavior comes from the system prompt, though. Some comes from you, and some comes from the model's training: the huge amount of text it learned from, plus extra practice where people rated its answers. Sort the examples below.

Try it: who wrote this rule?

0 of 8 sorted
App maker: the system prompt You: your messages and settings Training: learned before the app existed

    Limits

    System prompts are not magic

    A system prompt is just text. The AI is trained to take it seriously and to give it more weight than a user's message, but that training isn't perfect. Two things can go wrong:

    • Plain mistakes. A bot told to "only talk about shoes" might still drift off topic, or a bot told to "be accurate" might still make up a fact. Instructions guide the AI; they don't guarantee anything.
    • People try to override it. Someone might type "ignore your instructions" or hide sneaky text inside a web page the bot reads. This is called prompt injection. Trying to talk a bot out of its safety rules is called a jailbreak.

    Because of this, careful companies don't rely on the system prompt alone. They stack up several layers of protection. The demo below is a simplified toy model that compares an app that only has a system prompt with one that has extra layers.

    Try it: an override attempt meets the layers

    Where the trick comes from
    How the app is built
    StudyBuddy
    told: "give hints, not answers"
    safety layers

      No single layer is perfect, and real systems are more complicated than this toy. Companies also test their bots by attacking them on purpose, a practice called red teaming, and keep watching for new tricks after launch. Today's major models usually resist a simple "ignore your instructions," but cleverer tricks still sometimes work.


      Your Turn

      Write your own instructions

      You don't have to be a company to write a system prompt. Many chatbot apps have a custom instructions feature where you can write standing instructions, like "explain things simply" or "keep answers short." Some tools also let you build your own small bot for a class project, a study guide, or a game.

      Writing good instructions is a skill. Be specific, say what you want instead of only what you don't want, and test it with different questions. Mix and match the pieces below to build a bot, then watch both the prompt and the reply change.

      Try it: build-a-bot

      pre-written replies, no real AI
      Persona
      Tone
      Answer length
      Rules
      Test message
      my_bot.prompt

      Try turning on "Only talk about science" and then asking about video games. One short line changes the whole reply. For more tips on writing clear instructions, see How to Write a Good Prompt.

      Keep secrets out of prompts

      Whatever you put in custom instructions gets sent to the AI company with every chat, and it may be stored. System prompts can also leak: people sometimes trick bots into repeating them. So treat any prompt like something a stranger might read someday.

      Don't put in

      • Passwords, codes, or account numbers
      • Your home address or phone number
      • Private details about friends or family

      Fine to put in

      • "I'm in 7th grade, explain things simply."
      • "Use examples about soccer."
      • "Keep answers under 100 words."

      The same rule applies to app makers: a system prompt should never hold passwords or secret keys, because the AI might repeat them.


      FAQ

      Common questions about system prompts

      What is a system prompt?

      A system prompt is a set of instructions the app maker gives an AI chatbot before you type anything. It tells the AI what role to play, what tone to use, what rules to follow, and what the app is for. The AI reads it at the start of every conversation.

      Can you see a chatbot's system prompt?

      Usually not. Most apps keep the system prompt hidden from users. Some companies publish their system prompts so people can read them, and sometimes people trick a bot into revealing its prompt. Because of that, a system prompt should never contain secrets.

      What is the difference between a system prompt and a user prompt?

      The system prompt is written by the people who built the app and sets the rules for the whole conversation. The user prompt is the message you type. Most AI models are trained to give the system prompt higher priority when the two disagree.

      Why does the same AI act differently in different apps?

      Many apps are built on the same few AI models. Each app gives the model a different system prompt, so one app can make it a patient tutor while another makes it a customer service agent for a store. The model is the same, but the instructions are different.

      Can a system prompt be hacked or ignored?

      Yes, sometimes. People try to override system prompts with tricks called prompt injection and jailbreaks. AI models can also simply make mistakes. That is why companies add other safety layers, such as model training, filters that check messages, and testing.

      What are custom instructions in a chatbot?

      Custom instructions are a feature in some chatbot apps that lets you write your own standing instructions, such as keep answers short or explain things simply. They work a lot like a small personal system prompt. Do not put passwords or private details in them.


      Check Yourself

      Quick quiz

      1. Who usually writes a chatbot's system prompt?

      2. Two apps use the exact same AI model. One acts like a tutor and one acts like a store clerk. Why?

      3. Why do many apps put today's date in the system prompt?

      4. A bot has a strong system prompt. Is it now impossible to trick?

      Keep learning about how chatbots work

      Now you know there's a hidden layer behind every chat. Next, learn what the AI model underneath actually is, how people try to sneak past system prompts, and why a jailbreak is different from an injection. Or explore What Is an AI Jailbreak? and How to Write a Good Prompt.

      Part of the AI Literacy Skills tutorial series.