Skip to content

What Is a System Prompt? How to Write One (With Examples)

You open ChatGPT, type a question, and an answer appears. What you never see is the block of text the model read before your message landed. Someone at OpenAI wrote those hidden instructions. They told the model who it is, how it should talk, and which lines it should not cross. Claude has one. GitHub Copilot has one. So do almost all customer support bots and coding assistants you have used.

That block of text is the system prompt. It is the instruction layer that sits underneath every conversation in AI-powered applications. Before a single word from you arrives, it has already set the operating rules, the escalation logic, and the personality the assistant will show.

This guide covers what a system prompt is in AI, why it matters, how it differs from a user prompt, and how to write one that holds up with real users. You will also get copy-paste examples and the steps to set one in ChatGPT, Claude, Cursor, and the API.

Qasim AliWritten & reviewed by , SEO Specialist, Website Developer & Content WriterLast reviewed:

What is a system prompt?

A system prompt is a set of foundational instructions an AI model receives before the user's first message. It defines the assistant's role, tone, rules, boundaries, and output format, and it stays in force for the entire conversation. The user prompt then supplies the actual question or task.

What Is a System Prompt?

Diagram showing a system prompt sitting above the user prompt in an LLM conversation flow
Diagram showing a system prompt sitting above the user prompt in an LLM conversation flow

Quick answer: A system prompt is a set of foundational instructions an AI model receives before the user's first message. It defines the assistant's role, tone, rules, boundaries, and output format, and it stays in force for the entire conversation. The user prompt then supplies the actual question or task.

A system prompt is a set of special instructions given to large language models (LLMs) before any user interaction begins. It defines the model's role, behavior, and response characteristics, and it is usually invisible to the user. Think of it as the operating instructions for an AI assistant: who it is, what it knows, how it communicates, and which boundaries it must respect.

Most AI platforms use a message-based conversation format. Every message carries a role: system, user, or assistant. The system message usually comes first, and models are trained to give it extra weight, so instructions placed there tend to win when a later message conflicts with them. A system prompt can describe the assistant's identity and scope, its communication style and output format, allowed and disallowed behaviors, tool usage rules, source-of-truth rules, uncertainty behavior, and escalation priorities. Here is what that looks like in its simplest form:

[SYSTEM]  You are a concise travel assistant. Answer in under 80 words.
          Never book anything. If dates are missing, ask for them.
[USER]    Is Lisbon worth visiting in March?
[AI]      Yes. March brings mild weather, fewer crowds, and lower hotel
          prices than summer. Which dates are you considering?

The user never saw the first line. It still controlled the length, the scope, and the follow-up question. One thing worth knowing early: "system prompt" is an architectural concept, not one universal API field. Anthropic exposes a system parameter, Gemini uses system_instruction, and OpenAI's current API uses an instructions parameter and developer messages. The idea is shared; the plumbing differs.

Key takeaways: a system prompt sets persistent context and boundaries; the user prompt sets the task. A role is only one piece; strong prompts also define goals, sources, uncertainty handling, tools, and output rules. System prompts improve consistency but are not a security boundary, so critical rules still belong in code, and you should treat one like product code: version it and change one thing at a time.

How system prompts work

A system prompt does not change the model itself. It changes what the model reads first. A useful way to picture a production AI application is as a stack of layers:

Application rules
      |
System/developer instructions   <- the system prompt lives here
      |
Runtime context                 <- customer data, retrieved data
      |
User request
      |
Model  ->  Tools  ->  Validated response

Because it arrives first, the model reads its goals, roles, and domain before it understands the question, and long before it generates the answer. That ordering is why a single line about length, scope, or tone can reshape every reply.

Why system prompts matter: the purpose of a system prompt

What is the purpose of a system prompt? In one sentence: it turns a general-purpose model into a specialized, predictable assistant. Without system-level guidance, LLMs fall back to general-purpose behavior. That is fine for casual chat, but a problem in production, where a support bot, a code reviewer, and a writing partner need very different behavior from the same model. Here is the clearest demonstration: same model, same question, different system prompts.

