# How to write a system prompt, with a worked example

> A system prompt is the standing instruction you give a model before a conversation starts. It sets the role, the rules, the tone and the output format for every reply. You write one in four parts: an identity, the instructions, an example and the context. Where it goes depends on the API.

Mindket editors · Published 2026-11-04 · Updated 2026-11-05 · https://mindket.com/learn/prompt-engineering/system-prompt

## In short

- A system prompt holds the rules that stay the same for every message, such as role, tone and format.
- Write it in four parts: identity, instructions, examples and context.
- Each vendor names the field differently: system, instructions or system_instruction.
- Start small and add a rule only when a real failure shows you need it.

## Before you start

You need a place to set standing instructions. That can be the `system` parameter of an API call or the `instructions` argument of an agent in OpenAI's [Agents SDK](https://cdn.openai.com/business-guides-and-resources/a-practical-guide-to-building-agents.pdf). In Claude Code it is a CLAUDE.md file, which [stores instructions](https://code.claude.com/docs/en/how-claude-code-works) that Claude should know every session. Without any of them you can still follow along, because the writing is the same.

Pick a job the model should do the same way every time. The sample below answers customer questions for one small shop, and you can swap in your own.

## Write a system prompt in four parts

OpenAI's [guide](https://developers.openai.com/api/docs/guides/prompt-engineering) says a developer message usually has four sections in this order: identity, instructions, examples and context. Google's [template for Gemini 3](https://aistudio.google.com/docs/prompting-strategies) splits a system instruction into a role, numbered instructions, constraints and an output format. The sample follows OpenAI's order. It uses Markdown headers for the sections and XML tags around the example and the pasted policy, the two ways OpenAI describes for marking sections and delimiting content.

````text
# Identity
You are the order-help assistant for a small online tea shop. You write in a friendly, plain style.

# Instructions
- Answer questions about orders, shipping and returns using only the policy in the Context section.
- If the policy does not cover the question, say so and offer to pass it to the shop owner.
- Keep every answer under 80 words and end with one clear next step.
- Reply in the language the customer wrote in.

# Examples
<customer_message>
Where is my order?
</customer_message>
<assistant_response>
Please send me the order number from your confirmation email, and I will pass your question to the shop owner.
</assistant_response>

# Context
<policy>
[paste your shipping and returns policy here]
</policy>
````

1. **Give it an identity.** One sentence on who the model is and who it serves. Anthropic's [guide](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices) says even a single sentence of role in the system prompt focuses the model's behavior and tone.
2. **List the rules.** Say what to do, where answers must come from and what to do when the model cannot answer. Keep each rule to one line, so you can tell later which one failed.
3. **Set the format.** Give the length, the tone and the shape of the reply. Google's template has slots for verbosity, tone and an output structure.
4. **Add an example or two.** Wrap each pair in tags, as OpenAI's example does, so the model can tell it from the instructions.
5. **Put reference text in its own block.** Paste the policy, price list or FAQ the model should answer from, under a label. OpenAI says this context is usually best near the end of the prompt.

## Where each vendor puts it

The idea is the same everywhere and the field name is not. If you move a prompt between providers, this is the part you rewrite. The names below come from the [Anthropic](https://platform.claude.com/docs/en/api/messages), [OpenAI](https://developers.openai.com/api/docs/guides/prompt-engineering) and [Google](https://aistudio.google.com/docs/text-generation) pages.

| Vendor | Where the system prompt goes | What the docs say |
| --- | --- | --- |
| Anthropic Messages API | The top-level `system` parameter, beside `messages` | A string or an array of text blocks. The reference calls it a way of providing context and instructions to Claude, such as a particular goal or role. |
| OpenAI Responses API | The `instructions` parameter, or a message with the `developer` role | Developer messages are prioritized ahead of `user` messages. `instructions` applies only to the current request. |
| Google Gemini API | The `system_instruction` parameter | The docs example sets "You are a cat. Your name is Neko." for a request. |

## What a system prompt can and cannot do

It does not carry over by itself. OpenAI notes that when you continue a conversation with `previous_response_id`, the `instructions` used on previous turns are not present in the context, so send them again.

Chat products set one for you. Anthropic [publishes](https://platform.claude.com/docs/en/release-notes/system-prompts) the system prompts behind claude.ai and its mobile apps. They supply details such as the current date and encourage behaviors such as always giving code snippets in Markdown, and Anthropic says they do not apply to the Claude API.

Those prompts are long and change often. Since 1 September 2026, Anthropic has posted nine dated entries for its four newest models, shown below. By our count the newest Opus 5.5 entry runs to about 4,800 words. It holds a `{{currentDateTime}}` placeholder where the app fills in the date, and it tells the model that its reliable knowledge stops at the end of June 2026. When an app starts behaving differently and the model has not changed, read the newest entry first.

A system prompt is also something users try to read. OpenAI's [guide to building agents](https://cdn.openai.com/business-guides-and-resources/a-practical-guide-to-building-agents.pdf) names preventing system prompt leaks as a data privacy risk that guardrails should cover.

> **Our view**
>
> Treat a system prompt as text a determined user can read. Keep keys, passwords and private customer data out of it, and enforce permissions in your own code.

**Dated system prompt entries for Claude's apps since September 2026**

1. **September 1, 2026** Claude Fable 5.1. The first entry on its page.
2. **September 22, 2026** Claude Opus 5.5. The first entry on its page.
3. **September 28, 2026** Claude Sonnet 5.5. The first entry on its page.
4. **October 7, 2026** Claude Haiku 5.5. The first entry on its page.
5. **October 7, 2026** Claude Sonnet 5.5. A second entry.
6. **October 26, 2026** Claude Haiku 5.5. A second entry.
7. **October 27, 2026** Claude Opus 5.5. A second entry.
8. **October 27, 2026** Claude Sonnet 5.5. A third entry.
9. **October 30, 2026** Claude Fable 5.1. A second entry, the newest of the nine.

Sources: [Anthropic: Claude Fable 5.1 system prompts](https://platform.claude.com/docs/en/release-notes/system-prompts/claude-fable-5-1) (read 2026-11-05), [Anthropic: Claude Opus 5.5 system prompts](https://platform.claude.com/docs/en/release-notes/system-prompts/claude-opus-5-5) (read 2026-11-05), [Anthropic: Claude Sonnet 5.5 system prompts](https://platform.claude.com/docs/en/release-notes/system-prompts/claude-sonnet-5-5) (read 2026-11-05), [Anthropic: Claude Haiku 5.5 system prompts](https://platform.claude.com/docs/en/release-notes/system-prompts/claude-haiku-5-5) (read 2026-11-05)

## Start small, then grow it from failures

Anthropic's [context engineering article](https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents) describes two ways a system prompt goes wrong. At one extreme, engineers hardcode complex, brittle logic to get exact behavior. At the other, they give vague, high-level guidance. Its advice is to test a minimal prompt on the best model available, then add clear instructions and examples based on the failures you see.

The same article prefers a curated set of diverse, canonical examples over a long list of edge-case rules, so reach for an example before a new rule.

Tone matters in both directions. Anthropic's guide says Claude Opus 4.5 and 4.6 respond more strongly to the system prompt than earlier models. Shouting such as "CRITICAL: You MUST use this tool when..." can now make them overuse a tool, and plain wording like "Use this tool when..." works better.

If one prompt serves many users, OpenAI's agent guide suggests a single base prompt with variables, such as the customer's first name and how long they have been a member, instead of many near-copies.

## Amanda Askell and Alex Albert on the system prompt behind Claude's apps

Amanda Askell, a philosopher and ethicist at Anthropic, [posted Claude 3's system prompt on X on 6 March 2024](https://x.com/AmandaAskell/status/1765207842993434880) with a thread breaking it down. Alex Albert, who works in research at Anthropic, followed five months later. On 26 August 2024 he [announced](https://x.com/alexalbert__/status/1828107230656471442) that changes to the default system prompts for claude.ai and the mobile apps would be logged in the docs from then on.

That log is the release notes page in the timeline above, still running more than two years later. Read the newest entry for the model you use. It is a working system prompt from the people who train the model. You can borrow its habits for your own: give the model the current date and say plainly what it does not know.

> We're going to log changes we make to the default system prompts on Claude dot ai and our mobile apps. (The system prompt does not affect the API.)
>
> Alex Albert, Research at Anthropic, [X](https://x.com/alexalbert__/status/1828107230656471442) (read 2026-11-05)

[![Amanda Askell (@AmandaAskell) on X, 6 March 2024, opening a thread that breaks down Claude 3's system prompt.](https://mindket.com/blog/shots/x-amandaaskell-claude-3-system-prompt.webp?v=dab2c5238a89)](https://x.com/AmandaAskell/status/1765207842993434880)

Amanda Askell on X, 6 March 2024

[![Alex Albert (@alexalbert__) on X, 26 August 2024. We've added a new system prompts release notes section to our docs.](https://mindket.com/blog/shots/x-alexalbert-system-prompt-notes.webp?v=2e5fcdba742a)](https://x.com/alexalbert__/status/1828107230656471442)

Alex Albert on X, 26 August 2024

> Screenshots of X's own embeds of the posts, taken on 5 November 2026, with the time in UTC. Askell's breakdown is in the thread under her post. Select one to open the post on X.

## Common mistakes

- Pasting a whole manual into the prompt. For data the model was not trained on, OpenAI points to retrieval and its file search tool.
- Writing rules without reasons. Add the reason, as in [lesson 1](https://mindket.com/learn/prompt-engineering/prompt-engineering-basics), so the model can apply the rule to cases you did not list.
- Adding a dozen rules at once, then not knowing which one changed the answer.
- Testing only friendly inputs. OpenAI's agent guide uses "Ignore all previous instructions" as an example of a hostile input, so try one on your own prompt.

## Try it yourself

- Write the four parts for a job you want done the same way every time.
- Send five different user messages through it, and make one of them ask the model to ignore its rules.
- Note each miss in one line. Fix the first with an example, not a new rule, and run all five again.

## Next: the context window

A system prompt is sent with every request, so it takes up room. The next lesson, [what a context window is](https://mindket.com/learn/prompt-engineering/context-window), shows what else fills that room and what happens when it runs out.

In Claude Code the standing instructions live in a file, which [what goes in a CLAUDE.md file](https://mindket.com/blog/claude-md-file) covers in detail.

## Check yourself

1. In the Anthropic Messages API, where does the system prompt go?

   A. The instructions parameter
   B. The system_instruction parameter
   C. The top-level system parameter, beside messages
   D. A message with the developer role

   Answer: C. The lesson's table says Anthropic uses a top-level system parameter, while OpenAI uses instructions and Google uses system_instruction.

2. Which four parts does the lesson use to write a system prompt, in order?

   A. Identity, instructions, examples, context
   B. Context, examples, identity, instructions
   C. Role, tools, memory, output
   D. Goal, steps, risks, summary

   Answer: A. OpenAI's guide says a developer message usually has identity, instructions, examples and context in that order, and the sample follows it.

3. You continue a conversation with previous_response_id and the model stops following your rules. What is the likely cause?

   A. The prompt was too long to fit
   B. The model only reads the first message
   C. Developer messages are ignored after the first turn
   D. The instructions from earlier turns are not carried over, so you must send them again

   Answer: D. OpenAI notes that the instructions used on previous turns are not present in the context when you continue with previous_response_id.

4. One user message breaks your system prompt. What does the lesson say to try before adding a new rule?

   A. Repeat the rule in capital letters with MUST
   B. Add an example of the answer you want
   C. Paste your whole manual into the prompt
   D. Remove the identity sentence

   Answer: B. Anthropic prefers a curated set of diverse, canonical examples over a long list of edge-case rules, so reach for an example first.

## Frequently asked questions

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

The system prompt sets standing rules for the whole conversation, and the user prompt is what someone asks in one message. In OpenAI's API the developer role is prioritized ahead of the user role, and OpenAI compares the two to a function and its arguments.

### How long should a system prompt be?

Short at first. Anthropic's engineering team suggests starting with a minimal prompt and adding instructions and examples as failures show up. A long one also costs room, because the system prompt counts toward the context window.

### Do chat apps have their own system prompt?

Claude's apps do, and Anthropic keeps a page per model, some with several dated entries. We read only Anthropic's page, so check other vendors for theirs.

### Where does reference material go in the prompt?

Long documents go above your question. Anthropic says to put documents of 20k tokens or more above the query, and Google's [long context page](https://aistudio.google.com/docs/long-context) says to put the question at the end of a long context. OpenAI's developer-message template puts context near the end instead, so for a short system prompt follow your vendor's template.

### Can a user override my system prompt?

A determined user can try, so never rely on the prompt alone for anything sensitive. OpenAI's agent guide calls guardrails a layered defense and pairs them with authentication, authorization and strict access controls.

### Should I write a system prompt in Markdown or XML?

Either works. Anthropic says XML tags help the model parse prompts that mix instructions, context, examples and inputs, and recommends consistent, descriptive tag names. Pick one style and keep it.

## Sources

- [Anthropic: Prompting best practices](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices) (read 2026-11-05)
- [Anthropic: Messages API reference](https://platform.claude.com/docs/en/api/messages) (read 2026-11-04)
- [Anthropic: System prompts release notes](https://platform.claude.com/docs/en/release-notes/system-prompts) (read 2026-11-05)
- [Anthropic Engineering: Effective context engineering for AI agents](https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents) (read 2026-11-04)
- [OpenAI: Prompt engineering](https://developers.openai.com/api/docs/guides/prompt-engineering) (read 2026-11-04)
- [OpenAI: A practical guide to building agents](https://cdn.openai.com/business-guides-and-resources/a-practical-guide-to-building-agents.pdf) (read 2026-11-04)
- [Google AI Studio: Text generation](https://aistudio.google.com/docs/text-generation) (read 2026-11-04)
- [Google AI Studio: Prompt design strategies](https://aistudio.google.com/docs/prompting-strategies) (read 2026-11-04)
- [Google AI Studio: Long context](https://aistudio.google.com/docs/long-context) (read 2026-11-04)
- [Claude Code docs: How Claude Code works](https://code.claude.com/docs/en/how-claude-code-works) (read 2026-11-04)
- [Anthropic: Claude Fable 5.1 system prompts](https://platform.claude.com/docs/en/release-notes/system-prompts/claude-fable-5-1) (read 2026-11-05)
- [Anthropic: Claude Opus 5.5 system prompts](https://platform.claude.com/docs/en/release-notes/system-prompts/claude-opus-5-5) (read 2026-11-05)
- [Anthropic: Claude Sonnet 5.5 system prompts](https://platform.claude.com/docs/en/release-notes/system-prompts/claude-sonnet-5-5) (read 2026-11-05)
- [Anthropic: Claude Haiku 5.5 system prompts](https://platform.claude.com/docs/en/release-notes/system-prompts/claude-haiku-5-5) (read 2026-11-05)
- [Amanda Askell on X, 6 March 2024](https://x.com/AmandaAskell/status/1765207842993434880) (read 2026-11-05)
- [Alex Albert on X, 26 August 2024](https://x.com/alexalbert__/status/1828107230656471442) (read 2026-11-05)

[Browse agents](https://mindket.com/agents)
