How to Write a System Prompt (With a Full Working Example)
A system prompt sets an AI assistant's role, rules and format for a whole conversation. Learn what belongs in it, how to order it, and see a full example.
Role & context
Role and context prompting means telling the model who it is serving, in what situation and under which rules before you give it the task. A system prompt sets that frame for a whole conversation. A role such as “you are a senior tax accountant” helps only when it brings real constraints with it, like audience, standards and what to do when unsure.
Your app parses the model’s JSON, but sometimes the reply starts with “Sure! Here is the JSON:”. What is the most robust fix?
You are building a support bot. Where should the rule “Never promise refunds; hand off to a human instead” go?
A. In the system prompt, as a standing rule Standing rules that apply to the whole conversation belong in the system prompt. User messages change every turn and are also where untrusted input arrives.
A system prompt is the instruction block that sets the model’s role, rules and context for a whole conversation, before any user message. Products use it for tone, scope, safety rules and output format.
Only a little on its own. A role works when you add what that expert would know and care about: the audience, the standards, the format and what to do when information is missing.
A system prompt sets an AI assistant's role, rules and format for a whole conversation. Learn what belongs in it, how to order it, and see a full example.
Do prompts work the same in ChatGPT, Claude and Gemini? Most principles transfer. Here is what differs, and how to test a prompt across models without guessing.
Prompt engineering is the skill of writing inputs that get reliable results from AI models. Learn the parts of a good prompt, with before-and-after examples.
Short quizzes on real prompting decisions, with an explanation for every answer. Free to start on iPhone and Android.