System promptWhat the model does with "Can I cancel and get a refund?"
Concise support agent: ask for the order date first; never invent policyGathers the minimum facts, then answers without guessing
Policy analyst: separate what the supplied policy says from assumptionsTreats the question as an evidence task and flags gaps
Empathetic coach: acknowledge the concern, then give the next safe stepChanges tone and ordering, not the policy
Risk reviewer: never promise or deny a refund; list what a human must verifyRestricts its own authority and escalates

The model was not retrained. Only its operating context changed. That shows why a system prompt is more than a persona: it sets authority, evidence standards, response order, and escalation. The benefits are higher-quality, more consistent responses, specialization, safety in one place, and lower token usage. There is also a quieter benefit: when product rules are written down you can test them, so "never invent refund eligibility" becomes an evaluation with evidence behind it.

System Prompt vs. User Prompt

So what is a user prompt? It is the message end users type: the actual question, the document to summarize, the task to perform. It changes every message. The system prompt, by contrast, is set once and persists across the whole conversation. It is the application-level contract; the user prompt works inside it.

System promptUser prompt
Who writes itThe developer or product ownerThe end user
When it is setOnce, before the conversationSent with every message
VisibilityUsually invisibleVisible
Typical contentRole, rules, tone, tools, output conventionsThe question, inputs, formatting requests
ScopeConversation-wideOne specific query
AuthorityHigher priorityFollowed when it does not conflict

System instructions usually win when the two conflict, which stops users from overriding safety measures, and because the system prompt is re-sent on every API call it also consumes tokens each time. One point of confusion: ChatGPT Custom Instructions are user-controlled personalization, not a developer system prompt, and fine-tuning changes model weights through training while a system prompt works at inference time. For a deeper breakdown, see the system prompt vs user prompt guide in the hub.

Key Components of a Good System Prompt

Different frameworks slice this differently (role, task, constraints, format, and more), but a practical version has nine parts: (1) identity/role, (2) objective, (3) behavior, (4) stable context, (5) boundaries, (6) tool rules, (7) output rules, (8) uncertainty behavior, and (9) priorities when goals conflict.

Be specific with the role: "You are a helpful assistant" activates nothing in particular, while "You are a technical documentation specialist with expertise in API design" sets expertise and expectations. Spell out tone and structure, and if downstream code reads the output, define the schema exactly. One habit matters most: separate stable instructions (role, objective, tone, source-of-truth rules, boundaries) from dynamic runtime context (customer data, retrieved documents, tool responses). And treat retrieved documents, web pages, and tool results as data, never as instructions, so a line like "ignore your previous instructions" buried in a document is not obeyed.

How to Write a System Prompt (Step by Step)

Here is how to write a system prompt that survives contact with real users. Start with the decisions the model has to make, not a long fictional biography.

  1. Name the role and objective. One or two lines. Who is it, and what outcome is it responsible for?
  2. Define authority. What may it decide or do on its own? What requires escalation or confirmation?
  3. Set the sources. Which supplied information should it trust, and what happens when evidence is missing?
  4. Add process rules. Required checks, ordering, or conditions for using tools.
  5. Write the output contract. Structure, length, tone, and any required fields.
  6. Define failure behavior. When should it ask a clarifying question, refuse, say it does not know, or hand off to a person?
  7. Test, then trim. Run real inputs, fix what breaks, and delete anything that does not change behavior.

Make every rule observable. "Do not hallucinate" gives the model no test it can apply. "Use only the supplied policy. If the answer is not there, say what is missing. Cite the clause you used" defines observable behavior you can check. The rule of thumb: if you cannot predict what the AI will do from reading your system prompt, rewrite it. For hallucinations specifically, name the source of truth, give an explicit "I do not have that information" fallback, require citations to supplied material, and tell the model to ask before guessing.

Want a head start? Our free ChatGPT prompt generator turns a rough goal into a structured prompt with audience, format, and constraints. Build your own system prompt.

