System Prompt Cheatsheet: How to Write Effective System Prompts

Templates and best practices for LLM system instructions

Ad placeholder (leaderboard)

What a system prompt is for

A system prompt is the standing instruction that shapes how a model behaves across an entire conversation. Unlike a user message — which is a one-off request — the system prompt persists on every turn and is weighted more heavily, which makes it the right place to define the assistant’s role, its tone, the rules it must always follow, and the format its answers should take. A good system prompt is the difference between a generic chatbot and a focused tool that stays in character, refuses what it should refuse, and returns output your application can actually use. The skill is putting stable behaviour in the system prompt and leaving the specific task to the user message.

The anatomy of an effective system prompt

A reliable system prompt covers, roughly in order of importance:

  1. Role and goal — “You are a customer support assistant for an e-commerce store. Your goal is to resolve order questions quickly and accurately.”
  2. Audience and tone — who the user is and how to sound (concise, warm, formal).
  3. Hard constraints — what it must never do (“Never invent order details. Never promise refunds; escalate those to a human.”).
  4. Output format — structure, length, whether to use markdown, JSON, or plain text.
  5. Fallback behaviour — what to do when it lacks information (“If you do not know, say so and offer to escalate.”).

Lead with the constraints that matter most, group related rules, and keep it tight — every line is paid for on every turn, and a bloated prompt dilutes the instructions that count.

Three reusable templates

Support bot: “You are a support assistant for [product]. Answer only from the provided knowledge base. If the answer is not there, say you are not sure and offer to connect a human. Be concise and friendly. Never make up policy, prices, or account details.”

Coding assistant: “You are a senior [language] engineer. Provide correct, runnable code with brief explanations. Prefer standard libraries. Point out edge cases and security risks. If requirements are ambiguous, ask one clarifying question before coding.”

Content writer: “You are a marketing copywriter for [audience]. Write in a [tone] voice. Keep paragraphs short. Avoid clichés and hype. Return a headline plus body, in markdown. Do not fabricate statistics.”

Adapt the bracketed fields and add domain-specific rules as needed — these skeletons cover the role-tone-constraints-format pattern that works across models.

Anti-patterns and model-specific notes

Avoid the common traps: vague roles (“be helpful” tells the model nothing useful), contradictory rules (be thorough and be brief — say which wins), secrets in the prompt (it can be extracted or leaked), and negative-only instructions that never say what to do. State the desired behaviour positively wherever you can. On the model side, Claude responds well to system prompts that use XML tags to separate sections and to being told to think before answering; ChatGPT and Gemini handle plain prose and markdown headers cleanly. Remember the system prompt guides behaviour but is not a hard security boundary — enforce real authorisation and data access in your backend, and test your prompt by deleting lines to see which ones the model actually needs.

Ad placeholder (rectangle)