How to Write a System Prompt That Actually Works

To write a system prompt that works, give the model the context a new colleague would need: a role, the task, the reason behind each rule, a few examples and a clear output shape. Then state your defaults on purpose, because users will absorb the opinions your prompt quietly sets.

Editorial title card reading "How to Write a System Prompt That Actually Works" beside the orange ZeroRaised mark.

Key takeaways

  • Give the model a role, the task, the context and the reason behind each rule.
  • Show 3 to 5 relevant, diverse examples wrapped in XML tags instead of describing the pattern.
  • Put long documents near the top and the query at the end; Anthropic's tests saw up to 30 percent better quality.
  • Tell the model what to do, not what to avoid, and drop CRITICAL and MUST phrasing that makes newer models overtrigger.
  • For agents, name the reversible actions and require approval for everything hard to undo.
On this page 13
  1. Start with the colleague test
  2. Give the model a role and a reason
  3. How many examples should you include?
  4. Use XML tags to separate the parts
  5. Where should long documents and the query go?
  6. Say what to do, not what to avoid
  7. Why you should stop shouting CRITICAL and MUST
  8. What changes when the prompt drives an agent?
  9. State your defaults on purpose
  10. A sample system prompt for a SaaS support bot
  11. A checklist before you ship
  12. Where ZeroRaised fits
  13. Sources

A system prompt works when it gives the model what a new colleague would need: the job, the reason behind each rule and what good output looks like. Anthropic frames Claude as a brilliant but new employee who lacks context on your norms and workflows (Anthropic). Write the brief you would give a capable contractor, then test it.

TL;DR

  • Give the model a role, the task, the context and the reason behind each rule.
  • Show 3 to 5 relevant, diverse examples in XML tags instead of describing the pattern.
  • Put long documents near the top and the query at the end; Anthropic saw up to 30 percent better quality in tests.
  • Tell the model what to do, not what to avoid, and drop CRITICAL and MUST phrasing that makes newer models overtrigger.

Disclosure: ZeroRaised publishes this guide and is a launch and discovery site for bootstrapped products. Facts come from the linked sources as checked on 29 Oct 2026; ZeroRaised has no commercial relationship with the companies named.

A system prompt is the standing set of instructions that tells a model who it is, what job it is doing and how to behave before any user message arrives.

Start with the colleague test#

Anthropic's key test is to show the prompt to a colleague with minimal context. If they would be confused, the model will be too (Anthropic). You know what "handle billing properly" means; a model does not. Replace the shorthand with the policy, an example and the reason.

Give the model a role and a reason#

Put a role in the prompt. Anthropic says even a single sentence makes a difference (Anthropic). "You are the support assistant for a small invoicing tool" narrows the vocabulary and assumptions better than a page of tone adjectives.

Then explain why each hard rule exists. Anthropic's example is text-to-speech software that cannot pronounce ellipses: the constraint beats a bare ban (Anthropic). Context lets the model apply the rule to cases you did not anticipate.

How many examples should you include?#

Anthropic recommends 3 to 5 examples for best results (Anthropic). They should be relevant, diverse, structured the same way and wrapped in tags. Examples show the pattern instead of describing it. Make every example something you would be happy to ship, because the model copies the style as well as the logic.

Use XML tags to separate the parts#

Anthropic recommends XML tags to separate instructions, context, examples and inputs (Anthropic). Tags draw a boundary between the rule that says what to do and the text it should act on. That makes a prompt easier to debug: if the answer ignored a rule, you can see which block held it. Clear structure is also a precondition for the security work in the prompt injection guide.

Where should long documents and the query go?#

For long context above 20k tokens, Anthropic recommends putting documents near the top and the query at the end. It reports that queries at the end can improve response quality by up to 30 percent in tests (Anthropic). Put the material first, the instruction last.

Say what to do, not what to avoid#

Anthropic is direct: tell the model what to do instead of what not to do (Anthropic). "Reply in two sentences with the next step" gives a target. "Do not ramble" names a failure without a fix. Rewrite prohibitions where you can: "Escalate refund requests to a human" is testable, while "do not handle refunds yourself" leaves the agent to invent the alternative.

Why you should stop shouting CRITICAL and MUST#