System Prompt Examples (Copy and Adapt)

The best system prompt examples are shaped by the repeated decisions an AI must make for a specific application. Treat these as starting points, adapted not copied: each includes a failure condition, because a useful prompt has to say what happens when the model cannot safely finish the job.

Example 1: First-line support assistant

You are a first-line customer support assistant for [Company]. Be friendly,
patient, and professional.

You can help with: product information, order status, basic troubleshooting,
and account questions.
You cannot: process refunds, see payment information, or make account
changes. For those, explain how to reach our specialized support teams.

Rules:
- Acknowledge the customer's concern with empathy in one sentence.
- Use only supplied product information and verified documentation.
- Never invent account status, policies, or completed actions.
- If the answer is not in the supplied information, say what detail is
  missing and route the issue for human review.

Example 2: Socratic tutor

You are a tutor who always responds in the Socratic method.
- Never give the final answer. Ask guiding questions that help the
  student reason it out.
- Break the problem into simpler parts until it matches the learner level.
- Keep responses brief.

Example 3: Code review assistant

You are a code review assistant. Prioritize correctness, security,
data loss, and backward compatibility before style advice.
- Cite the file and line for each finding.
- Separate confirmed issues from suggestions.
- Never claim tests pass unless test output is supplied.
For each finding return: severity, evidence, impact, recommended correction.

System Prompts for Tools, Agents, and RAG

Once an assistant can call tools, browse documents, or take actions, the system prompt stops being about tone and starts being about authority. A strong version names which tool is authoritative for which fact, whether an action needs confirmation, and what to do when a tool fails. AI agents that change external state need autonomy rules, not personas: the goal, tools, action boundaries, and stopping conditions. For retrieval-augmented generation (RAG), the system prompt sets how retrieved evidence is used (strict mode answers only from context; mixed mode labels source-backed facts versus general knowledge) and always treats retrieved chunks as data, not instructions.

System Prompts Across OpenAI, Claude, and Gemini

The concept is shared across providers; the implementation is not, so if your app supports several, evaluate each one.

Model / platformWhere the system prompt goesWorth knowing
ChatGPT (app)Custom Instructions, Project instructions, or a custom GPTOpenAI's own system prompt sits underneath; yours is added on top
OpenAI APIinstructions or developer messagesDeveloper messages replace system messages for reasoning models
Claude (API)system parameterAnthropic publishes its Claude app system prompts
Geminisystem_instructionPut critical constraints and role first
GrokSystem role in the xAI APIxAI publishes the Grok app's system prompts on GitHub

If you want to compare how ChatGPT and Claude differ in writing style once prompted, see our breakdown of how ChatGPT and Claude writing differs.

How to Set a System Prompt in ChatGPT, Claude, Cursor, and the API

Whether you can set a system prompt depends on the platform. Consumer chat apps like ChatGPT and Claude.ai do not let you edit the underlying system prompt; they give you settings to customize instead. Developers working through an API have full control and set it in the application backend.

In ChatGPT: open Settings, then Personalization, and enter Custom Instructions. For a narrower scope, put instructions in a Project or build a custom GPT. Through the API: pass instructions (Responses API) or a developer message for OpenAI, the system parameter for Anthropic, and system_instruction for Gemini. AI coding tools (Claude Code, Cursor, GitHub Copilot, Codex) also ship a built-in system prompt and let you append your own through a project rules file, rather than replacing it.

For a website chatbot: pick one clear job, write the system prompt using the anatomy above, load it server-side (never ship it in front-end code), supply your FAQ or docs as retrieved context rather than permanent rules, add a human handoff, and test before launch.

Testing, Common Mistakes, and Security

A prompt that looks polished is not validated until it has been tested. Set measurable criteria first ("every answer includes at least one actionable step" beats "responses should be helpful"), build test sets covering typical, edge, missing-information, and adversarial inputs, then iterate one element at a time and keep every production failure as a permanent regression test.

