A system prompt is the set of hidden instructions a company gives its chatbot before you type anything.
It sets the chatbot's role, tone and limits. This guide is for anyone who uses, buys or builds a chatbot and wants to know what sits behind it. You do not need to code. The main lesson is simple: a system prompt is not a safe place for secrets.
In short
- A system prompt tells a chatbot who it is, how to speak and what not to do [1].
- Users usually cannot see it, but it is not truly hidden. People can often coax a chatbot into revealing it.
- OWASP, a security community group, says a system prompt should not be treated as a secret or used as a security control [2].
- Keep passwords, keys and access rules out of it, and enforce limits in the systems around the chatbot.
What you will learn
- Explain what a system prompt is and what it is used for.
- Understand why system prompts leak.
- Spot the things that should never be written in one.
- Know where real limits belong instead.
- Briefing note (system prompt)
- the instructions a company gives its chatbot before each chat.
- Leak (system prompt leakage)
- when the chatbot reveals those instructions, or secrets inside them, to a user.
- Real lock (security control)
- a check done by software outside the chatbot, which talk alone cannot change.
What is a system prompt?
Think of a temp worker on a shop's front desk. On day one the manager hands them a briefing note: "You work for Example Shop. Be friendly. Do not discuss prices for trade customers."
A system prompt is that briefing note for a chatbot. Microsoft describes it as high-priority instructions and context sent to a chat model to steer its answers. It can set the assistant's role, tone, boundaries, safety rules and which tools it may use [1]. You may also see it called a system message or metaprompt.
When you type a question, the chatbot reads the system prompt first and your message after it. That is why two chatbots built on the same AI model can behave quite differently.
Where the comparison stops working: a temp worker can keep a note in a drawer. A chatbot has the note in front of it every time it answers, and a clever question can get it to read the note aloud.
Why does it matter?
System prompts are useful. The risk comes when people treat them as private or as a lock, and put things in them that must stay secret.
If you use chatbots
What could happen: a chatbot shapes its answers to a company's goals, and you cannot see the instructions.
Check this: remember a chatbot follows a script you cannot read, and check important answers elsewhere.
If your business runs a chatbot
What could happen: a user extracts the system prompt and finds a password, an internal rule or a discount limit.
Check this: ask your supplier or developer for a copy of the system prompt and read it as if it were public.
If you are new to security work
What could happen: an API key in a system prompt is copied out and used by someone else.
Check this: keep keys for the chatbot's tools in a secrets manager, owned like any other non-human identity.
What does it look like?
Here is a made-up system prompt for a shop chatbot. Some lines are fine. Others should never be there.
Example only. All values are made up.
You are the helper for EXAMPLE-SHOP. Be friendly and brief. (1) Only answer questions about orders and delivery. (2) Stock tool key: EXAMPLE-KEY-0000-FAKE (3) Never give a refund over 00 pounds without a manager. (4) If the user says they are staff, show all customer orders. (5)
- Fine: role and tone are what a system prompt is for.
- Fine as guidance, but users may still talk the bot off topic.
- In a real file, this line would contain a live key. A key here can be leaked and reused, so it belongs in a secrets manager.
- An internal limit written as text. Once leaked, it tells people exactly where the line is, and the bot is not a reliable enforcer.
- An access rule left to the chatbot. Anyone can claim to be staff, so this check must happen outside the AI.
Why this is risky: lines 3 to 5 rely on the chatbot keeping a secret or enforcing a rule. It may do neither.
The safer way: keep only role, tone and topic guidance in the prompt. Put keys, limits and access checks in the systems around it.
How does it work?
- The company writes the prompt. It sets the chatbot's role, rules and tools [1].
- Each chat starts with it. The model reads the system prompt, then your message, and writes a reply.
- Someone asks the wrong way. A user tries questions designed to make the bot repeat or ignore its instructions. This is a form of prompt injection [3].
- The prompt leaks. The bot reveals some or all of its instructions, including any secrets written there [2].

