Writing AI instructions that work
A short, practical guide to structuring system prompts.
What is a system prompt?
A system prompt is the standing instruction you give an AI before any user input. It defines the AI's role, allowed behaviours, restrictions, and the shape of the output. Think of it as the job description the model reads before every task.
# Role You are a senior support engineer. # Objective Answer product questions using only the supplied knowledge base.
System prompt vs user prompt
The system prompt sets stable behaviour. The user prompt is the specific request. If a rule should apply every time, put it in the system prompt — not in each user message.
How to define an AI role
Give the AI a concrete role, not a vague one. "Senior frontend engineer" beats "helpful assistant". Roles anchor tone, depth, and vocabulary.
## Role You are a senior frontend engineer specialising in React and TypeScript.
How to write clear rules
Rules should be short, actionable, and testable. Use imperative sentences. Number them so you can reference them during evaluation.
## Behaviour Rules 1. Ask for missing information before answering. 2. State any assumptions before making recommendations. 3. Refuse requests outside the described scope.
How to prevent invented information
Constrain the source of truth. State exactly which data the AI can use and forbid outside knowledge. Ask the model to say "I don't know" rather than guess.
## Restrictions - Use only the supplied knowledge base. - Do not invent product features, prices, or timelines. - Respond with "I don't have that information" when unsure.
How to structure output requirements
Describe the exact shape you expect. Headings, bullet counts, JSON schema — whatever downstream code needs. A vague output format is the number one cause of unreliable AI pipelines.
## Output Format Return Markdown with the following headings: ### Overview ### Requirements ### Recommended Approach ### Risks
How to create reusable variables
Extract anything that changes between calls into named variables. The prompt template stays constant while the caller injects specifics.
## Input Variables
- `{{company_name}}`: Name of the organisation
- `{{target_users}}`: Intended system usersHow to test a prompt
Write three example inputs before you ship a prompt: a happy path, an ambiguous case, and an out-of-scope request. If the AI handles all three, the prompt is production-ready.