
The system prompt is the constitution of an AI product. It defines who the assistant is, what it should do, what it must never do and how it should communicate. In a prototype, a two-line system prompt might be enough. In production, where thousands of users will probe edge cases, a weak system prompt produces inconsistent behavior, brand risks and support escalations. This guide explains how to write system prompts that hold up in real products, with system prompt examples, structural templates, versioning practices and common mistakes.
First, understand what a system prompt can and cannot do.
What System Prompts Control
A system prompt shapes:
- Role and purpose: what the assistant is for and who it serves.
- Behavior: how it handles requests, ambiguity and out-of-scope questions.
- Knowledge boundaries: what it should rely on, such as provided documents, and what it should not claim.
- Tone and format: voice, length, structure and formatting conventions.
- Safety and policy: what it must refuse or escalate.
- Tool use: when and how to call available tools.
What a system prompt cannot do is guarantee behavior. Models follow system prompts with high but not perfect reliability, and determined users can attempt to override them. Critical rules should be enforced in code as well.
A Proven Structure
LLM system prompt best practices converge on a structure like this:
- Identity and context: who the assistant is, the product, and the user it serves.
- Goals: what a successful interaction looks like.
- Instructions: specific behaviors, ordered by importance.
- Knowledge and tools: what information sources and tools exist and when to use them.
- Constraints: what to avoid, with reasons.
- Output format: length, structure, formatting rules.
- Examples: a few representative interactions.
Using clear section headings or tags helps the model distinguish components.
Before and After Example
Weak system prompt: You are a helpful assistant for Acme Bank. Be friendly and answer questions.
Strong system prompt: You are the virtual assistant in Acme Bank's mobile app. Users are existing retail customers. Your goal is to resolve account questions quickly and accurately, or route users to the right human channel.
Use only the information in the provided help articles and the user's account data returned by tools. If the answer is not available, say you do not have that information and offer to connect the user with support. Never guess about fees, interest rates or policies, because inaccurate financial information can harm customers.
Use the get transactions tool when users ask about specific payments. Ask for clarification if a request could refer to multiple accounts.
Do not provide investment, tax or legal advice; explain that a qualified advisor can help. If a user mentions fraud or an unrecognized transaction, immediately provide the card freeze option and the fraud hotline.
Respond in plain language, in two to four short sentences unless the user asks for detail. Do not use markdown, since responses appear in a chat bubble.
The strong prompt states context, goals, knowledge boundaries, tool guidance, constraints with reasons and format.
Chatbot System Prompt Guidance
For a chatbot system prompt specifically:
- Define how to handle off-topic requests politely.
- Specify how to escalate to humans and what information to collect first.
- Describe how to handle frustrated or abusive users.
- State how to respond when uncertain.
- Clarify language behavior, such as responding in the user's language.
Explaining Why Improves Compliance
Modern models follow instructions more reliably when they understand the reason. Compare never use ellipses with your responses are read aloud by a text-to-speech engine, so never use ellipses because the engine cannot pronounce them. The explanation helps the model generalize to similar cases.
Positive Instructions Beat Negative Lists
Telling a model what to do is usually more effective than listing what not to do. Instead of do not use markdown, write respond in plain prose paragraphs. Use constraints for genuinely critical prohibitions, and keep them specific.
AI Product Prompts and Personality
AI product prompts must also capture brand voice. Describe tone with concrete guidance and examples rather than adjectives alone. Friendly is vague. Use contractions, address the user by name when known, keep sentences short and avoid exclamation marks is actionable.
Prompt Versioning
Prompt versioning is essential in production:
- Store prompts in version control or a prompt management platform, not hardcoded strings scattered across services.
- Assign version identifiers and log which version produced each response.
- Change one thing at a time so you can attribute effects.
- Run evaluation suites before deploying new versions.
- Roll out gradually and monitor metrics.
- Keep the ability to roll back instantly.
Evaluating System Prompts
Build an evaluation set covering:
- Typical requests that should be handled well.
- Edge cases and ambiguous requests.
- Out-of-scope requests.
- Adversarial attempts, such as asking the assistant to ignore its instructions.
- Format compliance checks.
Use automated grading where possible and human review for nuanced cases. Every production incident should become a new test case.
Common Mistakes to Avoid
- Overly long prompts. Excessive rules dilute important ones and can cause the model to become rigid.
- Contradictions. Conflicting instructions produce unpredictable behavior.
- Shouting. Excessive capital letters and repeated warnings can cause overcorrection in modern models. State rules calmly and clearly.
- Hardcoding facts that change. Put changing information in retrieved documents or tools.
- Relying only on the prompt for security. Enforce permissions and data access in code.
- No examples. A few well-chosen examples often clarify more than paragraphs of rules.
Prompt Engineering Techniques for System Prompts
- Role framing for context and tone.
- Structured sections or tags for clarity.
- Few-shot examples for format and tone.
- Reasoning instructions for complex tasks, such as checking account eligibility before answering.
- Explicit uncertainty handling to reduce hallucination.
Frequently Asked Questions
How long should a system prompt be? As long as needed to cover essential behavior, but no longer. Many effective production prompts are a few hundred to a couple thousand words.
Should the system prompt be secret? Assume users may extract it. Do not place secrets or sensitive business logic in prompts.
Benefits and Considerations
Well-designed system prompts produce consistent behavior, reduce harmful outputs, strengthen brand voice and lower support costs. The considerations include maintenance as products evolve, testing effort and the reality that prompts are probabilistic controls.
Conclusion
Knowing how to write system prompts for production means structuring identity, goals, instructions, knowledge, constraints, format and examples clearly, explaining the reasons behind rules, and managing prompts with versioning and evaluation.
Key takeaways: be specific and explain why, prefer positive instructions, include examples, version every change, test against adversarial cases and enforce critical rules in code. Audit your current system prompt this week against the structure above and add an evaluation set before your next change.