System Prompts: Setting Role, Tone and Rules

JS
Jai Singh
11 Nov, 2026 3 min read 18 views

A system prompt is the set of standing instructions you give the model before any user input. It defines who the model is, who it is talking to, what it must and must not do, and how answers should look. A good one is the cheapest way to improve consistency across thousands of requests.

What belongs in a system prompt

  • Role and goal: what job the model is doing and for whom.
  • Audience: beginners, experts, customers, internal staff.
  • Rules: topics to avoid, things to always include, how to handle missing information.
  • Output format: length, structure, language, markdown or plain text.
  • Stable reference material: product facts, policies, glossaries that apply to every request.

Per-request details, like the user's actual question or a specific document, belong in the user message. Keeping the system prompt stable also lets you cache it, which saves money.

From vague to useful

Compare a weak prompt and a stronger one for a support assistant.

weak = "You are a helpful assistant."

strong = """You are the support assistant for Acme Notes, a note-taking app.

Audience: non-technical customers.
Goal: resolve the question in as few steps as possible.

Rules:
- Use only the facts in the product notes below. If the answer is not there, say you are not sure and offer to connect the customer to a human.
- Never promise refunds or dates. Refund requests go to billing@example.com.
- Keep replies under 120 words and use plain text, no markdown.

Product notes:
- Notes sync across devices within about a minute.
- Free plan: 50 notes. Pro plan: unlimited notes and offline mode.
"""

The strong version tells the model the context, the audience, what to do when it lacks information, and the format. Tests with real questions will show much less drift in tone and fewer invented answers.

Using it in a call

import anthropic

client = anthropic.Anthropic()
reply = client.messages.create(
    model="claude-haiku-5-5",
    max_tokens=400,
    system=strong,
    messages=[{"role": "user", "content": "Can I use Acme Notes offline?"}],
)
print(reply.content[0].text)

Expect an answer that says offline mode is part of the Pro plan, in plain text and under 120 words.

Tips for writing them

  • Explain the reason behind a rule. "Keep answers short because they appear in a small chat widget" works better than "Be brief".
  • Say what to do, not only what to avoid. Give a fallback behaviour for unknown cases.
  • Use sections or XML tags when the prompt is long, so the model can tell rules from reference data.
  • Do not repeat the same instruction five times in capitals. Clear once is better than shouted often.
  • Keep it as short as the job allows. Every token is paid on every request.

Structure long prompts clearly

When a system prompt grows beyond a few lines, give it visible structure. Group instructions under short headings, or wrap reference data in tags such as <policies> and <product_notes>. This helps the model separate rules from facts, and it helps your teammates review the prompt. Place long reference material first and the specific instructions about how to use it after, or keep the stable parts first so they can be cached.

Test it with awkward inputs

A system prompt that works for the happy path can fail on edge cases. Build a small list of tricky questions: something off-topic, something the notes do not cover, an angry message, a request to ignore the rules, and a very short or empty message. Run them whenever you edit the prompt and read the answers. Your list of sample questions will grow over time and becomes the seed of a real evaluation set.

A system prompt is not a security boundary

Users can try to override or extract your instructions. Do not put secrets, API keys or private rules you cannot afford to leak into a system prompt. Enforce permissions in your code, not in prose. See the prompt injection topic for defences.

Treat it as code

Store the system prompt in version control, test changes against a fixed set of sample questions, and review diffs like any other change. Small wording edits can shift behaviour in surprising ways.

Was this article helpful?

Comments

No comments yet. Have a question or a tip? Be the first to share it.

Leave a comment

Comments are reviewed before they appear.