System Prompt: Definition, Examples and API Setup

November 11, 2026 · 12 min read

System Prompt: What It Is and How It Differs From a User Prompt

A system prompt is the set of standing instructions an app sends to a language model before the conversation starts. It sets the model's role, scope, tone and output format for every reply. The person chatting usually never sees it. This guide shows where it goes in real APIs and gives complete examples you can adapt.

What Is a System Prompt in AI?

In AI chat apps, every request to the model carries more than your message. The app adds its own standing instructions first, ahead of anything you type. Anthropic's API reference describes them as a way of giving the model context and instructions, such as a goal or a role.

These instructions come from the app developer, not the person typing into the chat box. When you use a chat app, the company behind it has already written them for you. When you call a model through an API, you write your own LLM system prompt and send it with each request.

A useful mental model is a job description. It fits every AI system prompt, from a customer support bot to a coding agent. Each user message is a task handed over during the shift, while the job description stays the same.

What Is the Purpose of a System Prompt?

Its purpose is to set behaviour once so nobody has to repeat it in every message. Typical jobs include:

  • Role: who the model is acting as, such as a support agent for one product or a code reviewer.
  • Scope: which questions it answers and what it does with off-topic requests.
  • Tone and audience: formal or casual, beginner or expert readers.
  • Output format: length limits, numbered steps, JSON, or plain prose.
  • Standing context: facts that hold for the whole session, like product plans or today's date.
  • Refusals and escalation: what it won't do, and where it sends people instead.

Output format rules are one reason chatbots so often answer in headings and bullet points, which our post on Markdown in AI explains.

System Prompt vs User Prompt: Who Writes What

The user prompt vs system prompt difference comes down to who writes each one and how long it lasts. The user prompt is the request right now, and the standing instructions are the rulebook it runs under. A third role, the assistant, holds the model's earlier replies so it can follow the thread.

System promptUser prompt
Written byThe app developerThe person using the app
ChangesRarely, between releasesEvery turn
HoldsRole, rules, format, standing contextThe question or task
Where it goes in an APIA system field, or a developer or system roleA message with the user role
PriorityModels are trained to weight it higherFollowed within the system rules

That last row is a trained tendency, not a guarantee. OpenAI's text generation guide says developer messages are prioritized ahead of user messages. Its Model Spec goes further and reserves system messages for OpenAI itself, ranked above developers. A persistent user can still sometimes talk a model out of its instructions, and that shapes what you should keep out of them.

So in any system vs user prompt comparison, the real difference is control. You decide what the standing instructions say, and your users decide what they ask.

Where System Instructions Go in the API Messages Array

Most chat APIs model a conversation as a list of messages, each with a role. Here's the generic shape, with the standing instructions first:

[
  { "role": "system", "content": "You are a support assistant for Acme Notes. Answer only questions about Acme Notes." },
  { "role": "user", "content": "How do I export a note?" },
  { "role": "assistant", "content": "Open the note, then choose Export from the menu." },
  { "role": "user", "content": "Can I export it as a PDF?" }
]

The model reads the whole list on every call. It keeps no memory between requests, so each call has to carry the system message and the history it needs.

Each provider names the field differently. This table follows each one's official docs as of November 2026:

ProviderField for the standing instructionsNotes
Anthropic Messages APITop-level system parameterThe messages list carries the user and assistant turns
OpenAI Responses APIinstructions parameter, or a developer message in inputinstructions applies only to the current request
Google Gemini APIsystem_instruction fieldSome SDKs use camelCase, such as systemInstruction in Java

Anthropic's Messages API takes the instructions as a top-level system field, as its prompting docs show. A request body looks like this, with a placeholder where your model ID goes:

{
  "model": "your-model-id",
  "max_tokens": 1024,
  "system": "You are a support assistant for Acme Notes.",
  "messages": [
    { "role": "user", "content": "How do I export a note?" }
  ]
}

The system string sits beside the conversation rather than inside it. OpenAI's Responses API does the same job with instructions, but its docs warn that instructions from earlier turns aren't carried over when you chain responses with previous_response_id. Resend them on every request. Gemini's text generation docs pass the same kind of string as system_instruction.

How to Structure a System Prompt With Markdown Headings and Lists

A two-line prompt doesn't need structure. A forty-line one does, because you and the model both need to find the rules fast. Markdown headings split the prompt into sections, and lists turn each rule into one scannable line.

A skeleton that works for most apps:

  • # Role: one or two sentences on who the model is.
  • ## Context: facts it needs for every answer.
  • ## Rules: what to do and what never to do.
  • ## Output format: length, structure and tone.
  • ## Examples: one short sample exchange, if the format is unusual.

The order matters less than consistency, but we put the role first so every rule after it reads in context. Keep each rule to one line. Write it as an instruction the model can act on, such as "Reply in under 100 words", not a hope such as "Be concise".

