Mindket

How to write a system prompt, with a worked example

A black banner titled "Prompt engineering" over the line "Prompts, system prompts, context windows and AI agents."

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.

In this lesson

  • 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.
All courses
On this page
  1. Before you start
  2. Write a system prompt in four parts
  3. Where each vendor puts it
  4. What a system prompt can and cannot do
  5. Start small, then grow it from failures
  6. Amanda Askell and Alex Albert on the system prompt behind Claude's apps
  7. Common mistakes
  8. Try it yourself
  9. Next: the context window
  10. Check yourself
  11. Frequently asked questions
  12. Sources

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. In Claude Code it is a CLAUDE.md file, which stores instructions 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 says a developer message usually has four sections in this order: identity, instructions, examples and context. Google's template for Gemini 3 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.

# 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 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, OpenAI and Google pages.

Field names as the three vendors' API pages give them.
VendorWhere the system prompt goesWhat the docs say
Anthropic Messages APIThe top-level system parameter, beside messagesA 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 APIThe instructions parameter, or a message with the developer roleDeveloper messages are prioritized ahead of user messages. instructions applies only to the current request.
Google Gemini APIThe system_instruction parameterThe 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 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 names preventing system prompt leaks as a data privacy risk that guardrails should cover.

Dated system prompt entries for Claude's apps since September 2026
  1. Claude Fable 5.1

    The first entry on its page.

    Source: Anthropic: Claude Fable 5.1 system prompts (read November 5, 2026)

  2. Claude Opus 5.5

    The first entry on its page.

    Source: Anthropic: Claude Opus 5.5 system prompts (read November 5, 2026)

  3. Claude Sonnet 5.5

    The first entry on its page.

    Source: Anthropic: Claude Sonnet 5.5 system prompts (read November 5, 2026)

  4. Claude Haiku 5.5

    The first entry on its page.

    Source: Anthropic: Claude Haiku 5.5 system prompts (read November 5, 2026)

  5. Claude Sonnet 5.5

    A second entry.

    Source: Anthropic: Claude Sonnet 5.5 system prompts (read November 5, 2026)

  6. Claude Haiku 5.5

    A second entry.

    Source: Anthropic: Claude Haiku 5.5 system prompts (read November 5, 2026)

  7. Claude Opus 5.5

    A second entry.

    Source: Anthropic: Claude Opus 5.5 system prompts (read November 5, 2026)

  8. Claude Sonnet 5.5

    A third entry.

    Source: Anthropic: Claude Sonnet 5.5 system prompts (read November 5, 2026)

  9. Claude Fable 5.1

    A second entry, the newest of the nine.

    Source: Anthropic: Claude Fable 5.1 system prompts (read November 5, 2026)

Start small, then grow it from failures

Anthropic's context engineering article 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 with a thread breaking it down. Alex Albert, who works in research at Anthropic, followed five months later. On 26 August 2024 he announced 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 (read November 5, 2026)
Amanda Askell (@AmandaAskell) on X, 6 March 2024, opening a thread that breaks down Claude 3's system prompt.
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.
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, 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, 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 covers in detail.

Check yourself

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

    Show answer

    C. The top-level system parameter, beside messages 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?

    Show answer

    A. Identity, instructions, examples, context 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?

    Show answer

    D. The instructions from earlier turns are not carried over, so you must send them again 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?

    Show answer

    B. Add an example of the answer you want 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 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

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

Share this lesson

Compare how other agents are set up

Browse the agents listed on Mindket, and read how each one works before you write your own instructions.

Browse agents

This lesson as Markdown · Prompt engineering course for beginners · All courses