AI & Agents

How to Write a System Prompt for an Agent

The hidden instruction manual you give an AI before it starts working — and why getting it right changes everything.

Scroll to start

What Is a System Prompt?

A system prompt is the hidden instruction manual you give an AI agent before it starts a conversation. It's a set of rules, personality traits, and boundaries you set up so the AI knows how to behave — what to focus on, how to talk, what to avoid, and what tools it can use.

Think of it like training a new assistant on their first day at work. You don't just say "answer the phone." You tell them: greet people warmly, transfer calls to specific extensions, never share private info, and always ask if the caller needs anything else before hanging up. A system prompt is exactly that — the briefing that runs before the agent does anything else, shaping how it responds to every single message it ever sees.

When you chat with an AI like ChatGPT or Claude, you usually see only the conversation: your message, then the AI's reply. The system prompt is a third layer that sits behind the scenes. You don't see it in the chat, but the AI reads it on every turn. It's the difference between asking a stranger for help and asking someone you've already briefed on the job.

The Most Important Part of Any Agent

The system prompt is the single most important part of building an AI agent. It's the difference between a helpful assistant and a confused one that goes off the rails. A good system prompt keeps the agent focused on the right job, makes it sound the way you want it to sound, prevents it from doing things it shouldn't, and makes it reliable across thousands of users.

Without a strong system prompt, the AI will fall back on its default behavior — which is to be helpful in a general, chatty way. That might be fine for casual questions, but it's terrible for serious work. You don't want a customer support agent to suddenly start writing poetry. You don't want a research agent to invent facts. The system prompt is what stops that from happening.

💡 Key Insight

A well-written system prompt is like a job description for the AI. The clearer you are about the role, the rules, and the goals, the better the AI will perform — and the less you'll have to fix later. Most agent failures aren't model failures. They're system prompt failures.

The 4 Parts of a Great System Prompt

Every good system prompt has four key parts. Together they tell the agent who it is, what success looks like, what it must never do, and what tools it can reach for. Skip any one of them and the agent will start to drift.

1
🎭

Role

Who is the agent? "You are a friendly support rep for a small bakery." This sets the personality, tone, and domain. The more specific, the better — vague roles lead to vague answers.

2
🎯

Goals

What should the agent accomplish? List the main jobs it needs to do, in order of importance. Goals give the agent something to aim at and help it decide what to do when a request is unclear.

3
🚧

Rules

What should the agent never do? Hard boundaries, like "never share a customer's email" or "if you don't know, say so instead of guessing." Rules are the guardrails that keep the agent safe.

There's a fourth part that matters for agents (but not for simple chatbots): tools. If your agent can take actions — like searching the web, reading files, or sending emails — you need to tell it which tools it has, when to use them, and what to pass into them. Without a tool list, the agent won't know what it's allowed to reach for.

A Real System Prompt

Here's a complete system prompt for a small customer support agent. It uses the four parts we just covered — Role, Goals, Rules, and Tools — and is short enough to fit in a screenshot.

system_prompt.txt
# ROLE
You are a friendly support agent for an online store
called Acme Gifts. You help customers with orders,
shipping, and returns. Your tone is warm but brief.

# GOALS
- Answer questions about products, orders, and shipping
- Help customers start a return if they need one
- Escalate to a human agent when the issue is complex

# RULES
- Always greet the customer on the first message
- Never share another customer's order information
- If you don't know the answer, say so — don't guess
- Keep responses to 2-3 sentences unless more is needed
- Never discuss competitors or pricing strategy

# TOOLS
- lookup_order(order_id): returns order status
- start_return(order_id, reason): opens a return
- send_email(to, subject, body): emails the customer
- escalate_to_human(summary): hands off to a human

That's a real, working system prompt. It would actually run a useful agent if you plugged it into a tool like LangGraph, CrewAI, or OpenAI's Agents SDK. The power isn't in the length — it's in the structure.

Knowledge Check

Test what you learned about system prompts with this quick quiz.

Quick Quiz — 3 Questions

Question 1
What is a system prompt?
Question 2
Which of these is NOT one of the four parts of a great system prompt?
Question 3
Why is a clear system prompt important when building an AI agent?
🏆

You crushed it!

Perfect score on this module.