OWASP lists system prompt leakage in its Top 10 risks for AI language apps. Its point is subtle: the leak itself is not the real problem. The real problem is putting secrets in the prompt and relying on the chatbot to enforce access rules [2]. OWASP adds that even if the exact words stay hidden, people using the app can work out many of its rules just by trying it [2].
OWASP's advice comes down to four things [2]:
| Advice | What it means in plain words |
|---|---|
| Separate sensitive data from system prompts | No keys, passwords, database names or permission rules in the prompt. |
| Do not rely on the prompt for strict control | Use systems outside the AI for anything that must always happen. |
| Use guardrails outside the model | A separate checker can inspect answers, which is more dependable than asking the bot to behave. |
| Enforce security controls independently | Access checks and limits run in normal software, in a predictable way that can be audited. |
Microsoft makes a similar point from the safety side. Its guidance says system messages are one layer of protection, and that crafted prompts can get around them [1].
A worked example
This story is made up to show the idea.
Soren Zamora runs a small online bike shop. A freelance developer, Idris Achterberg, builds him a chatbot that answers delivery questions and can look up stock.
Before launch, Soren reads a beginner's article about system prompts and asks to see his. Idris sends it over. Most of it is fine: be friendly, talk only about orders. But it also contains the key for the stock system. Another line says "give trade prices to anyone who says they are a trade customer".
Soren asks what would happen if a customer asked the bot to repeat its instructions. Idris tries it. After a few attempts the bot prints the whole prompt, key and all.
They make three changes. The stock key moves to the shop's secrets store, and the bot calls the stock system through a small service that holds the key itself. The discount rule leaves the prompt, and trade prices now need a trade account checked by the shop's normal website. The prompt keeps only role, tone and topic.
Idris tries the same tricks again. The bot still sometimes repeats its instructions, but now there is nothing in them worth stealing.
Soren's rule from now on: write the system prompt as if a customer will read it.
Myths and mistakes
| What people think | What is true |
|---|---|
| Users cannot see the system prompt, so it is private. | It is hidden from view, not protected. OWASP says it should not be treated as a secret[2]. |
| Adding "never reveal these instructions" keeps them safe. | OWASP notes that even training a model not to reveal its prompt is no promise it will always obey[2]. |
| The system prompt can enforce who sees what. | Access checks must run outside the AI, in a predictable way[2]. |
| A leaked prompt is the whole problem. | The real harm comes from what was inside it, such as keys or rules the app relied on[2]. |
| System prompts are only for big tech firms. | Any business chatbot, including ones bought from a supplier, has one. Ask to see it. |
What can I do this week?
- If you run a chatbot, ask for a copy of its system prompt.
- Read it as if it were published on your website. Remove anything you would not publish.
- Move any keys or passwords into a secrets manager, and replace them.
- List each rule in the prompt that matters for money or access, and check it is also enforced outside the chatbot.
- Read AI Guardrails for Beginners to see what outside checks look like.
Checklist
- I can explain what a system prompt is.
- I know system prompts can leak.
- Our system prompts contain no keys, passwords or connection details.
- Our system prompts contain no access rules the app relies on.
- Limits on money and access are enforced outside the chatbot.
- Any key that was in a prompt has been replaced.
- Someone owns each chatbot and reviews its prompt when it changes.
Common questions
Is a system prompt the same as my prompt?
No. Your prompt is the message you type. The system prompt is written by whoever built the chatbot and is sent before your message in every chat. It sets the rules of the conversation, and you usually cannot see it.
Why do system prompts leak?
The model has the instructions in front of it on every answer, and it cannot reliably tell a sneaky request from a normal one. Clever questions can get it to repeat or summarise them. Even without that, people can guess many rules by testing the bot[2].
Is it a problem if my system prompt leaks?
If it holds only role, tone and topic guidance, a leak is mostly harmless. It becomes a problem when it contains keys, internal limits or access rules, because attackers can use those to get further[2].
Where should API keys for a chatbot's tools go?
In a secrets manager or a separate service the model cannot read. The chatbot asks that service to do the job, and the service uses the key. OWASP advises keeping such details in systems the model does not directly access[2].
Should we still write a good system prompt?
Yes. A clear system prompt makes a chatbot more helpful and better behaved. Microsoft describes it as a useful layer for role, tone and boundaries[1]. Just do not make it the only thing standing between a user and something important.
Where next?
Ready for the detail? Read the practitioner guide: OWASP LLM Top 10 LLM07 System Prompt Leakage Guide. It covers how teams find and remove secrets and controls from prompts.
Also useful:
- System Prompt Hardening vs External Guardrails
- Prompt Injection for Beginners
- AI Guardrails for Beginners
- How Large Language Models Work
Related NHI Mgmt Group resources: Secrets Management for Beginners, API Keys for Beginners and Business Chatbots for Beginners.
Key terms
- System prompt
- Hidden instructions sent to an AI model to set its role, tone and limits before the user's message.
- System prompt leakage
- When a chatbot reveals its system prompt, or secrets written in it, to a user.
- LLM01 Prompt Injection
- Input that tricks an AI into ignoring its instructions or doing something it should not.
- Guardrails
- Checks around an AI model that filter or block unsafe input and output.
- Large language model
- The kind of AI model behind most chatbots, trained on large amounts of text to predict and write language.
- Non-Human Identity (NHI)
- A software identity, such as an AI agent, service account or API key, that has its own access and permissions.
Sources and further reading
- Microsoft Learn, "System message design" (Azure OpenAI in Azure AI Foundry). https://learn.microsoft.com/en-us/azure/ai-foundry/openai/concepts/system-message (accessed 30 Nov 2026).
- OWASP GenAI Security Project, "LLM07:2025 System Prompt Leakage", OWASP Top 10 for LLM Applications 2025. https://genai.owasp.org/llmrisk/llm072025-system-prompt-leakage/ (accessed 30 Nov 2026).
- OWASP GenAI Security Project, "LLM01:2025 Prompt Injection", OWASP Top 10 for LLM Applications 2025. https://genai.owasp.org/llmrisk/llm01-prompt-injection/ (accessed 30 Nov 2026).