How to write a system prompt that actually holds
The short answer
A good system prompt has five blocks: identity, objective, rules, output contract and escalation. Keep it short enough to read, make every rule testable, and never treat it as a security boundary. Enforcement of permissions, spending and data access belongs in code, not in the prompt.
What is a system prompt?
A system prompt is the instruction set that applies before the user's message. It defines who the assistant is, what it is allowed to do, how it should format answers and when it should refuse or escalate. In API terms it is usually the highest-priority message; in a chat product it is the custom instructions or project context.
It is not a magic safety layer. A prompt can be overridden by a determined user, leaked, or simply ignored under context pressure. Treat it as one layer in a system that also includes input validation, tool permissions, rate limits, logging and human review.
The five-block structure
We use this structure across the system prompts collection:
1. Identity
Who is the assistant, who does it serve, and what is its relationship to the user? Keep it concrete.
``text You are the support assistant for Northline, a B2B analytics product. You help customers understand the product and resolve account questions. You are patient, precise and never sycophantic. ``
2. Objective
State the single job. If there are two jobs, you probably need two prompts.
``text Objective: resolve the customer's question using the documentation provided, or route it to the right human team within two turns. ``
3. Rules
Rules should be testable. "Be helpful" is not testable. "Ask one clarifying question when the request is ambiguous" is.
```text Rules:
- Use only the documentation in <docs>. Do not invent policy, pricing or account data.
- Ask one clarifying question if a required detail is missing.
- Never promise a refund, discount or timeline.
- Escalate billing disputes, security reports and legal threats immediately.
```
4. Output contract
Define the format, length and required sections. If the output is consumed by code, define the schema and validate it.
```text Output:
- A direct answer in no more than two sentences.
- Numbered next steps, or "No action needed".
- If escalating: a one-line hand-off summary for the human agent.
```
5. Escalation
Say what to do when the request is out of scope or the model is uncertain. Give the exact wording so the user experience is consistent.
``text If the request is out of scope, say: "I can't help with that here, but I can route you to a specialist who can." Then collect the minimum information needed to hand off. ``
Make it testable
Write five to ten test cases before you ship the prompt:
- A normal request.
- A request with missing information.
- A request for something out of scope.
- A request that tries to override the instructions.
- A request where the documentation is wrong or outdated.
- A request that should escalate for safety or legal reasons.
Run them on every prompt change. A prompt without tests is a guess.
What a system prompt cannot do
- Enforce permissions. If the model has a tool that can delete records, the prompt saying "do not delete" is not a control. Remove the capability or require approval.
- Guarantee secrecy. Assume the system prompt can be extracted. Do not put API keys, internal URLs or personal data in it.
- Prevent prompt injection. Retrieved documents and user content can contain instructions. Delimit them, instruct the model to treat them as data, and validate tool calls in code.
- Replace evaluation. Test the actual model version you deploy. Behaviour changes between versions.
Common mistakes
Too long. A 2,000-word system prompt hides contradictions. If you cannot explain the rules in a page, the assistant's behaviour will be unpredictable.
Contradictory rules. "Always be concise" plus "explain every step in detail" forces the model to choose silently. Resolve it in the prompt.
No refusal path. If the model has no approved way to say no, it will improvise.
Personality overload. A backstory can make a character fun, but it does not make a support bot accurate. Separate tone from policy.
No version history. Keep prompts in version control with a changelog, like code.
A complete example
The support assistant prompt and the coding assistant prompt show the structure applied to two very different domains. The output schema prompt covers machine-readable responses.
Testing for instruction drift
Long conversations degrade instructions. Test with multi-turn scenarios that introduce distractions, conflicting user instructions and context pressure. Check the constraint after each turn, not just at the end. The instruction drift test prompt includes a starter suite.
The bottom line
A system prompt is an operating manual, not a spell. Keep it short, make every rule testable, put enforcement in code and evaluate the behaviour you actually care about. If the assistant handles money, health, legal or safety decisions, add human review.
Explore all system prompts.
Copy-ready prompts featured in this guide
Copy any prompt below or open its full page with interactive variable fields and platform tabs.
Site Admin
Author & Platform Administrator
Administrator and lead editor at AIPrompt123, curating high-performance AI prompts, SEO/AEO/GEO strategies, and developer repositories.
Questions about this guide
Short answers to what readers ask most about this topic.
Keep reading
The best ChatGPT prompts for students (that actually help you learn)
Most 'study prompts' generate summaries that feel productive and teach you nothing. These twelve prompts are built around retrieval, feedback and self-testing.
The Midjourney prompt formula (with 12 copy-ready examples)
A repeatable structure for Midjourney v7: subject, light, lens, composition and parameters. Plus the mistakes that make images look generic.
Prompt engineering for beginners: zero-shot, few-shot and chain-of-thought
The techniques that matter, when to use them, and why chain-of-thought is not a universal upgrade. With copy-ready patterns.