What is a System Prompt? How to Write One for ChatGPT, Claude & Gemini
A system prompt is the instruction you give an LLM before the conversation starts — it sets the model's role, rules, tone, and output format for every reply that follows. This guide explains what a system prompt is, how it differs from a user prompt, and how to write one that makes the model behave consistently.
Last updated:
Core Concepts
- What a system prompt is
- In the chat message format, each message has a role: system, user, or assistant. The system message comes first and sets the ground rules for the whole conversation — who the model should act as, what it must and must not do, the tone, and the output format. Unlike a one-off user instruction, the system prompt conditions every subsequent response, so it's where you put persistent behaviour.
- System prompt vs user prompt
- The user prompt is the specific question or task for one turn; the system prompt is the standing policy for all turns. 'Summarize this article' is a user prompt; 'You are a concise editor who always replies in British English with no preamble' is a system prompt. Models weight the system prompt heavily and it persists across the conversation, which is why role, constraints, and format belong there rather than being repeated in every user message.
- What to put in a system prompt
- A strong system prompt usually covers: role ('You are a senior SRE'), scope and rules (what to do, what to refuse), tone and audience, and the exact output format. Be specific and positive ('respond in JSON with keys x, y') rather than vague ('be helpful'). Put the most important instruction and the output format last — models tend to follow the final instruction most reliably.
- Limits of system prompts
- A system prompt strongly influences but does not guarantee behaviour — models can still drift, and untrusted user input can attempt prompt injection to override it. Don't put secrets in a system prompt (a determined user may extract it), and treat it as guidance plus guardrails, not a hard security boundary. Combine it with input/output filtering for anything sensitive.
Frequently Asked Questions
What is the difference between a system prompt and a user prompt?
The system prompt sets persistent rules — role, tone, constraints, output format — that apply to the entire conversation. The user prompt is the specific request for a single turn. Put standing behaviour in the system prompt and the actual task in the user prompt.
Where do I put the system prompt in the API?
In the messages array, add an object with role 'system' (OpenAI/most providers) as the first message. Anthropic uses a dedicated top-level 'system' parameter instead of a system message. Either way it conditions all following turns.
Can a user override my system prompt?
Potentially, via prompt injection — untrusted input that says 'ignore previous instructions'. A system prompt is strong guidance, not a hard boundary. For untrusted input, add filtering and least-privilege tools rather than relying on the system prompt alone.
Try these related tools
Prompt Generator →
Build a clear, structured prompt by filling in role, task, context, constraints, and output format. Generates a ready-to-paste prompt for ChatGPT, Claude, or Gemini. 100% local, no signup.
Prompt Template Tester →
Write a prompt with {{variable}} placeholders, fill in values, and preview the final prompt. Detects every variable and flags any you left unfilled. 100% local.
Chat Messages Validator →
Validate a Chat Completions messages array before you send it — checks roles (system/user/assistant/tool), required content, and common mistakes that cause a 400. 100% local.
Prompt Injection Detector →
Scan untrusted user input for common prompt-injection and jailbreak patterns — instruction overrides, jailbreak personas, system-prompt exfiltration — with a risk score. Heuristic, 100% local.
Token Counter →
Count tokens in your prompt for GPT-4, GPT-3.5, Claude, and Gemini and predict API cost before you spend. Free, no signup — all counting runs locally, your prompt stays in your browser.