Anthropic says newer models are more responsive to the system prompt, and recommends replacing "CRITICAL: You MUST use this tool when..." with "Use this tool when..." to avoid overtriggering (Anthropic). Emphasis that used to secure compliance now pushes a model to act when it should not. Write the trigger condition plainly, and save strong language for cases that justify it.

What changes when the prompt drives an agent?#

For agents, Anthropic recommends encouraging local, reversible actions and asking before hard-to-reverse or shared-system actions (Anthropic). List what the agent may do without asking: read a record, draft a reply, search a sandbox. Then list what needs a person: sending email, deleting data, moving money, changing a shared setting. If the prompt says ask first but the tool has no approval step, it is a wish. The agent sandbox guide covers the controls.

State your defaults on purpose#

A system prompt also gives an agent opinions, and users absorb them. Anthropic tested this with 50 professional analysts on a realistic statistical task. Each agent's lean on four choices was set by coin flip through hidden system prompt instructions. The analysts followed the lean 86% of the time, repeated the agent's argument in at least one answer 77% of the time, and only 15% credited the agent (Anthropic research). Choose them. Decide the stance on refunds, escalation, tone and what the assistant will not decide. The analysis of that study covers the decision side.

A sample system prompt for a SaaS support bot#

Here is a short example, not copied from a vendor.

<role>
You are the support assistant for Acme, a small invoicing tool for freelancers.
</role>

<context>
You answer questions from paying customers. Billing changes are sensitive.
You cannot issue refunds above 50 dollars or change a plan without a human.
</context>

<rules>
- Answer the question first, in two sentences or fewer.
- Use the help centre excerpts in <docs>. If they do not cover it, say so and offer to escalate.
- For refunds, cancellations and account deletion, confirm the request and hand it to a human.
- State a delivery date or discount only when it appears in <docs>.
</rules>

<examples>
<example>
<customer>Can I get a refund for last month?</customer>
<answer>I can pass that to the billing team. Can you confirm the invoice number? A person will reply within one working day.</answer>
</example>
</examples>

<docs>
{{retrieved_help_centre_excerpts}}
</docs>

It states the job, the limits and the handoff rather than things not to do, and the query arrives after the documents, following Anthropic's ordering (Anthropic).

A checklist before you ship#

  1. Run the colleague test.
  2. Add a role and a plain task description.
  3. Explain why each hard rule exists.
  4. Add 3 to 5 tagged examples.
  5. Separate instructions, context, examples and inputs with XML tags.
  6. Put long documents first and the query last.
  7. Name reversible agent actions and require approval for the rest.
  8. State product defaults explicitly.
  9. Test realistic inputs and evaluate outputs against a written standard.

Where ZeroRaised fits#

ZeroRaised is a launch and discovery site for products built without institutional venture capital or accelerator equity. If you have shipped an AI product and can describe how its prompts and defaults work, submit your product. The pricing page explains the current options.

For more practical analysis, join the ZeroRaised newsletter. No promises of traffic or results, just the useful parts.

Sources#

Frequently asked questions

What is a system prompt?

A system prompt is the standing instruction set that tells a model who it is, what job it is doing and how it should behave before any user message arrives. It is where you put role, rules, tone, examples and boundaries.

How long should a system prompt be?

Long enough to remove ambiguity and no longer. Anthropic recommends including a role, context and 3 to 5 examples, and separating the parts with XML tags. A prompt that a colleague cannot follow after one read is too vague, not too short.

Should I use ALL CAPS for important rules?

Usually not. Anthropic says newer models are more responsive to the system prompt and recommends replacing phrasing such as CRITICAL: You MUST use this tool with a plain Use this tool when. Shouting can make a model overtrigger the action.

How do I test a system prompt?

Run it against a set of realistic inputs, including edge cases and inputs you expect it to refuse. Compare outputs against a written standard, not a feeling. Track failures by type so you can tell whether a change fixed one problem and created another.

Can a system prompt make an AI agent biased?

Yes. In an Anthropic study, hidden instructions in a system prompt set an agent's lean by coin flip, and expert analysts followed that lean 86% of the time. Write defaults deliberately, especially for decisions that affect customers.