Anthropic's prompting docs recommend XML tags such as <instructions> and <context> for the same job. Both approaches work, so pick one per prompt and stick to it. We prefer Markdown headings for prompts a team maintains, because a Git diff of a Markdown prompt stays readable. If you need a syntax refresher, see our guides to Markdown headings and Markdown lists, or the full Markdown cheat sheet.

One side effect to know about: Anthropic's docs note that the formatting style of your prompt can influence the style of the replies. A prompt full of bullets can nudge the model toward bulleted answers, so state the output format you want explicitly.

Here's a short structured prompt. Edit it and the preview shows whether the headings and lists nest the way you meant.

Role

You are a support assistant for Acme Notes, a Markdown note app.

Context

  • Plans: Free and Pro
  • Users write notes in a browser editor

Rules

  • Answer only questions about Acme Notes
  • If you don't know, say so and link the help page
  • Never ask for passwords or card numbers

Output format

  • Start with a one-sentence answer
  • Then give steps as a numbered list
  • Keep replies under 150 words
81 words410 characters16 lines
Markdown

System Prompt Examples You Can Adapt

Each example below is complete. Paste it into the system field of your API call, then swap in your own product facts and rules. For prompts you paste into a chat window instead, see our AI prompt templates.

Example 1: Customer support for a rental shop

# Role
You are the booking assistant for Harbor Bikes, a bike rental shop in a seaside town.

## Context
- Rentals run by the hour or by the day
- Every rental includes a helmet and a lock
- Customers book on the website and pay at pickup

## Rules
- Answer questions about bookings, bikes, routes and opening hours
- For refunds or damage claims, tell the customer to email the shop
- Don't invent prices; if a price isn't listed here, say you don't know
- Never collect card details or ID numbers in the chat

## Output format
- Reply in two to four short sentences
- Use a numbered list only for step-by-step instructions
- Keep a friendly, plain tone with no jargon

This prompt keeps the model on topic and sends money questions to a human. The rule about prices stops it from guessing a figure that isn't in its context.

Example 2: Code review assistant

# Role
You review pull requests for a TypeScript web app.

## What to check
- Bugs and unhandled errors
- Security issues such as unescaped user input
- Missing tests for new behaviour

## What to skip
- Formatting and style, which the linter already enforces
- Personal preferences that aren't backed by a bug or risk

## Output format
- One Markdown list item per finding
- Start each item with a severity: High, Medium or Low
- Name the file and line, then explain the fix in one or two sentences
- If you find nothing, reply with: No issues found.

The skip list matters as much as the check list. Without it, reviews fill up with style nitpicks the team has already automated.

Example 3: The shortest useful version

You are a patient math tutor for students aged 12 to 14.
Explain one step at a time and check understanding before moving on.
Don't give the final answer until the student has tried.
Use short sentences and everyday examples.

Four lines cover role, audience, method and style. Start this small and add sections only when real conversations show a gap.

Whichever example you start from, test it before you ship it. Run the conversations you expect, then a few awkward ones: an off-topic question, a rude message, and a question the context can't answer. Each failure tells you which rule is missing or unclear. Change one rule at a time so you know which edit fixed it.

What Doesn't Belong in a System Prompt

Some things look convenient to put in the prompt and cause trouble later:

  1. Secrets. API keys, passwords, database names and internal URLs. The OWASP Top 10 entry LLM07:2025 says the prompt itself shouldn't be treated as a secret. Assume users can get the model to reveal every word.
  2. Per-request data. The current user's order or the document they uploaded belongs in the user turn, not in standing rules.
  3. Huge reference dumps. Pasting a whole manual makes every call slower and costlier. Retrieve the relevant passage per request instead.
  4. Vague or conflicting rules. "Be brief" next to "explain everything in detail" leaves the model guessing which one wins.

The honest limitation: these instructions steer the model, but they don't enforce anything. Prompt injection, where a user or a document slips in competing instructions, can override them. OWASP advises keeping access control and other hard limits in your own code, outside the model.

CLAUDE.md, AGENTS.md and Cursor Rules: Persistent Instructions in a Repo

Coding agents add another layer: Markdown files in your repository that the agent loads as standing instructions, on top of the agent's own built-in instructions. They hold your project's commands, conventions and no-go zones.

  • CLAUDE.md: Claude Code's memory docs say it's delivered as a user message after the system prompt, not inside it.
  • AGENTS.md: an open format that agents.md describes as a README for agents, read by several coding tools.
  • Cursor rules: Cursor's docs say rule contents are included at the start of the model context. Our Cursor rules guide covers the file format and rule types.

Our CLAUDE.md generator builds CLAUDE.md, AGENTS.md, .cursorrules and copilot-instructions.md from one form you fill in.

Frequently Asked Questions

A good system prompt is short, specific and easy to scan, with the role first, then context, rules and output format. Keep secrets out and enforce hard limits in code. To draft one, write it in the editor, where the preview shows your headings and lists as you type and the status bar counts words. Copy the Markdown or download it as a .md file when it's ready.