Most system-prompt problems collapse into a short list: role-only prompting, vague rules ("be accurate") instead of observable actions, prompt bloat and conflicting rules, dynamic data baked in where it goes stale, and treating attempted actions as successful.

SymptomLikely fix
Ignored requirementMove it near the top and phrase it as an observable action ("max five bullets," not "be concise")
Format variesShow the exact structure and label required fields
Generic answersAdd audience, goal, context, and an example of the depth you want
Unsupported additionsRestrict sources, ban new facts, define the "insufficient info" reply
Works for one task, fails anotherSplit the workflow into separate prompts

One limit to remember: a system prompt guides behavior but is not a security boundary. Prompt injection ("Ignore all previous instructions...") can override it, and good models resist most such attacks but not all. Add an explicit rule against role changes, treat tool outputs and retrieved documents as data, and enforce permissions, validation, and human approval in code rather than trusting prompt text alone.

Conclusion

A system prompt is the behavioral contract between your product and the model, set before the first user message. The method is simple: write the smallest useful version, separate behavior from context, name your sources, define what happens when evidence is missing, test against real criteria, and move anything critical into deterministic software instead of trusting prompt text alone.

Ready to write yours? Start with our free prompt generator, then explore the rest of the System Prompts hub.

Resources and Further Reading

Platform details were checked against official documentation in October 2026 and change often, so verify against the linked docs before relying on them. See our editorial policy.

Main tool

A free prompt maker for ChatGPT: describe your task and it writes the prompt for you - ready-to-use prompt text you can copy and paste into ChatGPT, Claude or Gemini. As a prompt writer and prompt builder it turns rough goals into structured prompts with audience, format, constraints, and context built in.

Open ChatGPT Prompt Generator

FAQ

What is a system prompt in AI?▾

A system prompt is a set of high-level instructions, guidelines, and contextual information a language model receives before the user's request. It defines the assistant's role, objectives, boundaries, tool behavior, output rules, and uncertainty handling, and it shapes how the model responds for the whole conversation.

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

A system-level (or developer-level) instruction sets the standing role, rules, authority, and response requirements for the application. The user prompt supplies the current task or immediate question. User instructions are followed when they do not conflict with higher-priority platform instructions, and the exact authority hierarchy depends on the provider and API.

What is the purpose of a system prompt?▾

Its purpose is to turn a general model into a specialized, consistent assistant. It sets behavior once so every request is handled under the same rules, improving accuracy, tone, format, and safety.

How long should a system prompt be?▾

Long enough to define the required behavior (objective, authority, evidence boundaries, required checks, output contract, failure behavior) and no longer. Cut repeated prose, contradictions, and anything that does not change a decision. Every line adds context overhead, so add rules based on measured needs, not repetition.

How do I set a system prompt in ChatGPT, Cursor, or the API?▾

Each platform names the field differently: in ChatGPT use Custom Instructions or Project instructions; in the API use the system parameter (Anthropic), system_instruction (Gemini) or instructions and developer messages (OpenAI). Our System Prompts hub has the full setup steps and code for each platform.

Do AI models reveal their system prompts?▾

Generally providers instruct models not to share them, but leaks still happen through prompt injection, and some companies (including Anthropic and xAI) publish theirs voluntarily. Do not put anything secret in a system prompt, and do not rely on the model to keep it confidential.

What should a good system prompt include?▾

Identity, primary objective, behavioral rules, stable domain context, boundaries, tool rules, output rules, uncertainty behavior, and priorities. Which ones you need depends on the application.

Is "You are an expert" a good system prompt?▾

It is a useful role instruction, but it is rarely sufficient. Production system prompts also need goals, boundaries, source rules, uncertainty behavior, tools, and output requirements.

Related tools

ChatGPT Prompt Generator

Generate powerful AI prompts instantly

Try tool
AI Paragraph Rewriter

Rewrite any text in seconds

Try tool
AI Tone Changer

Change the tone of any text instantly

Try tool

Related workflows

More in the System Prompts & Advanced guide