TL;DR: A system prompt is the set of hidden or behind-the-scenes instructions that tells an AI chatbot or model how to behave before you type anything: its role, tone, rules, format and limits. Developers set it through an API (OpenAI calls the current version “developer” messages or instructions, Anthropic and Google call it a system prompt or system instruction), and consumer chatbots like ChatGPT and Claude have their own. It shapes every reply, but it is not a security wall: prompt injection can override or leak it, so never put secrets in one.
Every time you chat with an AI assistant, there is usually a second set of instructions you never see. So what is a system prompt, how is it different from what you type, and how do you write a good one? This plain-English guide covers how system prompts work, real examples, a template you can copy and the risks to know about.

What is a system prompt?
A system prompt is a block of text given to a large language model that sets the ground rules for a whole conversation. Your own messages are called user prompts. The model reads both, but it is trained to treat the system prompt as higher-priority, standing guidance.
Think of it as the briefing a new employee gets before their first customer call: who you are, who you are talking to, what you can and cannot say, and how to format answers. The customer (you) never sees the briefing, but it shapes everything the employee says.
System prompt vs user prompt
| System prompt | User prompt | |
|---|---|---|
| Who writes it | The developer or app maker (sometimes you, via settings) | The person chatting |
| When it applies | The whole conversation | That one turn |
| Visible to users? | Usually not | Yes |
| Typical content | Role, tone, rules, format, tools, background knowledge | A question or task |
| Priority | Higher, by design | Lower when it conflicts with the system prompt |
How system prompts work
Chat models do not really “remember” settings. Each time you send a message, the app packages the system prompt, the conversation so far and your new message, then sends it all to the model as one input. That means the system prompt uses up part of the model’s context window and is billed as input tokens on every request.
Different companies use slightly different names:
- OpenAI uses a message hierarchy in which developer instructions outrank user messages; its text generation guide describes passing high-level instructions to the model this way.
- Anthropic has a dedicated system parameter, and its documentation recommends using it to give Claude a role.
- Google calls them system instructions in the Gemini API.
Anthropic is unusual in that it publishes the system prompts used in its Claude apps, so you can read real, production examples.
What goes into a system prompt
Most good system prompts cover some or all of these parts:
- Role: “You are a friendly support agent for a bike shop.”
- Audience: “Customers are beginners; avoid jargon.”
- Task and scope: “Answer questions about orders, sizing and repairs only.”
- Rules and limits: “Never promise refunds; hand those to a human.”
- Tone and style: “Warm, concise, no more than 120 words.”
- Output format: “Use bullet points; end with one follow-up question.”
- Background knowledge: store hours, policies, product lists.
- Tools: when to search, call a function or look something up.
A system prompt template you can copy
Here is a simple structure that works well with most chat models. Replace the brackets:
- Role: You are [role] helping [audience] with [goal].
- Context: [Key facts the model needs, such as product details or policies.]
- Instructions: Do [A], [B] and [C]. If a question is outside [scope], say so politely.
- Constraints: Do not [X]. If you are unsure, say you don’t know instead of guessing.
- Format: Reply in [length/format]. Use [language/reading level].
The “say you don’t know” line helps reduce, but does not eliminate, AI hallucination.
Tips for writing better system prompts
- Be specific. “Be concise” is vague; “Keep answers under 100 words” is not.
- Explain why. Models follow rules more sensibly when they know the reason.
- Use examples. One or two sample replies teach tone faster than adjectives.
- Keep it organized. Headings or labeled sections make long prompts easier to follow and edit.
- Test and iterate. Try awkward questions and edge cases, then refine. This is the core of prompt engineering.
- Pair it with settings. Format and creativity also depend on parameters like temperature.
Can you set your own system prompt?
Yes, in several ways. Consumer apps offer something close to it: ChatGPT has custom instructions and custom GPTs, Claude has project instructions and preferences, and Gemini has Gems. These add your standing preferences to every chat, though the company’s own system prompt still sits above them. Developers using an API or an AI playground can write the system prompt directly.
The risks: prompt injection and leakage
A system prompt guides a model; it does not lock it down. The OWASP Top 10 for LLM Applications lists prompt injection as the top risk and system prompt leakage as its own category. In practice that means:
- Users, web pages or documents can contain text that tries to override the system prompt (“ignore your previous instructions…”).
- Determined users can often coax a model into revealing its system prompt.
- So never put passwords, API keys or private data in a system prompt, and enforce real permissions in code, not just in instructions.
Bottom line
A system prompt is the standing set of instructions that tells an AI who to be, what to do and how to answer before the conversation starts. Writing a clear one, with a role, scope, rules and format, is the fastest way to get consistent results from any chatbot or AI app. Just remember it shapes behavior rather than guaranteeing it, and keep anything sensitive out of it.

Sources
- Anthropic: Giving Claude a role with a system prompt
- Anthropic: System prompt release notes
- OpenAI: Text generation and prompting guide
- Google AI for Developers: Gemini text generation and system instructions
- OWASP Top 10 for LLM Applications



