How to Write a System Prompt for an AI Agent (Template)
The system prompt (sometimes called custom instructions) is the single most important piece of an AI agent. It's where you tell the assistant who it is, what it's trying to do, how to do it, and what it must not do. A good one makes an average assistant dependable. A vague one makes a great assistant unpredictable.
Here's a six-part template you can reuse for any agent.
The six-part template
ROLE: You are [role] who helps me with [job].
GOAL: Your goal is to [specific outcome].
PROCESS: 1. [step] 2. [step] 3. [step]
OUTPUT: Reply in this format: [format, length].
RULES: [limits, safety rules, what to do when unsure]
SELF-CHECK: Before replying, verify [checks]. Fix anything that fails.
Let's go through each part.
Role
One sentence. Not "you are the world's best expert" (that just adds fluff) but a concrete role: "You are a careful research assistant who summarizes sources for a busy reader."
Goal
What does success look like? Be specific. "Produce a one-page brief that lists three key findings, each with a source and a confidence level" beats "do research."
Process
Number the steps. Agents follow numbered steps far more reliably than they follow a paragraph of prose. Include a step for asking clarifying questions if inputs are missing.
Output format
Tell it exactly what to return: headings, bullet list, table, word limit. If you want to paste the output somewhere, specify the format that will paste well.
Rules
This is where safety and reliability live. Good rules to start with:
- "If you're not sure, say so and ask me. Don't guess."
- "Never invent facts, quotes, links or numbers."
- "Don't ask for or repeat passwords, keys or private data."
- "Draft only: never claim you sent, bought or changed anything."
Self-check
A final instruction to review the answer against the rules before replying. This small addition catches a surprising number of mistakes.
Example 1: research brief agent
ROLE: You are a careful research assistant who writes briefs for a
busy reader.
GOAL: Given a topic, produce a one-page brief with 3 key findings.
PROCESS:
1. If the topic is vague, ask up to 3 clarifying questions first.
2. List what you know with confidence and what you're unsure of.
3. Write the brief.
OUTPUT: Headline, three findings (one sentence each + why it
matters), a "what I couldn't verify" list, under 300 words.
RULES: Never invent sources or statistics. Mark every uncertain
claim as "unverified". If you can't answer, say so.
SELF-CHECK: Confirm every finding is either well-supported or
marked unverified, and the brief is under 300 words.
Example 2: code explainer
ROLE: You are a patient coding tutor.
GOAL: Help me understand code I paste, in plain English.
PROCESS:
1. Summarize what the code does in 2 sentences.
2. Explain it step by step.
3. Point out one potential bug or improvement.
OUTPUT: Summary, numbered explanation, one suggestion.
RULES: Assume I'm a beginner. Don't rewrite the code unless I ask.
If a function or library is unfamiliar to you, say so. Warn me
before suggesting anything that deletes files or sends data.
SELF-CHECK: Make sure you didn't skip a step or invent a function.
Common mistakes
- Too long. Past a point, extra instructions get ignored or conflict. Keep it focused on one job.
- Conflicting rules. "Be brief" and "explain everything in detail" can't both win.
- No example. If format matters, show one short example of a good output.
- No stop condition. Tell the agent when it's done and when to hand the decision back to you.
- Putting secrets in the prompt. Treat anything in a system prompt as potentially visible. Never include keys or passwords.
How to improve it over time
Keep a "failures" note. Whenever the agent does something wrong, write down the input and the problem, add or tighten one rule, and retest the same input. After a few rounds you'll have a prompt that handles your real situations, not hypothetical ones.
Templates and blueprints, ready to go
The AI Agent Starter Kit for Beginners includes five complete agent blueprints, each with a goal, a full system prompt, the tools it needs, an example run and common pitfalls with fixes, plus 25 reusable prompt templates and a blank blueprint template for designing your own.
Just getting started? Read what an AI agent is first, then how to build one without coding.
AI Agent Starter Kit for Beginners
Build your first AI agent in an afternoon. No coding required. 25-page PDF, $12.